cboddeposit-40-deposit-fee.spp
cboddeposit/fee/cboddeposit-40-deposit-fee.spp
Download original file · Bank deposit source contents
1domain cboddeposit;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",37"UNSUPPORTED_DEPOSIT_FEE_ACCOUNT"38);39}4041atomic calculate classifyDepositFee(DepositFeeParty, DepositFeeContext, DepositFeePlan) {42DepositFeePlan.range = 0;43DepositFeePlan.tariff = "";44DepositFeePlan.applicable = false;45DepositFeePlan.variableAmount = 0;46DepositFeePlan.fee = 0;47if (DepositFeeContext.channel == "Teller") {48if (DepositFeeParty.regionCode != DepositFeeContext.regionCode) {49DepositFeePlan.range = 2;50DepositFeePlan.tariff = "SAP00001";51} else {52if (DepositFeeParty.branchNumber != DepositFeeContext.branchNumber) {53DepositFeePlan.range = 1;54DepositFeePlan.tariff = "SAC00001";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,69"DEPOSIT_FEE_TARIFF_MISMATCH"70);71require(72!DepositFeePlan.applicable73|| (DepositFeeRate.rate >= 074&& DepositFeeRate.discount >= 075&& DepositFeeRate.minimum >= 076&& DepositFeeRate.maximum >= DepositFeeRate.minimum),77"INVALID_DEPOSIT_FEE_RATE"78);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, "DEPOSIT_FEE_RATE_NOT_FOUND");100}