[ledger] Invoices: the print language, Czech or English per invoice (Czech when absent); v0.4.1
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//! inconsistent refused.
|
||||
|
||||
use fiscus_ledger::import::StatementLine;
|
||||
use fiscus_ledger::invoice::{dic_ok, ico_ok, invoice_number, line_amount, plan_invoice_payments, same_vs, totals, Invoice, InvoiceError, InvoiceLine, Party, Supplier};
|
||||
use fiscus_ledger::invoice::{dic_ok, ico_ok, invoice_number, line_amount, plan_invoice_payments, same_vs, totals, Invoice, InvoiceError, InvoiceLine, Language, Party, Supplier};
|
||||
use fiscus_ledger::{Date, Event, EventBody, Haler, State, Timestamp};
|
||||
|
||||
fn d(s: &str) -> Date {
|
||||
@@ -47,6 +47,7 @@ fn invoice(id: &str, number: &str, issued: &str, lines: Vec<InvoiceLine>, vat: b
|
||||
customer: party("Odběratel s.r.o."),
|
||||
lines,
|
||||
budget: None,
|
||||
language: Language::Cs,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,3 +348,18 @@ fn the_events_round_trip_and_keep_their_names() {
|
||||
// Replaying the log twice gives the same state.
|
||||
assert_eq!(State::replay(&events), State::replay(&back));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_invoice_is_printed_in_czech_or_english_and_czech_when_unsaid() {
|
||||
let mut i = invoice("i1", "20260001", "2026-03-01", vec![line("Work", 1_000, 100_000, None)], false);
|
||||
i.language = Language::En;
|
||||
let json = serde_json::to_string(&i).unwrap();
|
||||
assert!(json.contains("\"language\":\"en\""), "{json}");
|
||||
assert_eq!(serde_json::from_str::<Invoice>(&json).unwrap(), i);
|
||||
// An event written without the field reads as Czech.
|
||||
let older = json.replace(",\"language\":\"en\"", "");
|
||||
assert!(!older.contains("language"));
|
||||
assert_eq!(serde_json::from_str::<Invoice>(&older).unwrap().language, Language::Cs);
|
||||
// Anything else is refused.
|
||||
assert!(serde_json::from_str::<Invoice>(&json.replace("\"en\"", "\"de\"")).is_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user