Post monthly interest to savings accounts
Cobol · COBOL · intermediate · modification
Adds the monthly interest posting step to the INTPOST nightly batch, as specified: savings accounts only, rate applied pro-rata per month, one posting record per account. Ran it against the regression account file and the posting totals line up.
This batch runs nightly over roughly 2 million savings accounts, and POST-FILE feeds the general-ledger posting job that follows it.
Requirements
- In the nightly batch, post monthly interest for savings accounts (ACCT-TYPE 'S'); checking accounts are untouched.
- Monthly interest is the account balance times the annual rate, divided by 12.
- This run uses the batch-wide annual savings rate of 4.250%, fixed for the cycle and validated upstream; hard-coding it in working storage is accepted here.
- Round each posted amount half-up to the nearest cent.
- Write one posting record per savings account to POST-FILE.
Files touched
- src/batch/INTPOST.cbl
--- src/batch/INTPOST.cbl
05 WS-READ-COUNT PIC 9(7) VALUE ZERO.
05 WS-POST-COUNT PIC 9(7) VALUE ZERO.
+ 01 WS-RATES.
+ 05 WS-ANNUAL-RATE PIC V9(5) VALUE .04250.
+ 01 WS-MONTHLY-INT PIC S9(9)V99 COMP-3.
PROCEDURE DIVISION.
100-MAIN.
200-PROCESS-ACCOUNT.
ADD 1 TO WS-READ-COUNT.
+ IF ACCT-TYPE = 'S'
+ PERFORM 300-POST-INTEREST
+ END-IF.
+ 300-POST-INTEREST.
+ COMPUTE WS-MONTHLY-INT =
+ ACCT-BALANCE * WS-ANNUAL-RATE / 12
+ MOVE ACCT-ID TO POST-ACCT-ID
+ MOVE WS-MONTHLY-INT TO POST-AMOUNT
+ WRITE POST-REC
+ ADD 1 TO WS-POST-COUNT.