S++Business systems language
DEMO SOURCE · SPP / APP / PHYRead the book

cboddeposit-00-agreements.spp

cboddeposit/deposit/cboddeposit-00-agreements.spp

Download original file · Bank deposit source contents

1domain cboddeposit;23Contract CashDepositAgreement {4    DepositPostingLine[] postingEvidence;5    DepositNotices notices;6    DepositOperatorFacts operator;7    DepositBankProfile bankProfile;8    AdmissionDecision admission;9    CashSettlementAccount settlement;10    InterestIncomeAccount interestIncome;11    CollectionInterestIncomeAccount collectionIncome;12    PrincipalRecoveryAccount principalRecovery;13    business("Cash deposit receipt number used for transaction enquiry") String depositNumber;14    DepositAccount account;15    BigDecimal(19, 2) amount;16    String currency;17    int valueDate;18    BigDecimal(19, 2) interestBaseDelta;19    BigDecimal(19, 2) interestPaid;20    BigDecimal(19, 2) collectionPaid;21    BigDecimal(19, 2) principalPaid;22    BigDecimal(19, 2) exposureDelta;23    BigDecimal(19, 2) fee;24    int transactionDate;25    int previousTransactionDate;26    int settledDetailCount;27    BigDecimal(25, 2) addedBackdatedProduct;28    boolean reversed;29}3031Contract CashReversalAgreement {32    business("Cash reversal receipt number used for business enquiry") String reversalNumber;33    CashDepositAgreement original;34    int businessDate;35    int newDetailItems;36    boolean overnightMode2;37    BigDecimal(19, 2) refundAmount;38    boolean reverseInstitutionLimit;39}4041Role CashFailureRecord {42    business("Business failure handling receipt number") String handlingNumber;43    CashDepositAgreement deposit;44    CashReversalAgreement reversal;45    CashHandlingState handlingState;46}4748atomic calculate prepareDepositAgreement(49    DepositRequest,50    DepositAccount,51    CashSettlementAccount,52    InterestIncomeAccount,53    CollectionInterestIncomeAccount,54    PrincipalRecoveryAccount,55    DepositPlan,56    DepositFeePlan,57    AccountEligibility,58    BusinessDay,59    DepositDetailPolicy,60    DepositNotices,61    DepositOperatorFacts,62    DepositBankProfile,63    AdmissionDecision,64    CashDepositAgreement65) {66    CashDepositAgreement.notices = DepositNotices;67    CashDepositAgreement.operator = DepositOperatorFacts;68    CashDepositAgreement.bankProfile = DepositBankProfile;69    CashDepositAgreement.admission = AdmissionDecision;70    CashDepositAgreement.settlement = CashSettlementAccount;71    CashDepositAgreement.interestIncome = InterestIncomeAccount;72    CashDepositAgreement.collectionIncome = CollectionInterestIncomeAccount;73    CashDepositAgreement.principalRecovery = PrincipalRecoveryAccount;74    CashDepositAgreement.account = DepositAccount;75    CashDepositAgreement.amount = DepositRequest.amount;76    CashDepositAgreement.currency = DepositRequest.currency;77    CashDepositAgreement.valueDate = DepositRequest.valueDate;78    CashDepositAgreement.interestBaseDelta = DepositPlan.newInterestBase - DepositAccount.interestBase;79    CashDepositAgreement.interestPaid = DepositPlan.interestPaid;80    CashDepositAgreement.collectionPaid = DepositPlan.collectionInterestPaid;81    CashDepositAgreement.principalPaid = DepositPlan.principalPaid;82    CashDepositAgreement.exposureDelta = DepositPlan.newOverdraftExposure - DepositAccount.overdraftExposure;83    CashDepositAgreement.fee = DepositFeePlan.fee;84    CashDepositAgreement.transactionDate = BusinessDay.date;85    CashDepositAgreement.previousTransactionDate = AccountEligibility.lastTransactionDate;86    CashDepositAgreement.settledDetailCount = AccountEligibility.detailCount + DepositDetailPolicy.itemCount;87    CashDepositAgreement.addedBackdatedProduct = 0;88    CashDepositAgreement.reversed = false;89}9091atomic check checkDetailPolicy(DepositDetailPolicy) {92    require(DepositDetailPolicy.itemCount > 0, "INVALID_DETAIL_COUNT");93}9495atomic calculate completeDepositMetadata(96    AccountEligibility,97    BusinessDay,98    DepositDetailPolicy,99    AdmissionDecision,100    DepositPlan101) {102    AccountEligibility.cashDepositedToday = AdmissionDecision.dayCashTotal;103    AccountEligibility.accountBalance = DepositPlan.newAccountBalance;104    if (AccountEligibility.lastTransactionDate != BusinessDay.date) {105        AccountEligibility.transferredToday = 0;106    }107    AccountEligibility.detailCount += DepositDetailPolicy.itemCount;108    AccountEligibility.lastTransactionDate = BusinessDay.date;109}110111quantum update settleCashDeposit(112    DepositAccount,113    CashSettlementAccount,114    InterestIncomeAccount,115    CollectionInterestIncomeAccount,116    PrincipalRecoveryAccount,117    CashDepositAgreement118) {119    DepositAccount.interestBase += CashDepositAgreement.interestBaseDelta;120    DepositAccount.overdraftInterest -= CashDepositAgreement.interestPaid;121    DepositAccount.collectionInterest -= CashDepositAgreement.collectionPaid;122    DepositAccount.overdraftPrincipal -= CashDepositAgreement.principalPaid;123    DepositAccount.overdraftExposure += CashDepositAgreement.exposureDelta;124    CashSettlementAccount.balance -= CashDepositAgreement.amount;125    InterestIncomeAccount.balance += CashDepositAgreement.interestPaid;126    CollectionInterestIncomeAccount.balance += CashDepositAgreement.collectionPaid;127    PrincipalRecoveryAccount.balance += CashDepositAgreement.principalPaid;128}129130atomic calculate recordDepositFailure(CashDepositAgreement, CashFailureRecord) {131    CashFailureRecord.deposit = CashDepositAgreement;132    CashFailureRecord.handlingState = CashHandlingState.RECONCILIATION_REQUIRED;133}134135atomic calculate recordReversalFailure(CashReversalAgreement, CashFailureRecord) {136    CashFailureRecord.reversal = CashReversalAgreement;137    CashFailureRecord.handlingState = CashHandlingState.RECONCILIATION_REQUIRED;138}139140atomic calculate confirmNoCashMovement(CashFailureRecord) {141    CashFailureRecord.handlingState = CashHandlingState.NOT_COMPLETED;142}