You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeliveryNoteSolver.php 957B

пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace domain\Document\DeliveryNote;
  3. use domain\Document\Document\DocumentSolver;
  4. use domain\Document\Invoice\Invoice;
  5. use domain\_\SolverInterface;
  6. class DeliveryNoteSolver extends DocumentSolver implements SolverInterface
  7. {
  8. public function getInvoiceId(DeliveryNote $deliveryNote): ?int
  9. {
  10. if($deliveryNote->orders && count($deliveryNote->orders) > 0) {
  11. foreach($deliveryNote->orders as $order) {
  12. if($order->id_invoice) {
  13. return $order->id_invoice;
  14. }
  15. }
  16. }
  17. return null;
  18. }
  19. public function isInvoiced(DeliveryNote $deliveryNote): bool
  20. {
  21. return (bool) $this->getInvoiceId($deliveryNote);
  22. }
  23. public function getInvoice(DeliveryNote $deliveryNote): ?Invoice
  24. {
  25. $idInvoice = (int) $this->getInvoiceId($deliveryNote);
  26. return Invoice::searchOne([
  27. 'id' => $idInvoice
  28. ]);
  29. }
  30. }