You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 line
646B

  1. <?php
  2. namespace domain\Document\Invoice;
  3. use common\helpers\Price;
  4. use domain\Document\Document\DocumentSolver;
  5. use domain\Order\Order\Order;
  6. class InvoiceSolver extends DocumentSolver
  7. {
  8. public function getInvoiceAmountPaid(Invoice $invoice): float
  9. {
  10. $amountPaid = 0;
  11. foreach($invoice->payments as $payment) {
  12. $amountPaid += $payment->amount;
  13. }
  14. return $amountPaid;
  15. }
  16. public function isInvoicePaid(Invoice $invoice): bool
  17. {
  18. return $this->getInvoiceAmountPaid($invoice) >= Price::numberTwoDecimals($this->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL));
  19. }
  20. }