[repo] Merge: feature/invoice-language (Czech or English per invoice, PR #6)
This commit was merged in pull request #6.
This commit is contained in:
Generated
+4
-4
@@ -139,7 +139,7 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fiscus-capture"
|
name = "fiscus-capture"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fiscus-ledger",
|
"fiscus-ledger",
|
||||||
"proptest",
|
"proptest",
|
||||||
@@ -150,7 +150,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fiscus-insight"
|
name = "fiscus-insight"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fiscus-ledger",
|
"fiscus-ledger",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -159,7 +159,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fiscus-ledger"
|
name = "fiscus-ledger"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proptest",
|
"proptest",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -169,7 +169,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fiscus-statement"
|
name = "fiscus-statement"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"fiscus-ledger",
|
"fiscus-ledger",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ resolver = "2"
|
|||||||
members = ["crates/fiscus-ledger", "crates/fiscus-statement", "crates/fiscus-insight", "crates/fiscus-capture"]
|
members = ["crates/fiscus-ledger", "crates/fiscus-statement", "crates/fiscus-insight", "crates/fiscus-capture"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
repository = "https://gitea.marek-novak.cz/mnovak/FiscusPublic"
|
repository = "https://gitea.marek-novak.cz/mnovak/FiscusPublic"
|
||||||
|
|||||||
@@ -98,6 +98,15 @@ pub struct InvoiceLine {
|
|||||||
pub vat: Option<u8>,
|
pub vat: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The language an invoice is printed in, chosen per invoice.
|
||||||
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum Language {
|
||||||
|
#[default]
|
||||||
|
Cs,
|
||||||
|
En,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Invoice {
|
pub struct Invoice {
|
||||||
pub id: InvoiceId,
|
pub id: InvoiceId,
|
||||||
@@ -111,6 +120,9 @@ pub struct Invoice {
|
|||||||
pub lines: Vec<InvoiceLine>,
|
pub lines: Vec<InvoiceLine>,
|
||||||
/// The budget the payment goes into when it arrives; `None`: the default budget.
|
/// The budget the payment goes into when it arrives; `None`: the default budget.
|
||||||
pub budget: Option<String>,
|
pub budget: Option<String>,
|
||||||
|
/// What the printed invoice is in. Absent in an event: Czech.
|
||||||
|
#[serde(default)]
|
||||||
|
pub language: Language,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What an invoice adds up to.
|
/// What an invoice adds up to.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//! inconsistent refused.
|
//! inconsistent refused.
|
||||||
|
|
||||||
use fiscus_ledger::import::StatementLine;
|
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};
|
use fiscus_ledger::{Date, Event, EventBody, Haler, State, Timestamp};
|
||||||
|
|
||||||
fn d(s: &str) -> Date {
|
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."),
|
customer: party("Odběratel s.r.o."),
|
||||||
lines,
|
lines,
|
||||||
budget: None,
|
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.
|
// Replaying the log twice gives the same state.
|
||||||
assert_eq!(State::replay(&events), State::replay(&back));
|
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());
|
||||||
|
}
|
||||||
|
|||||||
+2
-1
@@ -15,7 +15,8 @@ IČO: 8 digits, the last the weighted mod-11 check of the first seven. DIČ: `CZ
|
|||||||
|
|
||||||
## An invoice
|
## An invoice
|
||||||
`invoice.issued` carries the whole invoice: id, number, issue and due dates, the taxable-supply date (DUZP, on a
|
`invoice.issued` carries the whole invoice: id, number, issue and due dates, the taxable-supply date (DUZP, on a
|
||||||
VAT invoice only), the customer, 1–50 lines, and the budget its payment goes into (`None`: the default one).
|
VAT invoice only), the customer, 1–50 lines, the budget its payment goes into (`None`: the default one), and
|
||||||
|
the language it is printed in: `cs` or `en`, chosen per invoice (absent: Czech).
|
||||||
|
|
||||||
- **Number = variable symbol.** `YYYYNNNN`: the year it was issued and its place in that year
|
- **Number = variable symbol.** `YYYYNNNN`: the year it was issued and its place in that year
|
||||||
(`State::next_invoice_number(year)`). A number is used once. The payment is matched by it.
|
(`State::next_invoice_number(year)`). A number is used once. The payment is matched by it.
|
||||||
|
|||||||
Reference in New Issue
Block a user