in src/main/scala/InvoiceHelper.scala [52:66]
def buildChargeAdjustment(invoice: Invoice, positiveCharge: InvoiceItem, negativeCharge: Option[InvoiceItem]): InvoiceItemAdjustment = {
val amount = negativeCharge match {
case Some(discount) => {
logger.info(s"Found a discount of ${discount.chargeAmount}")
positiveCharge.chargeAmount + discount.chargeAmount
}
case None => positiveCharge.chargeAmount
}
InvoiceItemAdjustment(
amount = amount,
invoice = invoice,
sourceType = "InvoiceDetail",
sourceId = positiveCharge.id
)
}