1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/app/Services/PurchaseOrder/MarkSent.php

45 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2022-06-05 11:41:19 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2024-04-12 06:15:41 +02:00
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
2022-06-05 11:41:19 +02:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\PurchaseOrder;
2024-06-28 07:16:08 +02:00
use App\Models\Vendor;
use App\Models\Webhook;
2024-06-28 07:16:08 +02:00
use App\Models\PurchaseOrder;
class MarkSent
{
2024-06-28 07:16:08 +02:00
public function __construct(public Vendor $vendor, public PurchaseOrder $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) //why was this commented out previously?
->save();
2023-02-07 15:46:52 +01:00
$this->purchase_order->sendEvent(Webhook::EVENT_SENT_PURCHASE_ORDER, "vendor");
return $this->purchase_order;
}
}