Skip to content

Compare money and decimal values by value when matching - #31

Merged
imranakram merged 3 commits into
masterfrom
fix/compare-decimals-by-value
Oct 9, 2026
Merged

imranakram merged 3 commits into
masterfrom
fix/compare-decimals-by-value

Conversation

@imranakram

Copy link
Copy Markdown
Collaborator

Money and decimal values with a different number of decimals never matched, so records with an amount were updated on every import, and a Match on an amount created the record again on every run.

The cause

A .NET decimal keeps its scale: 4999.0000 and 4999.00 are equal but print differently. A data file holds the source environment's scale, and the target returns its own, which for money follows that environment's precision settings. TargetAttributeValue compared ToString() of both.

The fix

TargetAttributeValue now compares decimals by value (ComparableDecimal), the same way it compares dates since #26. Money arrives there as its decimal value. The identical check and the PreRetrieveAll match keys share the comparison, so they still agree.

Tests

  • Identical check: an unchanged money value is skipped whatever its decimals: 4999.0000 against 4999, 0.0000 against 0, -12.5000 against -12.5. The same goes for a decimal column (1.2500000000 against 1.25).
  • Real changes: a money value that really changed is still updated.
  • Matching: a Match on a money column finds the existing record instead of creating a duplicate.

Without the fix, 5 of the 6 fail; the match test creates a second record. All 278 tests pass in Debug and Release.

Also checked against a real environment: importing a block matched on two money columns twice used to create every record again. With the fix, the second run skips them all.

Fixes #30

A decimal keeps its scale, so 4999.0000 and 4999.00 are equal but print
differently. A data file holds the source environment's scale, and the
target returns its own, which for money follows that environment's
precision settings. The match comparison used ToString(), so:

- a record with a money or decimal column was never identical, and was
  updated on every import;
- a Match on such a column found nothing, and the record was created a
  second time.

TargetAttributeValue now compares decimals by value, the same way it
compares dates since the previous fix. The identical check and the
PreRetrieveAll match keys share it.
…s-by-value

# Conflicts:
#	README.md
#	XTB/ShuffleDeployer.nuspec
#	XTB/ShuffleRunner.nuspec
…s-by-value

# Conflicts:
#	XTB/ShuffleDeployer.nuspec
#	XTB/ShuffleRunner.nuspec
@imranakram
imranakram merged commit 916beb4 into master Oct 9, 2026
1 check passed
@imranakram
imranakram deleted the fix/compare-decimals-by-value branch October 9, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Money and decimal values with a different number of decimals never match

1 participant