Migrate CBACT04C (interest calculation) and CBTRN03C (transaction report) to Java - #189
Open
devanshi-gpta wants to merge 1 commit into
Conversation
… to Java Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Migrates the two batch programs
CBACT04C(INTCALC.jcl) andCBTRN03C(TRANREPT.jcl) intocom.carddemo.batch.interestandcom.carddemo.batch.report, with the business math isolated in@Serviceclasses and Spring Batch jobs as thin wrappers. Only new files under those two packages, plus an appended row-pair in the README mapping table.Arithmetic notes worth checking against the COBOL:
COMPUTE WS-MONTHLY-INT = (TRAN-CAT-BAL * DIS-INT-RATE) / 1200carries no ROUNDED phrase, soInterestCalculationService.monthlyInteresttruncates intoS9(09)V99rather than half-up rounding:100.00 @ 1.50% -> 0.125 -> 0.12(and-0.12for the negative balance, truncation towards zero).CobolUtils.rounded/HALF_UP is therefore deliberately not used here; it would produce0.13.1300-B-WRITE-TXare preserved verbatim:TRAN-ID = PARM-DATE(10) || 9(06) counter("2022071800000001"), type01, category0005, sourceSystem,TRAN-DESC = "Int. for a/c " || ACCT-ID zero-padded to 11, merchant fields zeroed/blanked, card number from the CARDXREF alternate-index read, and both timestamps set to theEEEE-MM-DD-UU.MM.SS.HH0000DB2 string ofZ-GET-DB2-FORMAT-TIMESTAMP.DEFAULT(VSAM status 23 path); a miss on the retry throws, mirroring the abend in1200-A-GET-DEFAULT-INT-RATE.TransactionReportFormatter.editedAmount, including comma suppression inside the suppressed region and the all-blank field for a zero value:PIC -ZZZ,ZZZ,ZZZ.ZZof1234.56is" 1,234.56", of0.56is" .56", of0is 15 blanks. Every line is padded to the 133 bytes ofFD-REPTFILE-REC.Two quirks of the originals are reproduced on purpose (documented in Javadoc, README and asserted by tests) rather than silently "fixed":
CBACT04Cnever posts the accumulated interest of the last account in TCATBALF.1050-UPDATE-ACCOUNTonly runs on an account change, and theELSEbranch of the mainPERFORM UNTILthat would flush the final account is unreachable because the loop test ends the loop first. The interest transactions of that account are still written.CBTRN03Cadds the amount of the last transaction a second time at end of file (READ INTOleavesTRAN-RECORDuntouched), writes page + grand totals but no closing account total, andNEXT SENTENCEon an out-of-rangeTRAN-PROC-TStransfers control past the period that closes the wholePERFORM UNTIL— i.e. the first out-of-range record ends the report. Since the surrounding JCL pre-filters the extract with aSORT INCLUDE CONDon the same dates, the alternative "skip the record" reading is available asgenerate(txns, range, /* stopOnOutOfRange */ false); the default is the COBOL-exact behavior.Tests (
mvn -B clean verifygreen, 39 tests) assert concrete numbers: per-category interest amounts, the resulting account balance (500.00 + 10.00 + 3.86 = 513.86with both cycle buckets zeroed), theDEFAULT-group fallback, the zero-rate skip, the last-account non-update, page break after 16 detail lines (the four heading lines are counted intoWS-LINE-COUNTER), account subtotals on card change, and the page/grand totals including the EOF double count.Link to Devin session: https://app.devin.ai/sessions/7e9f2314ced941a5a0f00bdf4b49cb50
Requested by: @devanshi-gpta
Devin Review