bankdeposit-20-internal-accounts.spp
bankdeposit/account/bankdeposit-20-internal-accounts.spp
Download original file · Bank deposit source contents
1domain bankdeposit;23Role InterestIncomeAccount;45Role CollectionInterestIncomeAccount;67Role PrincipalRecoveryAccount;89take InterestSubject as InterestIncomeAccount {10takeall;11quantum BigDecimal(19, 2) balance;12}1314take CollectionSubject as CollectionInterestIncomeAccount {15takeall;16quantum BigDecimal(19, 2) balance;17}1819take PrincipalSubject as PrincipalRecoveryAccount {20takeall;21quantum BigDecimal(19, 2) balance;22}2324// The three internal accounts are opened together, so each subject is its own role with its own table.2526Role InterestSubject short interestSubject {27String accountNumber;28}2930Role CollectionSubject short collectionSubject {31String accountNumber;32}3334Role PrincipalSubject short principalSubject {35String accountNumber;36}3738Contract InternalAccountOpeningAgreement {39InterestIncomeAccount interestIncome;40CollectionInterestIncomeAccount collectionIncome;41PrincipalRecoveryAccount principalRecovery;42}4344atomic check checkInternalAccountNumbers( InterestSubject, CollectionSubject, PrincipalSubject ) {45require(46interestSubject.accountNumber != BLANK47&& collectionSubject.accountNumber != BLANK48&& principalSubject.accountNumber != BLANK,49RejectionCode.INTERNAL_ACCOUNT_NUMBER_REQUIRED50);51require(52interestSubject.accountNumber != collectionSubject.accountNumber53&& interestSubject.accountNumber != principalSubject.accountNumber54&& collectionSubject.accountNumber != principalSubject.accountNumber,55RejectionCode.INTERNAL_ACCOUNTS_MUST_DIFFER56);57}5859atomic calculate prepareInternalAccounts(60InterestSubject,61CollectionSubject,62PrincipalSubject,63InterestIncomeAccount,64CollectionInterestIncomeAccount,65PrincipalRecoveryAccount,66InternalAccountOpeningAgreement67) {68interestIncomeAccount.accountNumber = interestSubject.accountNumber;69collectionInterestIncomeAccount.accountNumber = collectionSubject.accountNumber;70principalRecoveryAccount.accountNumber = principalSubject.accountNumber;71internalAccountOpeningAgreement.interestIncome = interestIncomeAccount;72internalAccountOpeningAgreement.collectionIncome = collectionInterestIncomeAccount;73internalAccountOpeningAgreement.principalRecovery = principalRecoveryAccount;74}