S++Core systems, human-reviewable
DEMO SOURCE · SPP / APP / PHYRead the book

bankdeposit-80-bank-qualification.spp

bankdeposit/admission/bankdeposit-80-bank-qualification.spp

Download original file · Bank deposit source contents

1domain bankdeposit;23// the legacy query module: decoded account and operator facts, with business selection in SPP.45Role DepositBankProfile {6    boolean normalSavings;7    boolean restrictedSubtype;8    String openingBranch;9    String openingProvince;10    String subbranch;11    String area;12    String areaProvince;13    String depositRange;14    String proprietaryRange;15    boolean cardLinked;16    String accountSeries;17    boolean cardRecordFound;18    String cardLoss;19    String cardStatus;20    String passbookLoss;21    boolean groupSubaccount;22}2324Role DepositOperatorFacts {25    String branch;26    String province;27    String subbranch;28    String area;29    String areaProvince;30    boolean accountingCentre;31    String transactionPrefix;32    String operationCode;33    String tellerFamily;34    int tellerNumber;35    boolean numericTeller;36    String mode;37    boolean agencySigned;38    boolean corporateTransfer;39    String settlementChannel;40}4142Role DepositNotices {43    String cardWarning;44    String passbookWarning;45}4647atomic calculate assessDepositDocumentNotices(48    DepositBankProfile,49    DepositOperatorFacts,50    CashChannel,51    DepositNotices52) {53    depositNotices.cardWarning = BLANK;54    depositNotices.passbookWarning = BLANK;55    boolean applies = !depositOperatorFacts.agencySigned56        && depositOperatorFacts.numericTeller57        && (depositOperatorFacts.mode == "Online"58        || depositOperatorFacts.mode == "Mode8");59    if (applies) {60        if (depositBankProfile.accountSeries == "49927"61            && depositBankProfile.cardLinked62            && depositBankProfile.cardRecordFound63            && cashChannel.businessCode != "CR0"64            && (depositBankProfile.cardLoss == "Oral"65            || depositBankProfile.cardLoss == "Written")66            && depositBankProfile.cardStatus != "Cancelled") {67            depositNotices.cardWarning = "WN200";68        }69        if (depositBankProfile.passbookLoss == "Oral" || depositBankProfile.passbookLoss == "Written") {70            depositNotices.passbookWarning = "WN201";71        }72    }73}7475atomic check checkDepositBranchRange(DepositBankProfile, DepositOperatorFacts, CashChannel) {76    boolean specificPermission = depositOperatorFacts.transactionPrefix == "FL06002"77        || depositOperatorFacts.transactionPrefix == "AG02891"78        || depositOperatorFacts.transactionPrefix == "SA01120"79        || depositOperatorFacts.transactionPrefix == "FL06615"80        || depositOperatorFacts.transactionPrefix == "FL06618";81    boolean commonException = depositOperatorFacts.transactionPrefix == "RE04081"82        || depositOperatorFacts.transactionPrefix == "RE04082"83        || depositOperatorFacts.transactionPrefix == "RE04001"84        || depositOperatorFacts.transactionPrefix == "RE04013"85        || depositOperatorFacts.transactionPrefix == "RE04047"86        || depositOperatorFacts.transactionPrefix == "RE04057"87        || depositOperatorFacts.transactionPrefix == "CR05220";88    boolean agencyException = cashChannel.businessCode == "AG0"89        && (depositOperatorFacts.operationCode == "1732"90        || depositOperatorFacts.operationCode == "1762"91        || depositOperatorFacts.operationCode == "1725");92    boolean outerException = depositOperatorFacts.transactionPrefix == "RE04001"93        || depositOperatorFacts.transactionPrefix == "RE04013"94        || depositOperatorFacts.transactionPrefix == "RE04047"95        || depositOperatorFacts.transactionPrefix == "RE04057"96        || depositOperatorFacts.transactionPrefix == "RE04067"97        || depositOperatorFacts.transactionPrefix == "AG01765"98        || depositOperatorFacts.transactionPrefix == "AG02899"99        || depositOperatorFacts.transactionPrefix == "RE04066";100    boolean specialTeller = depositOperatorFacts.tellerFamily == "UH"101        && depositOperatorFacts.tellerNumber >= 0102        && depositOperatorFacts.tellerNumber <= 9;103    if ((depositOperatorFacts.operationCode == "1751"104        || depositOperatorFacts.operationCode == "1176"105        || depositOperatorFacts.operationCode == "1172")106        && depositOperatorFacts.tellerFamily == "O"107        && depositOperatorFacts.tellerNumber >= 56108        && depositOperatorFacts.tellerNumber <= 99) {109        specialTeller = true;110    }111    if (depositOperatorFacts.operationCode == "1751"112        && depositOperatorFacts.tellerFamily == "ZD"113        && depositOperatorFacts.tellerNumber >= 0114        && depositOperatorFacts.tellerNumber <= 9) {115        specialTeller = true;116    }117    boolean applies = !depositBankProfile.cardLinked118        && cashChannel.businessCode != "FL0"119        && cashChannel.businessCode != "RE0"120        && cashChannel.businessCode != "AG0"121        && (!depositOperatorFacts.accountingCentre122        || depositBankProfile.openingProvince != depositOperatorFacts.province)123        && !outerException124        && !specificPermission125        && !specialTeller;126    boolean groupException = depositBankProfile.groupSubaccount127        && (depositOperatorFacts.settlementChannel == "HVP"128        || depositOperatorFacts.settlementChannel == "BEP"129        || depositOperatorFacts.settlementChannel == "NXY");130    boolean checksRange = depositOperatorFacts.mode != "CentralBatch"131        && !depositOperatorFacts.corporateTransfer132        && depositOperatorFacts.transactionPrefix != "CR05220"133        && !groupException;134    if (applies) {135        if (depositBankProfile.normalSavings) {136            require(137                depositBankProfile.depositRange == "SameBranch"138                    || depositBankProfile.depositRange == "Subbranch"139                    || depositBankProfile.depositRange == "City"140                    || depositBankProfile.depositRange == "Province"141                    || depositBankProfile.depositRange == "All",142                RejectionCode.INVALID_DEPOSIT_RANGE143            );144            if (checksRange) {145                if (depositBankProfile.depositRange == "SameBranch"146                    && depositBankProfile.openingBranch != depositOperatorFacts.branch147                    && !commonException) {148                    require(false, RejectionCode.EN134);149                }150                if (depositBankProfile.depositRange == "Subbranch") {151                    require(152                        depositBankProfile.subbranch != BLANK && depositOperatorFacts.subbranch != BLANK,153                        RejectionCode.DEPOSIT_SUBBRANCH_RELATION_NOT_FOUND154                    );155                    require(156                        depositBankProfile.subbranch == depositOperatorFacts.subbranch,157                        RejectionCode.EN470158                    );159                }160                if (depositBankProfile.depositRange == "City") {161                    require(162                        depositBankProfile.area != BLANK && depositOperatorFacts.area != BLANK,163                        RejectionCode.DEPOSIT_AREA_NOT_FOUND164                    );165                    require(depositBankProfile.area == depositOperatorFacts.area, RejectionCode.EN470);166                }167                if (depositBankProfile.depositRange == "Province") {168                    require(169                        depositBankProfile.areaProvince != BLANK170                            && depositOperatorFacts.areaProvince != BLANK,171                        RejectionCode.DEPOSIT_AREA_NOT_FOUND172                    );173                    require(174                        depositBankProfile.areaProvince == depositOperatorFacts.areaProvince,175                        RejectionCode.EN470176                    );177                }178            }179        } else {180            if ((depositBankProfile.proprietaryRange == "SameBranch"181                || depositBankProfile.proprietaryRange == "WithdrawOnly")182                && depositBankProfile.openingBranch != depositOperatorFacts.branch183                && depositOperatorFacts.mode != "CentralBatch"184                && !depositOperatorFacts.corporateTransfer185                && !commonException186                && !(depositBankProfile.restrictedSubtype187                && agencyException)) {188                require(false, RejectionCode.EN134);189            }190        }191    }192    // This subtype check is outside the outer range gate in the source.193    if (depositBankProfile.restrictedSubtype194        && depositBankProfile.openingBranch != depositOperatorFacts.branch195        && !agencyException196        && !commonException197        && depositOperatorFacts.transactionPrefix != "AG01765"198        && depositOperatorFacts.transactionPrefix != "AG02899"199        && depositOperatorFacts.transactionPrefix != "RE04066"200        && depositOperatorFacts.transactionPrefix != "RE04035"201        && !specificPermission) {202        require(false, RejectionCode.EN134);203    }204}205206atomic calculate mergeDepositNotices(AdmissionDecision, DepositNotices) {207    if (admissionDecision.executable208        && (depositNotices.cardWarning != BLANK209        || depositNotices.passbookWarning != BLANK)) {210        admissionDecision.status = AdmissionStatus.WARNING;211    }212}213214// the legacy deposit program and the legacy query module. Reversal uses its own eligibility path.215216atomic check checkCoreDepositReversalEligibility(217    CashAccountControl,218    AccountEligibility,219    DepositOperatorFacts220) {221    require(accountEligibility.status != AccountStatus.CLOSED, RejectionCode.EO082);222    require(cashAccountControl.cancelledOn == 0, RejectionCode.EN113);223    require(224        accountEligibility.status != AccountStatus.FROZEN225            || depositOperatorFacts.transactionPrefix == "SA01116",226        RejectionCode.EN111227    );228}229230atomic check checkDepositOperatorBinding(DepositOperatorFacts, DepositFeeContext) {231    require(232        depositOperatorFacts.branch == depositFeeContext.branchNumber233            && depositOperatorFacts.area == depositFeeContext.regionCode,234        RejectionCode.DEPOSIT_OPERATOR_CONTEXT_MISMATCH235    );236    require(237        depositOperatorFacts.operationCode == "1102" && depositOperatorFacts.transactionPrefix == "SA01102",238        RejectionCode.UNSUPPORTED_DEPOSIT_OPERATOR_PATH239    );240}241242readonly Scenario serial assessReversalEligibility(243    CashAccountControl,244    AccountEligibility,245    DepositOperatorFacts246) {247    checkCoreDepositReversalEligibility;248}