bankdeposit-40-deposit-fee.spp
bankdeposit/fee/bankdeposit-40-deposit-fee.spp
Download original file · Bank deposit source contents
1domain bankdeposit;23Role DepositFeeParty {4String accountKind;5String customerNumber;6String branchNumber;7String regionCode;8}910Role DepositFeeContext {11String channel;12String branchNumber;13String regionCode;14}1516Role DepositFeeRate {17String customerNumber;18String tariff;19BigDecimal(19, 6) rate;20BigDecimal(19, 6) discount;21BigDecimal(19, 2) fixedAmount;22BigDecimal(19, 2) minimum;23BigDecimal(19, 2) maximum;24}2526Role DepositFeePlan {27int range;28String tariff;29boolean applicable;30BigDecimal(19, 2) variableAmount;31BigDecimal(19, 2) fee;32}3334atomic check checkFeeAccount(DepositFeeParty, DepositFeeContext) {35require(36depositFeeContext.channel != "Teller" || depositFeeParty.accountKind == "NormalSavings",37RejectionCode.UNSUPPORTED_DEPOSIT_FEE_ACCOUNT38);39}4041atomic calculate classifyDepositFee(DepositFeeParty, DepositFeeContext, DepositFeePlan) {42depositFeePlan.range = 0;43depositFeePlan.tariff = BLANK;44depositFeePlan.applicable = false;45depositFeePlan.variableAmount = 0;46depositFeePlan.fee = 0;47if (depositFeeContext.channel == "Teller") {48if (depositFeeParty.regionCode != depositFeeContext.regionCode) {49depositFeePlan.range = 2;50depositFeePlan.tariff = "TRF00002";51} else {52if (depositFeeParty.branchNumber != depositFeeContext.branchNumber) {53depositFeePlan.range = 1;54depositFeePlan.tariff = "TRF00001";55}56}57depositFeePlan.applicable = depositFeePlan.range > 0;58}59}6061atomic calculate prepareFeeLookup(DepositFeeParty, DepositFeePlan, DepositFeeRate) {62depositFeeRate.customerNumber = depositFeeParty.customerNumber;63depositFeeRate.tariff = depositFeePlan.tariff;64}6566atomic check checkFeeRate(DepositFeePlan, DepositFeeRate) {67require(68!depositFeePlan.applicable || depositFeeRate.tariff == depositFeePlan.tariff,69RejectionCode.DEPOSIT_FEE_TARIFF_MISMATCH70);71require(72!depositFeePlan.applicable73|| (depositFeeRate.rate >= 074&& depositFeeRate.discount >= 075&& depositFeeRate.minimum >= 076&& depositFeeRate.maximum >= depositFeeRate.minimum),77RejectionCode.INVALID_DEPOSIT_FEE_RATE78);79}8081atomic calculate calculateDepositFee(DepositRequest, DepositFeeRate, DepositFeePlan) {82if (depositFeePlan.applicable) {83depositFeePlan.variableAmount = roundHalfUp(84depositRequest.amount * depositFeeRate.rate * depositFeeRate.discount,85286);87depositFeePlan.fee = depositFeePlan.variableAmount + depositFeeRate.fixedAmount;88if (depositFeePlan.fee > depositFeeRate.maximum) {89depositFeePlan.fee = depositFeeRate.maximum;90} else {91if (depositFeePlan.fee < depositFeeRate.minimum) {92depositFeePlan.fee = depositFeeRate.minimum;93}94}95}96}9798atomic check checkRequiredFeeIdentified(DepositFeePlan, DepositFeeRate) {99require(!depositFeePlan.applicable || depositFeeRate, RejectionCode.DEPOSIT_FEE_RATE_NOT_FOUND);100}