Invoices: alanyi adómentes (AAM) by default
INVOICE_VAT picks the VAT of the invoices: AAM (no VAT, net = gross, the invoice says so) or a rate like 27% once the exemption limit is passed. The packages page tells which. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -48,12 +48,13 @@ CREATE TABLE invoices (
|
|||||||
-- Billingo's partner tax type: HAS_TAX_NUMBER, NO_TAX_NUMBER or FOREIGN.
|
-- Billingo's partner tax type: HAS_TAX_NUMBER, NO_TAX_NUMBER or FOREIGN.
|
||||||
buyer_tax_type text NOT NULL CHECK (buyer_tax_type IN ('HAS_TAX_NUMBER', 'NO_TAX_NUMBER', 'FOREIGN')),
|
buyer_tax_type text NOT NULL CHECK (buyer_tax_type IN ('HAS_TAX_NUMBER', 'NO_TAX_NUMBER', 'FOREIGN')),
|
||||||
buyer_tax_number text,
|
buyer_tax_number text,
|
||||||
-- The single item, gross price with 27% VAT.
|
-- The single item. vat_rate is Billingo's VAT value: AAM (alanyi
|
||||||
|
-- adómentes: net = gross, no VAT) or a rate like 27%.
|
||||||
item_name text NOT NULL,
|
item_name text NOT NULL,
|
||||||
gross_huf integer NOT NULL CHECK (gross_huf > 0),
|
gross_huf integer NOT NULL CHECK (gross_huf > 0),
|
||||||
net_huf integer NOT NULL,
|
net_huf integer NOT NULL,
|
||||||
vat_huf integer NOT NULL,
|
vat_huf integer NOT NULL,
|
||||||
vat_rate text NOT NULL DEFAULT '27%',
|
vat_rate text NOT NULL DEFAULT 'AAM',
|
||||||
payment_method text NOT NULL DEFAULT 'online_bankcard',
|
payment_method text NOT NULL DEFAULT 'online_bankcard',
|
||||||
-- From Billingo.
|
-- From Billingo.
|
||||||
billingo_partner_id bigint,
|
billingo_partner_id bigint,
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ services:
|
|||||||
# Stripe purchases for everyone (false: admins only, until the opening;
|
# Stripe purchases for everyone (false: admins only, until the opening;
|
||||||
# with a test key always admins only).
|
# with a test key always admins only).
|
||||||
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
||||||
|
# VAT on the invoices: AAM (alanyi adómentes) or a rate like 27%.
|
||||||
|
INVOICE_VAT: ${INVOICE_VAT:-AAM}
|
||||||
# Users inviting others ("Meghívom"): shown but off until the launch.
|
# Users inviting others ("Meghívom"): shown but off until the launch.
|
||||||
USER_INVITES: ${USER_INVITES:-false}
|
USER_INVITES: ${USER_INVITES:-false}
|
||||||
# A new user from a shared link earns the sharer an analysis: off until sign-up opens.
|
# A new user from a shared link earns the sharer an analysis: off until sign-up opens.
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ services:
|
|||||||
# Stripe purchases for everyone (false: admins only, until the opening;
|
# Stripe purchases for everyone (false: admins only, until the opening;
|
||||||
# with a test key always admins only).
|
# with a test key always admins only).
|
||||||
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
PURCHASES_OPEN: ${PURCHASES_OPEN:-false}
|
||||||
|
# VAT on the invoices: AAM (alanyi adómentes) or a rate like 27%.
|
||||||
|
INVOICE_VAT: ${INVOICE_VAT:-AAM}
|
||||||
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
|
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
|
||||||
# invite: new accounts need an invitation (admin page "Meghívók"); open: anyone.
|
# invite: new accounts need an invitation (admin page "Meghívók"); open: anyone.
|
||||||
SIGNUP_MODE: ${SIGNUP_MODE:-invite}
|
SIGNUP_MODE: ${SIGNUP_MODE:-invite}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ A katalógus a kódban van: `services/backend/src/packages.rs` (`CATALOG`). Ár-
|
|||||||
|
|
||||||
## Költség
|
## Költség
|
||||||
|
|
||||||
Egy részletes képletelemzés és egy kapcsolati elemzés is kb. **$0,21 (≈ 80 Ft)** Opus 5.5-tel, az éves előrejelzés a hosszabb adatsor miatt valamivel több; a rövid összefoglaló kb. $0,01. A fizetési szolgáltató díja kb. 1,5% + 85 Ft tranzakciónként. Az árak bruttók (27% áfa).
|
Egy részletes képletelemzés és egy kapcsolati elemzés is kb. **$0,21 (≈ 80 Ft)** Opus 5.5-tel, az éves előrejelzés a hosszabb adatsor miatt valamivel több; a rövid összefoglaló kb. $0,01. A fizetési szolgáltató díja kb. 1,5% + 85 Ft tranzakciónként. Az árak végső árak: alanyi adómentesek vagyunk (`INVOICE_VAT=AAM`), áfát nem számítunk fel; ha átlépjük az alanyi adómentesség határát, `INVOICE_VAT=27%`, és az árak bruttóként értendők.
|
||||||
|
|
||||||
## A lépcső
|
## A lépcső
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ A sorok a fiók törlése után is megmaradnak (`user_id` → NULL), mert a szá
|
|||||||
|
|
||||||
## Számla
|
## Számla
|
||||||
|
|
||||||
Fizetéskor a backend egy `invoices` sort is létrehoz a számla minden adatával: a vevő (név, e-mail, ország, irányítószám, város, cím, Billingo-adótípus: `HAS_TAX_NUMBER` / `NO_TAX_NUMBER` / `FOREIGN`, adószám) és a tétel (név, bruttó, nettó, áfa, 27%). Cégnél a `business_name` és a magyar adószám (`hu_tin`, ennek híján `eu_vat`) kerül a számlára.
|
Fizetéskor a backend egy `invoices` sort is létrehoz a számla minden adatával: a vevő (név, e-mail, ország, irányítószám, város, cím, Billingo-adótípus: `HAS_TAX_NUMBER` / `NO_TAX_NUMBER` / `FOREIGN`, adószám) és a tétel (név, végösszeg, nettó, áfa, áfakód). Az áfakód az `INVOICE_VAT` (a backend `.env`-je): alapból `AAM` (alanyi adómentes: nettó = végösszeg, áfa 0, a számla megjegyzésében „Alanyi adómentes.”), vagy egy kulcs, pl. `27%`. Cégnél a `business_name` és a magyar adószám (`hu_tin`, ennek híján `eu_vat`) kerül a számlára.
|
||||||
|
|
||||||
A worker `invoices` feladata (`WORKER_TASKS`, prodon a `worker` konténerben) a Billingo API v3-mal:
|
A worker `invoices` feladata (`WORKER_TASKS`, prodon a `worker` konténerben) a Billingo API v3-mal:
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ pub struct Config {
|
|||||||
/// Stripe Checkout, when `STRIPE_SECRET_KEY` is set (it wins over
|
/// Stripe Checkout, when `STRIPE_SECRET_KEY` is set (it wins over
|
||||||
/// `MOCK_PAYMENTS`).
|
/// `MOCK_PAYMENTS`).
|
||||||
pub stripe: Option<StripeConfig>,
|
pub stripe: Option<StripeConfig>,
|
||||||
|
/// `INVOICE_VAT` (default `AAM`, alanyi adómentes; or e.g. `27%`).
|
||||||
|
pub invoice_vat: crate::invoices::Vat,
|
||||||
/// `BILLINGO_API_KEY`: downloading invoices (the worker issues them).
|
/// `BILLINGO_API_KEY`: downloading invoices (the worker issues them).
|
||||||
pub billingo_api_key: Option<String>,
|
pub billingo_api_key: Option<String>,
|
||||||
/// `BILLINGO_API_URL` (default `https://api.billingo.hu/v3`).
|
/// `BILLINGO_API_URL` (default `https://api.billingo.hu/v3`).
|
||||||
@@ -174,6 +176,11 @@ impl Config {
|
|||||||
.trim_end_matches('/')
|
.trim_end_matches('/')
|
||||||
.to_string(),
|
.to_string(),
|
||||||
}),
|
}),
|
||||||
|
invoice_vat: match var("INVOICE_VAT") {
|
||||||
|
None => crate::invoices::Vat::Exempt,
|
||||||
|
Some(raw) => crate::invoices::Vat::parse(&raw)
|
||||||
|
.with_context(|| format!("invalid INVOICE_VAT '{raw}': use AAM or a rate like 27%"))?,
|
||||||
|
},
|
||||||
billingo_api_key: var("BILLINGO_API_KEY"),
|
billingo_api_key: var("BILLINGO_API_KEY"),
|
||||||
billingo_api_url: var("BILLINGO_API_URL")
|
billingo_api_url: var("BILLINGO_API_URL")
|
||||||
.unwrap_or_else(|| "https://api.billingo.hu/v3".into())
|
.unwrap_or_else(|| "https://api.billingo.hu/v3".into())
|
||||||
@@ -220,6 +227,7 @@ impl Config {
|
|||||||
password_login: true,
|
password_login: true,
|
||||||
mock_payments: true,
|
mock_payments: true,
|
||||||
stripe: None,
|
stripe: None,
|
||||||
|
invoice_vat: crate::invoices::Vat::Exempt,
|
||||||
billingo_api_key: Some("billingo-fake".into()),
|
billingo_api_key: Some("billingo-fake".into()),
|
||||||
billingo_api_url: format!("{horoscope_api_url}/billingo"),
|
billingo_api_url: format!("{horoscope_api_url}/billingo"),
|
||||||
purchases_open: true,
|
purchases_open: true,
|
||||||
|
|||||||
@@ -9,8 +9,41 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use crate::error::ApiError;
|
use crate::error::ApiError;
|
||||||
|
|
||||||
/// VAT of every package, in percent.
|
/// The VAT on the invoices (`INVOICE_VAT`): `AAM` (alanyi adómentes, subject
|
||||||
pub const VAT_PERCENT: i64 = 27;
|
/// to the small business exemption: no VAT, net = gross) or a rate like `27%`.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub enum Vat {
|
||||||
|
Exempt,
|
||||||
|
Percent(i64),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Vat {
|
||||||
|
pub fn parse(raw: &str) -> Option<Self> {
|
||||||
|
match raw.trim() {
|
||||||
|
"AAM" => Some(Vat::Exempt),
|
||||||
|
rate => rate.strip_suffix('%')?.trim().parse().ok().filter(|p| (1..=27).contains(p)).map(Vat::Percent),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Billingo's VAT value.
|
||||||
|
pub fn code(self) -> String {
|
||||||
|
match self {
|
||||||
|
Vat::Exempt => "AAM".into(),
|
||||||
|
Vat::Percent(p) => format!("{p}%"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Net and VAT parts of a gross price (rounded to forints, as Billingo does).
|
||||||
|
pub fn split(self, gross: i64) -> (i64, i64) {
|
||||||
|
match self {
|
||||||
|
Vat::Exempt => (gross, 0),
|
||||||
|
Vat::Percent(p) => {
|
||||||
|
let net = (gross * 200 + 100 + p) / (200 + 2 * p);
|
||||||
|
(net, gross - net)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The buyer as invoiced, from Stripe's `customer_details`.
|
/// The buyer as invoiced, from Stripe's `customer_details`.
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
@@ -61,12 +94,6 @@ impl Buyer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Net and VAT parts of a gross price (rounded to forints, as Billingo does).
|
|
||||||
pub fn split_gross(gross: i64) -> (i64, i64) {
|
|
||||||
let net = (gross * 200 + 100 + VAT_PERCENT) / (200 + 2 * VAT_PERCENT);
|
|
||||||
(net, gross - net)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Queues the invoice of a paid checkout, inside the caller's transaction.
|
/// Queues the invoice of a paid checkout, inside the caller's transaction.
|
||||||
pub async fn queue(
|
pub async fn queue(
|
||||||
tx: &mut PgConnection,
|
tx: &mut PgConnection,
|
||||||
@@ -75,9 +102,10 @@ pub async fn queue(
|
|||||||
buyer: &Buyer,
|
buyer: &Buyer,
|
||||||
item_name: &str,
|
item_name: &str,
|
||||||
gross_huf: i64,
|
gross_huf: i64,
|
||||||
|
vat: Vat,
|
||||||
) -> Result<Uuid, ApiError> {
|
) -> Result<Uuid, ApiError> {
|
||||||
let id = Uuid::now_v7();
|
let id = Uuid::now_v7();
|
||||||
let (net, vat) = split_gross(gross_huf);
|
let (net, vat_huf) = vat.split(gross_huf);
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
"INSERT INTO invoices (id, checkout_id, user_id, buyer_name, buyer_email, buyer_country, buyer_post_code, \
|
"INSERT INTO invoices (id, checkout_id, user_id, buyer_name, buyer_email, buyer_country, buyer_post_code, \
|
||||||
buyer_city, buyer_address, buyer_tax_type, buyer_tax_number, item_name, gross_huf, net_huf, vat_huf, vat_rate) \
|
buyer_city, buyer_address, buyer_tax_type, buyer_tax_number, item_name, gross_huf, net_huf, vat_huf, vat_rate) \
|
||||||
@@ -98,8 +126,8 @@ pub async fn queue(
|
|||||||
.bind(item_name)
|
.bind(item_name)
|
||||||
.bind(gross_huf as i32)
|
.bind(gross_huf as i32)
|
||||||
.bind(net as i32)
|
.bind(net as i32)
|
||||||
.bind(vat as i32)
|
.bind(vat_huf as i32)
|
||||||
.bind(format!("{VAT_PERCENT}%"))
|
.bind(vat.code())
|
||||||
.execute(&mut *tx)
|
.execute(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(id)
|
Ok(id)
|
||||||
@@ -113,9 +141,16 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn gross_prices_split_into_net_and_vat() {
|
fn gross_prices_split_into_net_and_vat() {
|
||||||
assert_eq!(split_gross(2000), (1575, 425));
|
let vat = Vat::parse("27%").unwrap();
|
||||||
assert_eq!(split_gross(6000), (4724, 1276));
|
assert_eq!(vat.split(2000), (1575, 425));
|
||||||
assert_eq!(split_gross(127), (100, 27));
|
assert_eq!(vat.split(6000), (4724, 1276));
|
||||||
|
assert_eq!(vat.split(127), (100, 27));
|
||||||
|
assert_eq!(vat.code(), "27%");
|
||||||
|
// Alanyi adómentes: no VAT at all.
|
||||||
|
assert_eq!(Vat::parse("AAM"), Some(Vat::Exempt));
|
||||||
|
assert_eq!(Vat::Exempt.split(6000), (6000, 0));
|
||||||
|
assert_eq!(Vat::parse("huszonhét"), None);
|
||||||
|
assert_eq!(Vat::parse("99%"), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub struct Package {
|
|||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
pub tagline: &'static str,
|
pub tagline: &'static str,
|
||||||
pub tier: Tier,
|
pub tier: Tier,
|
||||||
/// Gross price (27% VAT included).
|
/// The price paid (with VAT if `INVOICE_VAT` is a rate; none under AAM).
|
||||||
pub price_huf: i64,
|
pub price_huf: i64,
|
||||||
pub natal: i64,
|
pub natal: i64,
|
||||||
pub synastry: i64,
|
pub synastry: i64,
|
||||||
|
|||||||
@@ -173,6 +173,8 @@ async fn public_config(State(state): St) -> Json<Value> {
|
|||||||
"payments": payments::method(c),
|
"payments": payments::method(c),
|
||||||
"payments_admins_only": payments::admins_only(c),
|
"payments_admins_only": payments::admins_only(c),
|
||||||
"payments_test": c.stripe.as_ref().is_some_and(|s| s.test_mode()),
|
"payments_test": c.stripe.as_ref().is_some_and(|s| s.test_mode()),
|
||||||
|
// "AAM" (alanyi adómentes: the prices carry no VAT) or a rate like "27%".
|
||||||
|
"vat": c.invoice_vat.code(),
|
||||||
"user_invites": c.user_invites,
|
"user_invites": c.user_invites,
|
||||||
"referral_rewards": c.referral_rewards,
|
"referral_rewards": c.referral_rewards,
|
||||||
"signup_mode": c.signup_mode.as_str(),
|
"signup_mode": c.signup_mode.as_str(),
|
||||||
|
|||||||
@@ -207,7 +207,8 @@ async fn complete(state: &AppState, session: &stripe::Session) -> Result<bool, A
|
|||||||
.await?;
|
.await?;
|
||||||
let buyer = invoices::Buyer::from_stripe(session.customer_details.as_ref().unwrap_or(&Value::Null), None);
|
let buyer = invoices::Buyer::from_stripe(session.customer_details.as_ref().unwrap_or(&Value::Null), None);
|
||||||
let item = format!("Sorsfonalak – {}", package.name);
|
let item = format!("Sorsfonalak – {}", package.name);
|
||||||
invoices::queue(&mut tx, &session.id, user_id, &buyer, &item, amount_huf.unwrap_or(i64::from(price_huf))).await?;
|
let gross = amount_huf.unwrap_or(i64::from(price_huf));
|
||||||
|
invoices::queue(&mut tx, &session.id, user_id, &buyer, &item, gross, state.config.invoice_vat).await?;
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
tracing::info!(user = ?user_id, package = %package_id, session = %session.id, "package paid");
|
tracing::info!(user = ?user_id, package = %package_id, session = %session.id, "package paid");
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|||||||
@@ -2295,6 +2295,7 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
|
|||||||
let r = app.get("/v1/config", None).await;
|
let r = app.get("/v1/config", None).await;
|
||||||
assert_eq!(r.body["payments"], "stripe");
|
assert_eq!(r.body["payments"], "stripe");
|
||||||
assert_eq!(r.body["payments_test"], false);
|
assert_eq!(r.body["payments_test"], false);
|
||||||
|
assert_eq!(r.body["vat"], "AAM");
|
||||||
// Stripe replaces the stand-in payment.
|
// Stripe replaces the stand-in payment.
|
||||||
assert_eq!(r.body["mock_payments"], false);
|
assert_eq!(r.body["mock_payments"], false);
|
||||||
let anna = app.register("anna@example.com", "Anna").await;
|
let anna = app.register("anna@example.com", "Anna").await;
|
||||||
@@ -2404,7 +2405,8 @@ async fn stripe_checkout_grants_the_paid_package_once(pool: PgPool) {
|
|||||||
("HAS_TAX_NUMBER", Some("12345678-1-23"))
|
("HAS_TAX_NUMBER", Some("12345678-1-23"))
|
||||||
);
|
);
|
||||||
assert_eq!(invoice.item_name, "Sorsfonalak – Páros");
|
assert_eq!(invoice.item_name, "Sorsfonalak – Páros");
|
||||||
assert_eq!((invoice.gross_huf, invoice.net_huf, invoice.vat_huf), (6000, 4724, 1276));
|
// Alanyi adómentes (the default): no VAT.
|
||||||
|
assert_eq!((invoice.gross_huf, invoice.net_huf, invoice.vat_huf), (6000, 6000, 0));
|
||||||
|
|
||||||
// The user's invoices: being prepared until Billingo issues it, then the
|
// The user's invoices: being prepared until Billingo issues it, then the
|
||||||
// PDF comes from Billingo.
|
// PDF comes from Billingo.
|
||||||
|
|||||||
@@ -114,7 +114,11 @@ export default async function PackagesPage() {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</dl>
|
</dl>
|
||||||
<p className="hint">Az árak bruttó árak, az áfát tartalmazzák.</p>
|
<p className="hint">
|
||||||
|
{config?.vat === "AAM" || !config
|
||||||
|
? "Az árak végső árak: alanyi adómentesek vagyunk, áfát nem számítunk fel."
|
||||||
|
: `Az árak bruttó árak, a ${config.vat} áfát tartalmazzák.`}
|
||||||
|
</p>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ export interface PublicConfig {
|
|||||||
payments_admins_only: boolean;
|
payments_admins_only: boolean;
|
||||||
/** Stripe has a test key (test cards work, no real money). */
|
/** Stripe has a test key (test cards work, no real money). */
|
||||||
payments_test: boolean;
|
payments_test: boolean;
|
||||||
|
/** "AAM": alanyi adómentes, the prices carry no VAT; otherwise the rate, e.g. "27%". */
|
||||||
|
vat: string;
|
||||||
/** "invite": new accounts need an invitation. */
|
/** "invite": new accounts need an invitation. */
|
||||||
signup_mode: "invite" | "open";
|
signup_mode: "invite" | "open";
|
||||||
/** Users may invite others (off until the launch; admins always may). */
|
/** Users may invite others (off until the launch; admins always may). */
|
||||||
|
|||||||
@@ -243,7 +243,11 @@ async fn issue(db: &PgPool, billingo: &Billingo, due: &Due) -> Result<String, Fa
|
|||||||
"unit": "db",
|
"unit": "db",
|
||||||
"vat": due.vat_rate,
|
"vat": due.vat_rate,
|
||||||
}],
|
}],
|
||||||
"comment": "Bankkártyával kifizetve (Stripe).",
|
"comment": if due.vat_rate == "AAM" {
|
||||||
|
"Bankkártyával kifizetve (Stripe). Alanyi adómentes."
|
||||||
|
} else {
|
||||||
|
"Bankkártyával kifizetve (Stripe)."
|
||||||
|
},
|
||||||
});
|
});
|
||||||
let doc = billingo.call(Method::POST, "/documents", Some(&body)).await?;
|
let doc = billingo.call(Method::POST, "/documents", Some(&body)).await?;
|
||||||
let id = doc["id"].as_i64().ok_or("Billingo invoice without id")?;
|
let id = doc["id"].as_i64().ok_or("Billingo invoice without id")?;
|
||||||
@@ -353,7 +357,7 @@ mod tests {
|
|||||||
Json(json!({"id": 900 + n, "invoice_number": format!("SF-2026-{n}"), "invoice_date": "2026-11-20",
|
Json(json!({"id": 900 + n, "invoice_number": format!("SF-2026-{n}"), "invoice_date": "2026-11-20",
|
||||||
"fulfillment_date": body["fulfillment_date"], "due_date": body["due_date"],
|
"fulfillment_date": body["fulfillment_date"], "due_date": body["due_date"],
|
||||||
"gross_total": 6000.0,
|
"gross_total": 6000.0,
|
||||||
"items": [{"name": "x", "net_amount": 4724.41, "vat_amount": 1275.59, "gross_amount": 6000.0}]})),
|
"items": [{"name": "x", "net_amount": 6000.0, "vat_amount": 0.0, "gross_amount": 6000.0}]})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
async fn send(
|
async fn send(
|
||||||
@@ -395,7 +399,7 @@ mod tests {
|
|||||||
"INSERT INTO invoices (id, checkout_id, buyer_name, buyer_email, buyer_country, buyer_post_code, \
|
"INSERT INTO invoices (id, checkout_id, buyer_name, buyer_email, buyer_country, buyer_post_code, \
|
||||||
buyer_city, buyer_address, buyer_tax_type, buyer_tax_number, item_name, gross_huf, net_huf, vat_huf) \
|
buyer_city, buyer_address, buyer_tax_type, buyer_tax_number, item_name, gross_huf, net_huf, vat_huf) \
|
||||||
VALUES ($1, $2, 'Csillag Kft.', 'anna@example.com', 'HU', '6720', 'Szeged', 'Fő utca 1.', $3, $4, \
|
VALUES ($1, $2, 'Csillag Kft.', 'anna@example.com', 'HU', '6720', 'Szeged', 'Fő utca 1.', $3, $4, \
|
||||||
'Sorsfonalak – Páros', 6000, 4724, 1276)",
|
'Sorsfonalak – Páros', 6000, 6000, 0)",
|
||||||
)
|
)
|
||||||
.bind(id)
|
.bind(id)
|
||||||
.bind(&checkout)
|
.bind(&checkout)
|
||||||
@@ -447,7 +451,7 @@ mod tests {
|
|||||||
assert_eq!(doc["items"][0]["unit_price"], 6000);
|
assert_eq!(doc["items"][0]["unit_price"], 6000);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
(&doc["items"][0]["unit_price_type"], &doc["items"][0]["vat"]),
|
(&doc["items"][0]["unit_price_type"], &doc["items"][0]["vat"]),
|
||||||
(&json!("gross"), &json!("27%"))
|
(&json!("gross"), &json!("AAM"))
|
||||||
);
|
);
|
||||||
// Paid at 00:30 in Budapest.
|
// Paid at 00:30 in Budapest.
|
||||||
assert_eq!(doc["fulfillment_date"], "2026-11-21");
|
assert_eq!(doc["fulfillment_date"], "2026-11-21");
|
||||||
@@ -466,7 +470,7 @@ mod tests {
|
|||||||
.fetch_one(&db)
|
.fetch_one(&db)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!((net, vat, &kept["invoice_number"]), (4724, 1276, &json!("SF-2026-1")));
|
assert_eq!((net, vat, &kept["invoice_number"]), (6000, 0, &json!("SF-2026-1")));
|
||||||
assert_eq!(run_once(&db, &billingo, 5).await.unwrap(), 0);
|
assert_eq!(run_once(&db, &billingo, 5).await.unwrap(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user