Skip to content

migrate(DBCRFUN): translate payment debit/credit flow#24

Merged
a2chang merged 3 commits intomainfrom
migrate/DBCRFUN
May 1, 2026
Merged

migrate(DBCRFUN): translate payment debit/credit flow#24
a2chang merged 3 commits intomainfrom
migrate/DBCRFUN

Conversation

@a2chang
Copy link
Copy Markdown
Contributor

@a2chang a2chang commented May 1, 2026

Source program

Mapped REST endpoints

  • POST /api/v1/dbcrfun

Notable decisions

  • Mapped the z/OS Connect PAYDBCR payload to POST /api/v1/dbcrfun, preserving the nested request/response shape and returning RFC-7807 ProblemDetail bodies for failures.
  • Used CrdbRetry.run(...) around a transactional SELECT ... FOR UPDATE account lock so debit/credit updates follow CockroachDB retry requirements while matching the COBOL single-record update flow.
  • Preserved DBCRFUN fail-code behavior with 1 for account not found, 2 for persistence/update failures, 3 for insufficient funds on payment debits, and 4 for payment-disallowed account types.
  • Reused the existing AccountDetails domain model instead of introducing a duplicate account structure, and no Flyway migration was needed because DBCRFUN operates on existing account and proctran tables.
  • Derived proctran audit entries from the amount sign and facility type, using PDR/PCR plus the origin-based payment description for payment traffic and DEB/CRE counter descriptions for non-payment facilities.
  • CommOrigin (and CommFaciltype) are required on the request so clients explicitly opt into payment vs teller semantics rather than silently defaulting to non-payment when omitted.

Test coverage

@a2chang
Copy link
Copy Markdown
Contributor Author

a2chang commented May 1, 2026

augment review

@augmentcode
Copy link
Copy Markdown
Contributor

augmentcode Bot commented May 1, 2026

Test Coverage Guardian 🧪

Test coverage looks good. The new/changed behavior in this PR has adequate test coverage. No additional tests needed.

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

this.dbcrfunService = Objects.requireNonNull(dbcrfunService, "dbcrfunService must not be null");
}

@PutMapping("/dbcr")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/translation-rules.md specifies DBCRFUN should be exposed as a POST under /api/v1/dbcrfun, but this controller is currently a PUT under /api/v1/makepayment. If clients/tests are already aligning to the rulebook, this mismatch could cause route/method breakage.

Severity: medium

🤖 Was this useful? React with 👍 or 👎

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

}

private DbcrfunOrigin toOrigin(DbcrfunOriginDto originDto) {
if (originDto == null) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaulting a missing CommOrigin to DbcrfunOrigin.blank() (facilityType=0) means DbcrfunService will treat the request as non-payment traffic. If this endpoint should always enforce payment rules, a client could bypass the insufficient-funds / account-type restrictions by omitting or changing CommFaciltype.

Severity: medium

🤖 Was this useful? React with 👍 or 👎


@RestController
@Validated
@RequestMapping("/api/v1/makepayment")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/translation-rules.md currently says DBCRFUN maps to POST under /api/v1/<program-lowercase>, but this controller introduces PUT /api/v1/makepayment/dbcr; consider updating the rules doc so future migrations don’t follow the wrong convention.

Severity: low

🤖 Was this useful? React with 👍 or 👎

@a2chang
Copy link
Copy Markdown
Contributor Author

a2chang commented May 1, 2026

augment review

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

assertThat(auditRow.value1()).isEqualTo("PDR");
assertThat(auditRow.value2()).isEqualTo("ABCDEFGH123456");
assertThat(auditRow.value3()).isEqualTo(new BigDecimal("-25.00"));
assertThat(auditRow.value4()).isEqualTo(LocalDate.now(clock));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion reads LocalDate.now(clock) after the request, but the service persists TRAN_DATE based on a captured Instant; this can become flaky if the test runs across midnight (UTC).

Severity: low

🤖 Was this useful? React with 👍 or 👎


@RestController
@Validated
@RequestMapping("/api/v1/dbcrfun")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description lists the mapped endpoint as PUT /api/v1/makepayment/dbcr, but the implementation here is POST /api/v1/dbcrfun; this mismatch could confuse clients/reviewers relying on the PR notes.

Severity: low

🤖 Was this useful? React with 👍 or 👎

@a2chang
Copy link
Copy Markdown
Contributor Author

a2chang commented May 1, 2026

augment review

Copy link
Copy Markdown

@augment-app-staging augment-app-staging Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@a2chang a2chang merged commit 5be2cb2 into main May 1, 2026
1 check passed
@a2chang a2chang deleted the migrate/DBCRFUN branch May 1, 2026 11:40
@a2chang a2chang mentioned this pull request May 1, 2026
22 tasks
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.

1 participant