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

cboddeposit-20-internal-accounts.spp

cboddeposit/account/cboddeposit-20-internal-accounts.spp

Download original file · Bank deposit source contents

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