您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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