Compare PT refund CaseData fields by value and fix mislabeled error#668
Open
StefanKert wants to merge 1 commit into
Open
Compare PT refund CaseData fields by value and fix mislabeled error#668StefanKert wants to merge 1 commit into
StefanKert wants to merge 1 commit into
Conversation
ftReceiptCaseData, ftChargeItemCaseData, and ftPayItemCaseData are typed as System.Object on v2 ReceiptRequest/ChargeItem/PayItem, so the existing != checks did reference equality. After JSON deserialization both sides are distinct JsonElement instances, which made a stored "" never compare equal to an incoming "" and caused full refunds to be rejected. Replace the three reference comparisons with CaseDataEquals, which treats null and empty string as equivalent and otherwise compares via JsonSerializer.Serialize. Also fix the copy-paste label in CompareChargeItems: the ftChargeItemCaseData mismatch was reported as "(Field: cbCustomer)", which made the failure look like a customer-object mismatch. 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: 86f73e81b1
ℹ️ 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".
Queue Test Results 43 files 43 suites 2m 52s ⏱️ Results for commit 86f73e8. |
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
Full refunds in QueuePT were rejected with
Validation error []: EEEE_Full refund does not match the original invoice '<ref>'. ... (Field: cbCustomer)whenever the receipt'sftChargeItemCaseData(orftReceiptCaseData/ftPayItemCaseData) was a non-null value such as""on both sides.Root cause
ftReceiptCaseData,ftChargeItemCaseData, andftPayItemCaseDataare typed asSystem.Objecton the v2ReceiptRequest,ChargeItem, andPayItem.RefundValidatorcompared them with!=, which onobjectis reference equality. After JSON deserialization both sides are distinctJsonElementinstances, so equal values (e.g.""on the stored original and""on the incoming refund) always compared as different and the refund failed.The check inside
CompareChargeItemsadditionally reported the failure as(Field: cbCustomer)— a copy-paste of the cbCustomer mismatch label one method above — which made the error look like a customer-object problem rather than a CaseData problem.Existing tests didn't catch this because none of them set the
*CaseDatafields, so both sides werenullandnull != nullisfalse.Fix
CaseDataEquals(object?, object?)helper that treatsnulland""as equivalent and otherwise compares viaJsonSerializer.Serialize.CompareReceiptRequest,CompareChargeItems, andComparePayItemswithCaseDataEquals.Mismatch("cbCustomer")label insideCompareChargeItemstoMismatch("ftChargeItemCaseData").Test plan
"ftChargeItemCaseData": ""and the refund payload also sends"". Validation should now pass.fiskaltrust.Middleware.Localization.QueuePT.AcceptanceTest,fiskaltrust.Middleware.Localization.v2.UnitTest).ftChargeItemCaseDataactually differs from the original still fails, and the error message now reads(Field: ftChargeItemCaseData)rather than(Field: cbCustomer).Follow-ups (not in this PR)
JsonSerializer.Serializestring compare withJsonNode.DeepEqualsso structurally-equal but differently-ordered objects also compare equal.object-typed*CaseDatafields exist in QueueES'sRefundValidator— worth a follow-up audit there."" ≡ nullleniency should be policy across the codebase or scoped to refund validation only.🤖 Generated with Claude Code