feat(event): add invoice.issued and invoice.paid event contracts
This commit is contained in:
1 parent
d6af4dbc0b
commit
4bf00314d3
3 files changed
+91
No files matched your search
@@ -28,3 +28,49 @@ func TestCreatedRoundTrip(t *testing.T) {
|
||||
t.Errorf("line[0] mismatch: %+v", out.Lines[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvoiceIssuedRoundTrip(t *testing.T) {
|
||||
in := InvoiceIssued{
|
||||
OrderID: "ord-1",
|
||||
InvoiceNumber: "INV-000001",
|
||||
CompanyID: "comp-1",
|
||||
CustomerEmail: "a@b.c",
|
||||
AmountIncVat: 14995,
|
||||
DueDate: "2026-09-15",
|
||||
OCRReference: "00000139",
|
||||
IssuedAtMs: 1234567890,
|
||||
}
|
||||
raw, err := in.Encode()
|
||||
if err != nil {
|
||||
t.Fatalf("encode: %v", err)
|
||||
}
|
||||
out, err := DecodeInvoiceIssued(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if out.InvoiceNumber != in.InvoiceNumber || out.OCRReference != in.OCRReference || out.AmountIncVat != in.AmountIncVat {
|
||||
t.Fatalf("round-trip mismatch: got %+v, want %+v", out, in)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvoicePaidRoundTrip(t *testing.T) {
|
||||
in := InvoicePaid{
|
||||
OrderID: "ord-1",
|
||||
InvoiceNumber: "INV-000001",
|
||||
CompanyID: "comp-1",
|
||||
AmountPaid: 14995,
|
||||
PaidAtMs: 1234567990,
|
||||
}
|
||||
raw, err := in.Encode()
|
||||
if err != nil {
|
||||
t.Fatalf("encode: %v", err)
|
||||
}
|
||||
out, err := DecodeInvoicePaid(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if out.InvoiceNumber != in.InvoiceNumber || out.AmountPaid != in.AmountPaid {
|
||||
t.Fatalf("round-trip mismatch: got %+v, want %+v", out, in)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user