cboddeposit-45-agreement-window.spp
cboddeposit/accrual/cboddeposit-45-agreement-window.spp
Download original file · Bank deposit source contents
1domain cboddeposit;23// Zero date encodes absent agreement dates; clipping is business policy, not APP routing.45Role AgreementTerm {6int effectiveDate;7int cancelDate;8}910atomic calculate prepareAgreementWindow(11BankDate normalStart,12BankDate normalEnd,13AgreementTerm,14BankDate clippedStart,15BankDate clippedEnd,16InterestPeriod normal,17InterestPeriod overlap,18AgreementPolicy19) {20clippedStart.encoded = normalStart.encoded;21clippedEnd.encoded = normalStart.encoded;22overlap.amount = normal.amount;23overlap.unit = normal.unit;24overlap.days = 0;25AgreementPolicy.enabled = AgreementPolicy.enabled && AgreementTerm.effectiveDate > 0;26if (AgreementPolicy.enabled) {27clippedStart.encoded = max(normalStart.encoded, AgreementTerm.effectiveDate);28clippedEnd.encoded = normalEnd.encoded;29if (AgreementTerm.cancelDate > 0) {30clippedEnd.encoded = min(normalEnd.encoded, AgreementTerm.cancelDate);31}32if (clippedStart.encoded >= clippedEnd.encoded) {33AgreementPolicy.enabled = false;34clippedStart.encoded = normalStart.encoded;35clippedEnd.encoded = normalStart.encoded;36}37}38}