Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

InvoiceSolver.php 646B

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