Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Date effectiveStartDate =
- subscription.SBQQ__StartDate__c.day() == 1
- ? subscription.SBQQ__StartDate__c
- : subscription.SBQQ__StartDate__c.addMonths(1).toStartOfMonth();
- Integer monthsFromStart = effectiveStartDate.monthsBetween(Date.today());
- Integer frequencyInMonths = PERIODIC_COMPENSATIONS.get(frequency);
- Integer fullPeriods = monthsFromStart / frequencyInMonths;
- // TO:DO think about better variable naming
- Integer monthsToAdd = fullPeriods * frequencyInMonths;
- // check if period is full/closed
- if (Math.mod(monthsFromStart, frequencyInMonths) != 0) {
- monthsToAdd++;
- }
- payOutDate = effectiveStartDate.addMonths(monthsToAdd);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement