Skip to content

feat: add PaymentInfo support for Platnosc element#40

Merged
samupl merged 2 commits intomasterfrom
feat/payment-info
Apr 8, 2026
Merged

feat: add PaymentInfo support for Platnosc element#40
samupl merged 2 commits intomasterfrom
feat/payment-info

Conversation

@samupl
Copy link
Copy Markdown
Owner

@samupl samupl commented Apr 8, 2026

Summary

Adds support for the <Platnosc> element (payment details) in the Fa section of the FA(3) schema.

What's new

  • PaymentInfo model with:
    • is_paid: bool — emits <Zaplacono>1</Zaplacono> flag when True
    • payment_date<DataZaplaty>
    • due_date + due_description<TerminPlatnosci> / <Termin> / <TerminOpis>
    • method<FormaPlatnosci> (use PAYMENT_METHOD_* constants)
    • bank_account_number<RachunekBankowy> / <NrRB>
  • Payment method constants matching TFormaPlatnosci enum:
    • PAYMENT_METHOD_CASH (1), CARD (2), VOUCHER (3), CHECK (4), CREDIT (5), BANK_TRANSFER (6), MOBILE (7)
  • Optional payment_info field on InvoiceData
  • XML serializer _build_payment_info() emitting elements in schema order: ZaplaconoDataZaplatyTerminPlatnosciFormaPlatnosciRachunekBankowy

Note on Zaplacono

Initial attempt treated Zaplacono as a decimal amount, which KSeF rejected:

The value '100.00' is invalid according to its datatype 'TWybor1' - The string '100.00' is not a valid SByte value.

TWybor1 is a flag type accepting only value 1. The actual paid amount is implied from P_15 when the flag is set.

Test plan

  • Existing 36 library tests pass
  • Verified against KSeF test environment with 9 invoice variations (paid/unpaid, various methods)

samupl added 2 commits April 8, 2026 14:47
- Add PaymentInfo model with is_paid flag, payment/due dates,
  due description, payment method, and bank account number
- Add PAYMENT_METHOD_* constants matching TFormaPlatnosci enum
  (cash, card, voucher, check, credit, bank_transfer, mobile)
- Add optional payment_info field on InvoiceData
- Serialize Platnosc element in correct schema order:
  Zaplacono -> DataZaplaty -> TerminPlatnosci -> FormaPlatnosci
  -> RachunekBankowy
- Note: Zaplacono is a TWybor1 flag (value '1' = fully paid),
  not an amount field
Tests cover:
- payment_info=None omits <Platnosc> entirely
- Bank transfer with due date + account number
- Paid-in-full with Zaplacono flag and DataZaplaty
- Due description (TerminOpis)
- is_paid=False omits Zaplacono element
@samupl samupl merged commit 93a1776 into master Apr 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant