1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/Services/PurchaseOrder/PurchaseOrderService.php

90 lines
2.3 KiB
PHP
Raw Normal View History

2022-05-29 04:13:09 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\PurchaseOrder;
use App\Models\PurchaseOrder;
2022-05-31 00:28:32 +02:00
use App\Services\PurchaseOrder\ApplyNumber;
use App\Services\PurchaseOrder\CreateInvitations;
2022-05-29 04:13:09 +02:00
use App\Utils\Traits\MakesHash;
class PurchaseOrderService
{
use MakesHash;
public PurchaseOrder $purchase_order;
public function __construct($purchase_order)
{
$this->purchase_order = $purchase_order;
}
2022-05-31 00:28:32 +02:00
public function createInvitations()
{
$this->purchase_order = (new CreateInvitations($this->purchase_order))->run();
return $this;
}
public function applyNumber()
{
$this->invoice = (new ApplyNumber($this->purchase_order->vendor, $this->purchase_order))->run();
return $this;
}
2022-05-29 04:13:09 +02:00
public function fillDefaults()
{
2022-05-31 00:28:32 +02:00
// $settings = $this->purchase_order->client->getMergedSettings();
2022-05-29 04:13:09 +02:00
2022-05-31 00:28:32 +02:00
// //TODO implement design, footer, terms
2022-05-29 04:13:09 +02:00
2022-05-31 00:28:32 +02:00
// /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/
// if (!isset($this->purchase_order->exchange_rate) && $this->purchase_order->client->currency()->id != (int)$this->purchase_order->company->settings->currency_id)
// $this->purchase_order->exchange_rate = $this->purchase_order->client->currency()->exchange_rate;
2022-05-29 04:13:09 +02:00
2022-05-31 00:28:32 +02:00
// if (!isset($this->purchase_order->public_notes))
// $this->purchase_order->public_notes = $this->purchase_order->client->public_notes;
2022-05-29 04:13:09 +02:00
return $this;
}
public function setStatus($status)
{
$this->purchase_order->status_id = $status;
return $this;
}
public function markSent()
{
2022-06-05 11:22:58 +02:00
$this->purchase_order = (new MarkSent($this->purchase_order->vendor, $this->purchase_order))->run();
return $this;
}
2022-06-05 11:41:19 +02:00
/**
* Saves the purchase order.
* @return \App\Models\PurchaseOrder object
*/
public function save(): ?PurchaseOrder
{
$this->purchase_order->saveQuietly();
return $this->purchase_order;
}
2022-05-29 04:13:09 +02:00
}