Map MyData receipt-level Void on non-8.6 cases to refund flow#671
Map MyData receipt-level Void on non-8.6 cases to refund flow#671StefanKert wants to merge 1 commit into
Conversation
AADE's CancelInvoice endpoint is reserved for direct ERP/AADE users and is not callable through the e-Invoice Provider channel (market-gr#133). The provider-legal equivalent of a cancellation is a credit-note / refund-slip document, which the SCU already produces for Refund. Introduce a single IsEffectiveRefund() helper that returns true when either Refund is set, or Void is set on a non-Order0x3004 case. Route the four type-resolution call sites in AADEMappings (Item84/Item85, Item111/Item114, Item11/Item51/52, line net amount) and the four shape/amount call sites in AADEFactory (correlatedInvoices vs multipleConnectedMarks placement, line and payment amount negation, 9.3 reverseDeliveryNote) through the helper. The two "Voiding not supported" throws stay as defense-in-depth — only reachable if someone overrides Void+Order0x3004 to a non-8.6 invoice type. The 8.6 totalCancelDeliveryOrders cancellation (#116) and the dedicated 9.3 CancelDeliveryNote endpoint (#119) paths are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a94b5c94d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| || (receiptRequest.ftReceiptCase.IsFlag(ReceiptCaseFlags.Void) | ||
| && !receiptRequest.ftReceiptCase.IsCase(ReceiptCase.Order0x3004)); |
There was a problem hiding this comment.
Base effective-refund on resolved type, not only receipt case
IsEffectiveRefund() treats every Void that is not Order0x3004 as refund-shaped before overrides are applied. In CreateInvoiceDocType, 8.6-specific void handling (SetInvoiceHeaderFieldsForVoid) runs before ApplyMyDataOverride, so a Void receipt/invoice with mydataoverride.invoiceHeader.invoiceType = "8.6" now bypasses the old guard, gets refund-negated rows, and can end up as final type 8.6 without the required 8.6 cancellation header/validation path. This is a new inconsistent-output path introduced by the helper condition.
Useful? React with 👍 / 👎.
Summary
myDATA's
CancelInvoiceendpoint is reserved for direct ERP/AADE users and is not callable through the e-Invoice Provider channel (see market-gr#133). The provider-legal equivalent of a cancellation is a credit-note / refund-slip document, which the SCU already produces forReceiptCaseFlags.Refund.Until now, receipt-level
Voidon anything other thanOrder0x3004(the 8.6 path) threw "Voiding of documents is not supported for this invoice type. Please use refund." This PR removes that wall:Voidon non-8.6 cases now routes through the existing refund flow.VoidmultipleConnectedMarks)Void+ prior MARKcorrelatedInvoices)Voidwithout prior MARKVoidIn all four cases line amounts, VAT and payment amounts are negated, matching what
Refundalready produces.What stays unchanged
Order0x3004+Void→ 8.6 keeps the dedicatedtotalCancelDeliveryOrders+multipleConnectedMarkscancellation path (market-gr#116).DeliveryNote0x0005+Void+HasTransportInformation→ 9.3 keeps the dedicated/myDataProvider/CancelDeliveryNoteendpoint (market-gr#119).CancelInvoicedirectly — market-gr#133 stands.Design
A single
IsEffectiveRefund()extension onReceiptRequestreturns true when eitherRefundis set, orVoidis set on a non-Order0x3004case. Eight call sites swap fromIsFlag(ReceiptCaseFlags.Refund)to this helper:AADEMappings: type resolution for receipt → 11.4, invoice → 5.1/5.2, payment-transfer → 8.5, and theIncomeClassificationTypenet-amount sign.AADEFactory: correlatedInvoices vs multipleConnectedMarks placement, line and payment amount negation, and 9.3reverseDeliveryNote.The two "Voiding not supported" throws stay as defense-in-depth — only reachable if someone overrides
Void+Order0x3004to a non-8.6 invoice type via mydataoverride.Tests
VoidAsRefundTests.cs(8 tests): type resolution for each invoice family, the 8.6 regression guard, amount negation + mark placement, and the helper semantics.CancelInvoiceValidationTests.csTest 11: previously asserted the throw; now asserts anItem114document with negated amounts andmultipleConnectedMarkspopulated.CancelInvoiceValidationTests(8.6 path) andPartiallyCancelInvoiceValidationTests(per-itemrecType=7) suites continue to pass.819/819 unit tests green; build clean.
Related
Test plan
dotnet test scu-gr/test/fiskaltrust.Middleware.SCU.GR.MyData.UnitTest/— 819/819 passSignRequestReceipt_VoidReceipt_1(Receipt + Void) → 11.4 retail refund slip with negative amounts andmultipleConnectedMarkspopulatedSignRequestReceipt_VoidReceipt_2→ matching refund-shaped documenttotalCancelDeliveryOrders=truevia SendInvoices/myDataProvider/CancelDeliveryNote🤖 Generated with Claude Code