Nevar pievienot vairāk kā 25 tēmas
Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
|
- <?php
-
- namespace common\logic\Document\DeliveryNote\Service;
-
- use common\logic\Document\DeliveryNote\Model\DeliveryNote;
- use common\logic\Document\Document\Service\DocumentSolver;
- use common\logic\Document\Invoice\Model\Invoice;
- use common\logic\SolverInterface;
-
- class DeliveryNoteSolver extends DocumentSolver implements SolverInterface
- {
- public function getInvoiceId(DeliveryNote $deliveryNote): ?int
- {
- if($deliveryNote->orders && count($deliveryNote->orders) > 0) {
- foreach($deliveryNote->orders as $order) {
- if($order->id_invoice) {
- return $order->id_invoice;
- }
- }
- }
-
- return null;
- }
-
- public function isInvoiced(DeliveryNote $deliveryNote): bool
- {
- return (bool) $this->getInvoiceId($deliveryNote);
- }
-
- public function getInvoice(DeliveryNote $deliveryNote): ?Invoice
- {
- $idInvoice = (int) $this->getInvoiceId($deliveryNote);
- return Invoice::searchOne([
- 'id' => $idInvoice
- ]);
- }
- }
|