cboddeposit-20-bank-calendar.spp
cboddeposit/accrual/cboddeposit-20-bank-calendar.spp
Download original file · Bank deposit source contents
1domain cboddeposit;23// Business interest-unit quantization, CSAPRD2 5300; dates supplied by shared calendar service.45Role InterestPeriod {6BigDecimal(19, 2) amount;7BigDecimal(19, 2) unit;8int days;9}1011Role InterestProduct {12BigDecimal(19, 2) qualifiedAmount;13BigDecimal(19, 2) product;14}1516atomic check checkInterestPeriod(InterestPeriod) {17require(18InterestPeriod.amount >= 0 && InterestPeriod.unit > 0 && InterestPeriod.days >= 0,19"INVALID_INTEREST_PERIOD"20);21}2223atomic check checkBankDate(BankDate) {24require(BankDate.encoded != null && BankDate.encoded != 0, "EEC28");25require(BankDate.encoded >= 10000101 && BankDate.encoded <= 99991231, "EE374");26require(isGregorianDate(BankDate.encoded), "EE374");27}2829atomic check checkBankDays(BankDate start, BankDate end, InterestCalendar) {30require(start.epochDay <= end.epochDay, "E1175");31require(32InterestCalendar.convention == "ACT"33|| InterestCalendar.convention == "360365"34|| InterestCalendar.convention == "360360",35"EEC28"36);37}3839atomic calculate calculateInterestProduct(InterestPeriod, InterestProduct) {40InterestProduct.qualifiedAmount = roundDown(41InterestPeriod.amount / InterestPeriod.unit,42043) * InterestPeriod.unit;44InterestProduct.product = InterestProduct.qualifiedAmount * InterestPeriod.days;45}4647// CSAPRD2/CCMDAT1 function O: start included, end excluded.48// The shared Gregorian functions decode representation; business selects ACT or deposit 360-day policy.4950Role BankDate {51int encoded;52int year;53int month;54int day;55int epochDay;56}5758Role InterestCalendar {59String convention;60}6162atomic calculate decodeBankDate(BankDate) {63BankDate.year = dateYear(BankDate.encoded);64BankDate.month = dateMonth(BankDate.encoded);65BankDate.day = dateDay(BankDate.encoded);66BankDate.epochDay = dateEpochDay(BankDate.encoded);67}6869atomic calculate calculateBankDays(BankDate start, BankDate end, InterestCalendar, InterestPeriod) {70if (InterestCalendar.convention == "ACT") {71InterestPeriod.days = end.epochDay - start.epochDay;72} else {73InterestPeriod.days = 36074* (end.year75- start.year)76+ 3077* (end.month78- start.month)79+ min(end.day, 30)80- min(start.day, 30);81}82}