Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

InvoiceSolver.php 735B

123456789101112131415161718192021222324252627
  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. }