選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

27 行
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. }