renamed income/expense

This commit is contained in:
denisdulici
2019-12-31 15:49:09 +03:00
parent e2189158b9
commit 2428feb73b
235 changed files with 815 additions and 2147 deletions

View File

@ -0,0 +1,101 @@
<?php
namespace App\Transformers\Purchase;
use App\Transformers\Banking\Transaction;
use App\Transformers\Common\Contact;
use App\Transformers\Setting\Currency;
use App\Models\Purchase\Bill as Model;
use League\Fractal\TransformerAbstract;
class Bill extends TransformerAbstract
{
/**
* @var array
*/
protected $defaultIncludes = ['contact', 'currency', 'histories', 'items', 'status', 'transactions'];
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'bill_number' => $model->bill_number,
'order_number' => $model->order_number,
'bill_status_code' => $model->invoice_status_code,
'billed_at' => $model->billed_at ? $model->billed_at->toIso8601String() : '',
'due_at' => $model->due_at ? $model->due_at->toIso8601String() : '',
'amount' => $model->amount,
'currency_code' => $model->currency_code,
'currency_rate' => $model->currency_rate,
'contact_id' => $model->contact_id,
'contact_name' => $model->contact_name,
'contact_email' => $model->contact_email,
'contact_tax_number' => $model->contact_tax_number,
'contact_phone' => $model->contact_phone,
'contact_address' => $model->contact_address,
'notes' => $model->notes,
'attachment' => $model->attachment,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeContact(Model $model)
{
return $this->item($model->contact, new Contact());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCurrency(Model $model)
{
return $this->item($model->currency, new Currency());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includeHistories(Model $model)
{
return $this->collection($model->histories, new BillHistories());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includeItems(Model $model)
{
return $this->collection($model->items, new BillItems());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeStatus(Model $model)
{
return $this->item($model->status, new BillStatus());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includeTransactions(Model $model)
{
return $this->collection($model->transactions, new Transaction());
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Transformers\Purchase;
use App\Models\Purchase\BillHistory as Model;
use League\Fractal\TransformerAbstract;
class BillHistories extends TransformerAbstract
{
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'bill_id' => $model->bill_id,
'status_code' => $model->status_code,
'notify' => $model->notify,
'description' => $model->description,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Transformers\Purchase;
use App\Models\Purchase\BillItem as Model;
use League\Fractal\TransformerAbstract;
class BillItems extends TransformerAbstract
{
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'bill_id' => $model->bill_id,
'item_id' => $model->item_id,
'name' => $model->name,
'price' => $model->price,
'total' => $model->total,
'tax' => $model->tax,
'tax_id' => $model->tax_id,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Transformers\Purchase;
use App\Models\Purchase\BillStatus as Model;
use League\Fractal\TransformerAbstract;
class BillStatus extends TransformerAbstract
{
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'name' => $model->name,
'code' => $model->code,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Transformers\Purchase;
use App\Models\Purchase\BillTotal as Model;
use League\Fractal\TransformerAbstract;
class BillTotals extends TransformerAbstract
{
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'bill_id' => $model->bill_id,
'code' => $model->code,
'name' => $model->name,
'amount' => $model->amount,
'sort_order' => $model->sort_order,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}