No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

27 líneas
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. }