Ksef bypass#55
Draft
mrdanwa wants to merge 3 commits into
Draft
Conversation
4ff73eb to
4b701c7
Compare
Contributor
Author
|
Check gross-price, settlement-invoice-1, settlement-invoice-1 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a “bypass” conversion mode for KSeF → GOBL parsing, where totals are taken directly from KSeF invoice-level fields instead of relying on Calculate()/rounding adjustments, and updates the golden test fixtures accordingly.
Changes:
- Always tag parsed invoices with
tax.TagBypassand set totals from KSeF invoice-level tax summary fields (P_13_x,P_14_x,P_15). - Set line
Sum/Totaldirectly from KSeF line totals (P_11/P_11A) where present, and stop deriving settlement advances/rounding adjustments. - Update/extend KSeF fixture inputs and expected GOBL outputs; relax round-trip validation for bypass-tagged invoices; remove legacy rounding tests/helpers.
Reviewed changes
Copilot reviewed 12 out of 43 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/data/ksef.gobl/out/settlement-invoice-2.json | Golden output updated to include bypass tag and new totals formatting/values. |
| test/data/ksef.gobl/out/settlement-invoice-1.json | Golden output updated to include bypass tag and revised settlement totals. |
| test/data/ksef.gobl/out/prepayment.json | Golden output updated (due date amount now populated). |
| test/data/ksef.gobl/out/no-unit-price.json | Golden output updated to include bypass tag and numeric formatting changes. |
| test/data/ksef.gobl/out/long-invoice.json | Golden output updated to include bypass tag and revised totals/tax category mapping. |
| test/data/ksef.gobl/out/invoice-with-spaces.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-standard.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-simplified.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-settlement.json | Golden output updated to include bypass tag and changed payable/due fields. |
| test/data/ksef.gobl/out/invoice-self-billed.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-reverse-charge.json | Golden output updated to include bypass tag and numeric formatting changes. |
| test/data/ksef.gobl/out/invoice-prepayment.json | Golden output updated to include bypass tag and changed payable/due fields. |
| test/data/ksef.gobl/out/invoice-payment-card.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-jst-customer.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-group-vat.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-foreign-currency.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/invoice-exempt.json | Golden output updated to include bypass tag and numeric formatting changes. |
| test/data/ksef.gobl/out/gross-price.json | Golden output updated for gross-pricing fixture under bypass totals handling. |
| test/data/ksef.gobl/out/discount-invoice4.json | New golden output fixture for discount scenario (bypass-tagged). |
| test/data/ksef.gobl/out/discount-invoice3.json | New golden output fixture for discount scenario (bypass-tagged). |
| test/data/ksef.gobl/out/discount-invoice2.json | New golden output fixture for discount scenario (bypass-tagged). |
| test/data/ksef.gobl/out/discount-invoice.json | Golden output updated to include bypass tag and revised totals/taxes. |
| test/data/ksef.gobl/out/credit-note-wrong-sign.json | New golden output fixture for credit note sign edge case (bypass-tagged). |
| test/data/ksef.gobl/out/credit-note-standard.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/credit-note-settlement.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/credit-note-prepayment.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/out/credit-note-payed.json | Golden output updated to include bypass tag and revised line/totals values. |
| test/data/ksef.gobl/out/credit-note-no-lines.json | Golden output updated: totals now present (zeroed) instead of null, plus bypass tag. |
| test/data/ksef.gobl/out/credit-note-no-line.json | Golden output updated: totals now present (zeroed) instead of null, plus bypass tag. |
| test/data/ksef.gobl/out/credit-note-before-after.json | Golden output updated to include bypass tag. |
| test/data/ksef.gobl/discount-invoice4.xml | New KSeF XML input fixture for discount scenario. |
| test/data/ksef.gobl/discount-invoice3.xml | New KSeF XML input fixture for discount scenario. |
| test/data/ksef.gobl/discount-invoice2.xml | New KSeF XML input fixture for discount scenario. |
| test/data/ksef.gobl/credit-note-wrong-sign.xml | New KSeF XML input fixture for credit note sign edge case. |
| test/convert_test.go | Round-trip validation relaxed for bypass-tagged invoices. |
| rounding_test.go | Removed legacy rounding adjustment tests. |
| rounding.go | Removed legacy rounding adjustment implementation. |
| payments.go | Removed settlement-advance derivation helper. |
| lines.go | Populate Line.Sum/Line.Total directly from KSeF line totals. |
| ksef.go | Always set totals from KSeF invoice-level fields via parseTotals. |
| invoice_test.go | Updated expectations: bypass is now set broadly; removed settlement-advance derivation tests. |
| invoice.go | Always apply bypass mode in parseLines; implement invoice-level parseTotals and due-date amount fill. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+687
to
693
| // parseTotals builds bill.Totals directly from the invoice-level | ||
| // tax summary fields (P_13_X / P_14_X / P_15). The invoice must have the | ||
| // bypass tag set so that Calculate() does not overwrite these totals. | ||
| // The resulting invoice will not pass GOBL validation (no lines), which | ||
| // is acceptable for this edge case. | ||
| func (inv *Inv) parsePrepaymentTotals(goblInv *bill.Invoice) error { | ||
| func (inv *Inv) parseTotals(goblInv *bill.Invoice) error { | ||
| // Each entry maps a P_13_X / P_14_X pair to a tax category. | ||
| // Well-known percentages are set when the rate is unambiguous; | ||
| // otherwise only the amounts are included. |
Comment on lines
+687
to
693
| // parseTotals builds bill.Totals directly from the invoice-level | ||
| // tax summary fields (P_13_X / P_14_X / P_15). The invoice must have the | ||
| // bypass tag set so that Calculate() does not overwrite these totals. | ||
| // The resulting invoice will not pass GOBL validation (no lines), which | ||
| // is acceptable for this edge case. | ||
| func (inv *Inv) parsePrepaymentTotals(goblInv *bill.Invoice) error { | ||
| func (inv *Inv) parseTotals(goblInv *bill.Invoice) error { | ||
| // Each entry maps a P_13_X / P_14_X pair to a tax category. | ||
| // Well-known percentages are set when the rate is unambiguous; | ||
| // otherwise only the amounts are included. |
Comment on lines
650
to
+660
| }) | ||
| } else { | ||
| line.Quantity = line.Quantity.Invert() | ||
| if line.Sum != nil { | ||
| s := line.Sum.Invert() | ||
| line.Sum = &s | ||
| } | ||
| if line.Total != nil { | ||
| t := line.Total.Invert() | ||
| line.Total = &t | ||
| } |
# Conflicts: # invoice_test.go # rounding_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.