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.

27 line
735B

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