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

bankdeposit-00-agreements.spp

bankdeposit/deposit/bankdeposit-00-agreements.spp

Download original file · Bank deposit source contents

1domain bankdeposit;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.principalPaid;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, RejectionCode.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    CashDepositAgreement117) {118    if (cashDepositAgreement.interestBaseDelta >= 0) {119        cashSettlementAccount.balance -> depositAccount.interestBase : cashDepositAgreement.interestBaseDelta;120    } else {121        depositAccount.interestBase -> cashSettlementAccount.balance : -cashDepositAgreement.interestBaseDelta;122    }123    cashSettlementAccount.balance -> depositAccount.overdraftInterest : cashDepositAgreement.interestPaid;124    cashSettlementAccount.balance -> depositAccount.collectionInterest : cashDepositAgreement.collectionPaid;125    cashSettlementAccount.balance -> depositAccount.overdraftPrincipal : cashDepositAgreement.principalPaid;126}127128atomic calculate recordDepositFailure(CashDepositAgreement, CashFailureRecord) {129    cashFailureRecord.deposit = cashDepositAgreement;130    cashFailureRecord.handlingState = CashHandlingState.RECONCILIATION_REQUIRED;131}132133atomic calculate recordReversalFailure(CashReversalAgreement, CashFailureRecord) {134    cashFailureRecord.reversal = cashReversalAgreement;135    cashFailureRecord.handlingState = CashHandlingState.RECONCILIATION_REQUIRED;136}137138atomic calculate confirmNoCashMovement(CashFailureRecord) {139    cashFailureRecord.handlingState = CashHandlingState.NOT_COMPLETED;140}141142readonly Scenario serial readCashFailure(CashFailureRecord) {143    findCashFailureRecord;144    identify(cashFailureRecord);145}