bankdeposit-00-agreements.spp
bankdeposit/deposit/bankdeposit-00-agreements.spp
Download original file · Bank deposit source contents
1domain bankdeposit;23Contract CashDepositAgreement {4DepositPostingLine[] postingEvidence;5DepositNotices notices;6DepositOperatorFacts operator;7DepositBankProfile bankProfile;8AdmissionDecision admission;9CashSettlementAccount settlement;10InterestIncomeAccount interestIncome;11CollectionInterestIncomeAccount collectionIncome;12PrincipalRecoveryAccount principalRecovery;13business("Cash deposit receipt number used for transaction enquiry") String depositNumber;14DepositAccount account;15BigDecimal(19, 2) amount;16String currency;17int valueDate;18BigDecimal(19, 2) interestBaseDelta;19BigDecimal(19, 2) interestPaid;20BigDecimal(19, 2) collectionPaid;21BigDecimal(19, 2) principalPaid;22BigDecimal(19, 2) exposureDelta;23BigDecimal(19, 2) fee;24int transactionDate;25int previousTransactionDate;26int settledDetailCount;27BigDecimal(25, 2) addedBackdatedProduct;28boolean reversed;29}3031Contract CashReversalAgreement {32business("Cash reversal receipt number used for business enquiry") String reversalNumber;33CashDepositAgreement original;34int businessDate;35int newDetailItems;36boolean overnightMode2;37BigDecimal(19, 2) refundAmount;38boolean reverseInstitutionLimit;39}4041Role CashFailureRecord {42business("Business failure handling receipt number") String handlingNumber;43CashDepositAgreement deposit;44CashReversalAgreement reversal;45CashHandlingState handlingState;46}4748atomic calculate prepareDepositAgreement(49DepositRequest,50DepositAccount,51CashSettlementAccount,52InterestIncomeAccount,53CollectionInterestIncomeAccount,54PrincipalRecoveryAccount,55DepositPlan,56DepositFeePlan,57AccountEligibility,58BusinessDay,59DepositDetailPolicy,60DepositNotices,61DepositOperatorFacts,62DepositBankProfile,63AdmissionDecision,64CashDepositAgreement65) {66cashDepositAgreement.notices = depositNotices;67cashDepositAgreement.operator = depositOperatorFacts;68cashDepositAgreement.bankProfile = depositBankProfile;69cashDepositAgreement.admission = admissionDecision;70cashDepositAgreement.settlement = cashSettlementAccount;71cashDepositAgreement.interestIncome = interestIncomeAccount;72cashDepositAgreement.collectionIncome = collectionInterestIncomeAccount;73cashDepositAgreement.principalRecovery = principalRecoveryAccount;74cashDepositAgreement.account = depositAccount;75cashDepositAgreement.amount = depositRequest.amount;76cashDepositAgreement.currency = depositRequest.currency;77cashDepositAgreement.valueDate = depositRequest.valueDate;78cashDepositAgreement.interestBaseDelta = depositPlan.newInterestBase - depositAccount.interestBase;79cashDepositAgreement.interestPaid = depositPlan.interestPaid;80cashDepositAgreement.collectionPaid = depositPlan.collectionInterestPaid;81cashDepositAgreement.principalPaid = depositPlan.principalPaid;82cashDepositAgreement.exposureDelta = -depositPlan.principalPaid;83cashDepositAgreement.fee = depositFeePlan.fee;84cashDepositAgreement.transactionDate = businessDay.date;85cashDepositAgreement.previousTransactionDate = accountEligibility.lastTransactionDate;86cashDepositAgreement.settledDetailCount = accountEligibility.detailCount + depositDetailPolicy.itemCount;87cashDepositAgreement.addedBackdatedProduct = 0;88cashDepositAgreement.reversed = false;89}9091atomic check checkDetailPolicy(DepositDetailPolicy) {92require(depositDetailPolicy.itemCount > 0, RejectionCode.INVALID_DETAIL_COUNT);93}9495atomic calculate completeDepositMetadata(96AccountEligibility,97BusinessDay,98DepositDetailPolicy,99AdmissionDecision,100DepositPlan101) {102accountEligibility.cashDepositedToday = admissionDecision.dayCashTotal;103accountEligibility.accountBalance = depositPlan.newAccountBalance;104if (accountEligibility.lastTransactionDate != businessDay.date) {105accountEligibility.transferredToday = 0;106}107accountEligibility.detailCount += depositDetailPolicy.itemCount;108accountEligibility.lastTransactionDate = businessDay.date;109}110111quantum update settleCashDeposit(112DepositAccount,113CashSettlementAccount,114InterestIncomeAccount,115CollectionInterestIncomeAccount,116CashDepositAgreement117) {118if (cashDepositAgreement.interestBaseDelta >= 0) {119cashSettlementAccount.balance -> depositAccount.interestBase : cashDepositAgreement.interestBaseDelta;120} else {121depositAccount.interestBase -> cashSettlementAccount.balance : -cashDepositAgreement.interestBaseDelta;122}123cashSettlementAccount.balance -> depositAccount.overdraftInterest : cashDepositAgreement.interestPaid;124cashSettlementAccount.balance -> depositAccount.collectionInterest : cashDepositAgreement.collectionPaid;125cashSettlementAccount.balance -> depositAccount.overdraftPrincipal : cashDepositAgreement.principalPaid;126}127128atomic calculate recordDepositFailure(CashDepositAgreement, CashFailureRecord) {129cashFailureRecord.deposit = cashDepositAgreement;130cashFailureRecord.handlingState = CashHandlingState.RECONCILIATION_REQUIRED;131}132133atomic calculate recordReversalFailure(CashReversalAgreement, CashFailureRecord) {134cashFailureRecord.reversal = cashReversalAgreement;135cashFailureRecord.handlingState = CashHandlingState.RECONCILIATION_REQUIRED;136}137138atomic calculate confirmNoCashMovement(CashFailureRecord) {139cashFailureRecord.handlingState = CashHandlingState.NOT_COMPLETED;140}141142readonly Scenario serial readCashFailure(CashFailureRecord) {143findCashFailureRecord;144identify(cashFailureRecord);145}