Skip to content

fix(aml): set priceDefinitionAllowedDate on manual amlCheck pass#3845

Merged
TaprootFreak merged 2 commits into
developfrom
fix/aml-set-price-definition-date-on-manual-pass
Jun 9, 2026
Merged

fix(aml): set priceDefinitionAllowedDate on manual amlCheck pass#3845
TaprootFreak merged 2 commits into
developfrom
fix/aml-set-price-definition-date-on-manual-pass

Conversation

@TaprootFreak

Copy link
Copy Markdown
Collaborator

Problem

When amlCheck is set to Pass through the generic update endpoints used by the compliance tool (PUT /buyCrypto/:id, PUT /buyFiat/:id), priceDefinitionAllowedDate was only persisted when it was explicitly present in the request payload.

The automatic AML pass (AmlHelperService.getAmlResult) and the dedicated manualPassAmlCheck both set priceDefinitionAllowedDate together with the Pass transition. The generic update() path did not, so a manual pass without that field left the transaction with amlCheck = Pass but priceDefinitionAllowedDate = null, stuck in status Created (price definition never allowed → no further processing).

Fix

Couple priceDefinitionAllowedDate to the Pass transition inside the forceUpdate block of both BuyCryptoService.update and BuyFiatService.update, mirroring the automatic pass:

...(update.amlCheck === CheckStatus.PASS && {
  priceDefinitionAllowedDate:
    update.priceDefinitionAllowedDate ?? entity.priceDefinitionAllowedDate ?? new Date(),
}),

An explicit payload value still takes precedence; an already-set date is preserved; otherwise it defaults to now. Logic stays server-side, independent of the frontend.

Scope

  • BuyCryptoService.update
  • BuyFiatService.update (same tool path, same bug — fixed for parity)
  • No entity/column change → no migration.

Test plan

  • type-check, lint, format clean
  • existing AML / buy-crypto / buy-fiat suites green (59 tests)
  • manual: set amlCheck = Pass via compliance tool without the date checkbox → priceDefinitionAllowedDate now populated, transaction proceeds

Follow-ups (separate PRs)

  1. amlResponsible semantics: use a clear marker (e.g. automatic) for API-driven passes and the processing person's userData.verifiedName for compliance-tool passes, instead of the current API / null.
  2. Data backfill: existing transactions already passed without priceDefinitionAllowedDate need a one-off correction.
  3. Optional regression test for the update() Pass → priceDefinitionAllowedDate invariant.

…ssed

When compliance staff set amlCheck to Pass via the generic update endpoint
(PUT /buyCrypto/:id, PUT /buyFiat/:id), priceDefinitionAllowedDate was only
persisted if it was explicitly included in the payload. Unlike the automatic
AML pass (AmlHelperService) and manualPassAmlCheck, the update path did not
couple the date to the Pass transition, leaving transactions stuck in status
Created with amlCheck=Pass and a null priceDefinitionAllowedDate.

Couple priceDefinitionAllowedDate to the Pass transition in both
BuyCryptoService.update and BuyFiatService.update, mirroring the automatic
pass behaviour. An explicit payload value still takes precedence.
@TaprootFreak TaprootFreak marked this pull request as ready for review June 9, 2026 09:12
@TaprootFreak TaprootFreak requested a review from davidleomay as a code owner June 9, 2026 09:12
@TaprootFreak TaprootFreak enabled auto-merge (squash) June 9, 2026 09:13
@TaprootFreak TaprootFreak merged commit a21cf22 into develop Jun 9, 2026
7 checks passed
@TaprootFreak TaprootFreak deleted the fix/aml-set-price-definition-date-on-manual-pass branch June 9, 2026 10:39
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.

2 participants