-
Notifications
You must be signed in to change notification settings - Fork 5
Fix empty fields in payment output #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,28 +131,32 @@ func (ui *Invoice) addPaymentInstructions(instr *pay.Instructions) error { | |||||||||
| ui.PaymentMeans[0].PayeeFinancialAccount = newCreditTransferAccount(instr.CreditTransfer[0]) | ||||||||||
| } | ||||||||||
| if instr.DirectDebit != nil { | ||||||||||
| ui.PaymentMeans[0].PaymentMandate = &PaymentMandate{ | ||||||||||
| ID: IDType{Value: instr.DirectDebit.Ref}, | ||||||||||
| mandate := &PaymentMandate{} | ||||||||||
| if instr.DirectDebit.Ref != "" { | ||||||||||
| mandate.ID = IDType{Value: instr.DirectDebit.Ref} | ||||||||||
| } | ||||||||||
| if instr.DirectDebit.Account != "" { | ||||||||||
| ui.PaymentMeans[0].PayerFinancialAccount = &FinancialAccount{ | ||||||||||
| mandate.PayerFinancialAccount = &FinancialAccount{ | ||||||||||
| ID: &instr.DirectDebit.Account, | ||||||||||
| } | ||||||||||
| } | ||||||||||
| ui.PaymentMeans[0].PaymentMandate = mandate | ||||||||||
| } | ||||||||||
|
Comment on lines
133
to
144
|
||||||||||
| if instr.Card != nil { | ||||||||||
| ui.PaymentMeans[0].CardAccount = &CardAccount{ | ||||||||||
| PrimaryAccountNumberID: &instr.Card.Last4, | ||||||||||
| card := &CardAccount{} | ||||||||||
| if instr.Card.Last4 != "" { | ||||||||||
| card.PrimaryAccountNumberID = &instr.Card.Last4 | ||||||||||
| } | ||||||||||
| if instr.Card.Holder != "" { | ||||||||||
| ui.PaymentMeans[0].CardAccount.HolderName = &instr.Card.Holder | ||||||||||
| card.HolderName = &instr.Card.Holder | ||||||||||
| } | ||||||||||
| ui.PaymentMeans[0].CardAccount = card | ||||||||||
|
||||||||||
| ui.PaymentMeans[0].CardAccount = card | |
| if card.PrimaryAccountNumberID != nil || card.HolderName != nil { | |
| ui.PaymentMeans[0].CardAccount = card | |
| } |
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds new behavior where newCreditTransferAccount returns nil when no fields are set. There are existing payment conversion tests, but none assert the nil/omission behavior for an empty credit transfer; adding a unit test/fixture covering an empty pay.CreditTransfer would help prevent regressions in the generated XML.
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PaymentTerms are now appended only when pymt.Terms.Notes is non-empty. Since this changes output behavior (previously an empty <cbc:Note/> could be emitted), it would be good to add a conversion test that covers the case where due dates are absent and Terms.Notes is empty to ensure ui.PaymentTerms stays empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PaymentMandate.IDis a non-pointerIDType, so it will still be marshaled as<cbc:ID>with an empty value even wheninstr.DirectDebit.Ref == "". The conditional assignment here doesn’t actually prevent an empty ID from appearing in the XML; consider makingPaymentMandate.IDa*IDType(or implementing custom marshaling) so it can be omitted when unset, and update the parsing side accordingly.