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

37 行
1.0KB

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