#129 - Partially return void a restaurant order 8.6#642
Merged
StefanKert merged 1 commit intomainfrom Mar 24, 2026
Merged
Conversation
AVPavel
approved these changes
Mar 23, 2026
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.
{Summary of the changes}
Forward recType=7 to myDATA for partial cancellation of restaurant order lines (8.6).
When a restaurant order (type 8.6) contains individual charge items flagged as returned
(ChargeItemCaseFlags.Refund / 0x0002), the middleware now correctly sets recType=7 on
those lines and guarantees all amounts are positive, as required by myDATA.
Previously the recType field was never set, causing myDATA to treat returned
lines as normal order lines.
{Detail}
I added the per-item return detection in AADEFactory.cs -> GetInvoiceDetails(),
where isPartialReturnItem is evaluated as InvoiceType.Item86 && chargeItem.IsRefund().
When true, recType=7 and recTypeSpecified=true are set on the InvoiceRowType,
and Math.Abs() is applied to quantity, vatAmount and netValue to guarantee
positive values regardless of the sign the POS sends
(e.g. VIVA sends negative amounts with the refund flag).
I fixed AADEMappings.cs -> GetIncomeClassificationType() to also apply Math.Abs()
on netAmount for partial return lines in 8.6 orders.
Without this, incomeClassification.amount in the generated XML was negative,
which caused myDATA to reject the payload.
I added the PartiallyCancelInvoiceValidationTests unit test class with three scenarios:
Scenario 1: MapToInvoicesDoc_Order86_SingleReturnedLine_SetsRecType7WithPositiveAmounts
A single returned item with positive payload. The POS sends the item with
ChargeItemCaseFlags.Refund and positive amounts.
Asserts recType=7, positive netValue, vatAmount, quantity,
positive incomeClassification.amount, and correct invoice header.
Scenario 2: MapToInvoicesDoc_Order86_MixedLines_OnlyReturnedLineHasRecType7
A mixed order with one normal line and one returned line.
Asserts that only the flagged line gets recType=7,
the normal line has no recType, and all amounts on the returned
line are positive including incomeClassification.amount.
Scenario 3: MapToInvoicesDoc_Order86_ReturnedLineWithNegativeAmounts_OutputsPositiveAmounts
A returned item where the POS sends negative amounts (e.g. VIVA-style).
Asserts that Math.Abs() normalises all values to positive
as required by myDATA for recType=7 lines.
The existing full-void path (ReceiptCaseFlags.Void -> GetInvoiceDetailsForVoid)
and all tests in CancelInvoiceValidationTests are untouched.
Fixes [#129](Partially return/void a restaturnat order 8.6 · Issue #129 · fiskaltrust/market-gr)