Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

DeliveryNoteSolver.php 957B

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