bankdeposit-45-agreement-window.spp
bankdeposit/accrual/bankdeposit-45-agreement-window.spp
Download original file · Bank deposit source contents
1domain bankdeposit;23// Zero date encodes absent agreement dates; clipping is business policy, not APP routing.45Role AgreementTerm {6int effectiveDate;7int cancelDate;8}910// The clipped window and the overlap period are second participants of the BankDate and11// InterestPeriod types, so each is a distinct role over its base type.1213Role OverlapStart short clippedStart;1415take BankDate as OverlapStart;1617Role OverlapEnd short clippedEnd;1819take BankDate as OverlapEnd;2021Role OverlapPeriod short overlap;2223take InterestPeriod as OverlapPeriod;2425atomic calculate prepareAgreementWindow(26BankDate,27PeriodEnd,28AgreementTerm,29OverlapStart,30OverlapEnd,31InterestPeriod,32OverlapPeriod,33AgreementPolicy34) {35clippedStart.encoded = start.encoded;36clippedEnd.encoded = start.encoded;37overlap.amount = normal.amount;38overlap.unit = normal.unit;39overlap.days = 0;40agreementPolicy.enabled = agreementPolicy.enabled && agreementTerm.effectiveDate > 0;41if (agreementPolicy.enabled) {42clippedStart.encoded = max(start.encoded, agreementTerm.effectiveDate);43clippedEnd.encoded = end.encoded;44if (agreementTerm.cancelDate > 0) {45clippedEnd.encoded = min(end.encoded, agreementTerm.cancelDate);46}47if (clippedStart.encoded >= clippedEnd.encoded) {48agreementPolicy.enabled = false;49clippedStart.encoded = start.encoded;50clippedEnd.encoded = start.encoded;51}52}53}