Skip to content

#129 - Partially return void a restaurant order 8.6#642

Merged
StefanKert merged 1 commit intomainfrom
Fix-129--Partially-return/void-a-restaturnat-order-8.6
Mar 24, 2026
Merged

#129 - Partially return void a restaurant order 8.6#642
StefanKert merged 1 commit intomainfrom
Fix-129--Partially-return/void-a-restaturnat-order-8.6

Conversation

@mariananton18
Copy link
Copy Markdown
Contributor

{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)

@mariananton18 mariananton18 requested a review from a team as a code owner March 20, 2026 06:43
@github-actions github-actions Bot added market-gr Related to the greek market area-tests Affects the test labels Mar 20, 2026
@mariananton18 mariananton18 self-assigned this Mar 20, 2026
@mariananton18 mariananton18 changed the title Fix 129 - Partially return void a restaurant order 8.6 #129 - Partially return void a restaurant order 8.6 Mar 20, 2026
@StefanKert StefanKert added scu-gr-mydata Related to the greek MyDATA SCU area-sign Affects the signing endpoint and removed area-tests Affects the test labels Mar 24, 2026
@github-actions github-actions Bot added the area-tests Affects the test label Mar 24, 2026
@StefanKert StefanKert added meta-no-issue This PR does not need to have a linked issue and removed area-tests Affects the test labels Mar 24, 2026
@github-actions github-actions Bot added the area-tests Affects the test label Mar 24, 2026
@StefanKert StefanKert enabled auto-merge March 24, 2026 08:07
@StefanKert StefanKert added the category-enhancement New feature or request label Mar 24, 2026
@StefanKert StefanKert merged commit a3e1d94 into main Mar 24, 2026
14 of 25 checks passed
@StefanKert StefanKert deleted the Fix-129--Partially-return/void-a-restaturnat-order-8.6 branch March 24, 2026 08:11
@github-actions github-actions Bot removed the meta-no-issue This PR does not need to have a linked issue label Mar 24, 2026
@volllly volllly added this to the v1.3.83 milestone Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-sign Affects the signing endpoint area-tests Affects the test category-enhancement New feature or request market-gr Related to the greek market scu-gr-mydata Related to the greek MyDATA SCU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants