Merge pull request #7634 from turbo124/v5-develop

Add status and client to task transformer
This commit is contained in:
David Bomba 2022-07-12 20:51:30 +10:00 committed by GitHub
commit a1befd96ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 11 deletions

View File

@ -18,7 +18,7 @@ class PaymentType extends StaticModel
*/
public $timestamps = false;
const CREDIT = 1;
const CREDIT = 32;
const ACH = 4;
const VISA = 5;
const MASTERCARD = 6;

View File

@ -302,7 +302,7 @@ class BaseRepository
/* Perform model specific tasks */
if ($model instanceof Invoice) {
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT && $model->status_id != Invoice::STATUS_PAID)) {
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) {
//10-07-2022
$model->service()->updateStatus()->save();

View File

@ -48,19 +48,27 @@ class PurchaseOrderService
public function fillDefaults()
{
// $settings = $this->purchase_order->client->getMergedSettings();
// //TODO implement design, footer, terms
$settings = $this->purchase_order->company->settings;
// /* 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;
if (! $this->purchase_order->design_id)
$this->purchase_order->design_id = $this->decodePrimaryKey($settings->invoice_design_id);
if (!isset($this->invoice->footer) || empty($this->invoice->footer))
$this->purchase_order->footer = $settings->purchase_order_footer;
// if (!isset($this->purchase_order->public_notes))
// $this->purchase_order->public_notes = $this->purchase_order->client->public_notes;
if (!isset($this->purchase_order->terms) || empty($this->purchase_order->terms))
$this->purchase_order->terms = $settings->purchase_order_terms;
if (!isset($this->purchase_order->public_notes) || empty($this->purchase_order->public_notes))
$this->purchase_order->public_notes = $this->purchase_order->vendor->public_notes;
if($settings->counter_number_applied == 'when_saved'){
$this->applyNumber()->save();
}
return $this;
}
public function triggeredActions($request)

View File

@ -123,8 +123,10 @@ class RecurringService
public function sendNow()
{
if($this->recurring_entity instanceof RecurringInvoice)
if($this->recurring_entity instanceof RecurringInvoice && $this->recurring_entity->status_id == RecurringInvoice::STATUS_DRAFT){
$this->start()->save();
SendRecurring::dispatchNow($this->recurring_entity, $this->recurring_entity->company->db);
}
return $this->recurring_entity;

View File

@ -13,6 +13,8 @@ namespace App\Transformers;
use App\Models\Document;
use App\Models\Task;
use App\Models\TaskStatus;
use App\Transformers\TaskStatusTransformer;
use App\Utils\Traits\MakesHash;
use League\Fractal\Resource\Item;
@ -32,6 +34,7 @@ class TaskTransformer extends EntityTransformer
*/
protected $availableIncludes = [
'client',
'status'
];
public function includeDocuments(Task $task)
@ -41,13 +44,27 @@ class TaskTransformer extends EntityTransformer
return $this->includeCollection($task->documents, $transformer, Document::class);
}
public function includeClient(Task $task): Item
public function includeClient(Task $task): ?Item
{
$transformer = new ClientTransformer($this->serializer);
if(!$task->client)
return null;
return $this->includeItem($task->client, $transformer, Client::class);
}
public function includeStatus(Task $task): ?Item
{
$transformer = new TaskStatusTransformer($this->serializer);
if(!$task->status)
return null;
return $this->includeItem($task->status, $transformer, TaskStatus::class);
}
public function transform(Task $task)
{
return [