diff --git a/app/Services/PurchaseOrder/MarkSent.php b/app/Services/PurchaseOrder/MarkSent.php new file mode 100644 index 000000000000..fe51346066d0 --- /dev/null +++ b/app/Services/PurchaseOrder/MarkSent.php @@ -0,0 +1,45 @@ +client = $client; + $this->purchase_order = $purchase_order; + } + + public function run() + { + + /* Return immediately if status is not draft */ + if ($this->purchase_order->status_id != PurchaseOrder::STATUS_DRAFT) { + return $this->purchase_order; + } + + $this->purchase_order->markInvitationsSent(); + + $this->purchase_order + ->service() + ->setStatus(PurchaseOrder::STATUS_SENT) + ->applyNumber() + // ->adjustBalance($this->purchase_order->amount) + // ->touchPdf() + ->save(); + + event(new PurchaseOrderWasMarkedSent($this->purchase_order, $this->purchase_order->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); + + return $this->purchase_order; + } +}