-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...iday-stop-processor/src/main/scala/com/gu/holidaystopprocessor/NextInvoiceStartDate.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.gu.holidaystopprocessor | ||
|
||
import java.time.LocalDate | ||
|
||
/** | ||
* Invoiced period is defined as [processedThroughDate, chargedThroughDate) meaning | ||
* - from processedThroughDate inclusive | ||
* - to chargedThroughDate exclusive | ||
* | ||
* Hence chargedThroughDate represents the first day of the next invoiced 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. | ||
*/ | ||
object NextInvoiceStartDate { | ||
def apply(subscription: Subscription): Either[HolidayStopFailure, LocalDate] = { | ||
subscription | ||
.originalRatePlanCharge | ||
.flatMap(_.chargedThroughDate) | ||
.toRight(HolidayStopFailure("Original rate plan charge has no charged through date. A bill run is needed to fix this.")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters