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

36 行
957B

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