in src/main/scala/com/gu/invoicing/preview/Model.scala [19:59]
def apply(input: APIGatewayProxyRequestEvent): PreviewInput =
PreviewInput(
pathParameterOrThrow(input, "subscriptionName"),
LocalDate.parse(queryStringParameterOrThrow(input, "startDate")),
LocalDate.parse(queryStringParameterOrThrow(input, "endDate")),
)
}
case class PreviewOutput(
subscriptionName: String,
nextInvoiceDateAfterToday: Option[LocalDate] = None,
rangeStartDate: LocalDate,
rangeEndDate: LocalDate,
publicationsWithinRange: List[Publication],
)
// ************************************************************************
// Implementation detail models
// ************************************************************************
case class RatePlanCharge(
originalChargeId: String,
price: Double /* Includes tax */,
discountPercentage: Option[Double],
effectiveStartDate: LocalDate,
effectiveEndDate: LocalDate,
model: Option[String], /* Used to determine discounts DiscountPercentage */
)
case class RatePlan(ratePlanCharges: List[RatePlanCharge])
case class Subscription(
invoiceOwnerAccountId: String,
ratePlans: List[RatePlan],
)
case class Publication( /* Contrast with InvoiceItem */
publicationDate: LocalDate, /* Date of paper printed on cover */
invoiceDate: LocalDate, /* Publication falls on this invoice */
nextInvoiceDate: LocalDate, /* The invoice on which this publication would be credited */
productName: String, /* For example Newspaper Delivery */
chargeName: String, /* For example Sunday */
dayOfWeek: DayOfWeek, /* Strongly typed day of publication */
price: Double, /* Charge of single publication (including tax) */
invoiceItemId: String, /* InvoiceItem associated with this publication */
) {