cboddeposit-20-internal-accounts.spp
cboddeposit/account/cboddeposit-20-internal-accounts.spp
Download original file · Bank deposit source contents
1domain cboddeposit;23Role InterestIncomeAccount {4String accountNumber;5quantum BigDecimal(19, 2) balance;6}78Role CollectionInterestIncomeAccount {9String accountNumber;10quantum BigDecimal(19, 2) balance;11}1213Role PrincipalRecoveryAccount {14String accountNumber;15quantum BigDecimal(19, 2) balance;16}1718take BankAccount as InterestIncomeAccount {19mapsame;20}2122take BankAccount as CollectionInterestIncomeAccount {23mapsame;24}2526take BankAccount as PrincipalRecoveryAccount {27mapsame;28}2930Contract InternalAccountOpeningAgreement {31InterestIncomeAccount interestIncome;32CollectionInterestIncomeAccount collectionIncome;33PrincipalRecoveryAccount principalRecovery;34}3536atomic check checkInternalAccountNumbers(37BankAccount interestSubject,38BankAccount collectionSubject,39BankAccount principalSubject40) {41require(42interestSubject.accountNumber != null43&& interestSubject.accountNumber != ""44&& collectionSubject.accountNumber != null45&& collectionSubject.accountNumber != ""46&& principalSubject.accountNumber != null47&& principalSubject.accountNumber != "",48"INTERNAL_ACCOUNT_NUMBER_REQUIRED"49);50require(51interestSubject.accountNumber != collectionSubject.accountNumber52&& interestSubject.accountNumber != principalSubject.accountNumber53&& collectionSubject.accountNumber != principalSubject.accountNumber,54"INTERNAL_ACCOUNTS_MUST_DIFFER"55);56}5758atomic calculate prepareInternalAccounts(59BankAccount interestSubject,60BankAccount collectionSubject,61BankAccount principalSubject,62InterestIncomeAccount,63CollectionInterestIncomeAccount,64PrincipalRecoveryAccount,65InternalAccountOpeningAgreement66) {67InterestIncomeAccount.accountNumber = interestSubject.accountNumber;68CollectionInterestIncomeAccount.accountNumber = collectionSubject.accountNumber;69PrincipalRecoveryAccount.accountNumber = principalSubject.accountNumber;70InternalAccountOpeningAgreement.interestIncome = InterestIncomeAccount;71InternalAccountOpeningAgreement.collectionIncome = CollectionInterestIncomeAccount;72InternalAccountOpeningAgreement.principalRecovery = PrincipalRecoveryAccount;73}