-
Notifications
You must be signed in to change notification settings - Fork 5
/
NextBillingPeriodStartDate.scala
32 lines (28 loc) · 1.19 KB
/
NextBillingPeriodStartDate.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.gu.holidaystopprocessor
import java.time.LocalDate
import com.gu.holiday_stops.CurrentGuardianWeeklySubscription
/**
* Holiday credit is applied to the next invoice on the first day of the next billing period.
*
* 'Invoiced period' or `billing period that has already been invoiced` is defined as
* [processedThroughDate, chargedThroughDate) meaning
* - from processedThroughDate inclusive
* - to chargedThroughDate exclusive
*
* Hence chargedThroughDate represents the first day of the next billing period. For quarterly
* billing period this would be the first day of the next quarter, whilst for annual this would be
* the first day of the next year.
*
* Note chargedThroughDate is an API concept. The UI and the actual invoice use the term 'Service Period'
* where from and to dates are both inclusive.
*
* Note nextBillingPeriodStartDate represents a specific date yyyy-mm-dd unlike billingPeriod (quarterly)
* or billingPeriodStartDay (1st of month).
*/
object NextBillingPeriodStartDate {
def apply(currentGuardianWeeklySubscription: CurrentGuardianWeeklySubscription): LocalDate = {
currentGuardianWeeklySubscription
.invoicedPeriod
.endDateExcluding
}
}