v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -1,32 +0,0 @@
<?php
namespace App\Transformers\Income;
use App\Models\Income\Customer as Model;
use League\Fractal\TransformerAbstract;
class Customer extends TransformerAbstract
{
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'user_id' => $model->user_id,
'name' => $model->name,
'email' => $model->email,
'tax_number' => $model->tax_number,
'phone' => $model->phone,
'address' => $model->address,
'website' => $model->website,
'currency_code' => $model->currency_code,
'enabled' => $model->enabled,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
];
}
}

View File

@ -2,11 +2,8 @@
namespace App\Transformers\Income;
use App\Transformers\Income\Customer;
use App\Transformers\Income\InvoiceHistories;
use App\Transformers\Income\InvoiceItems;
use App\Transformers\Income\InvoicePayments;
use App\Transformers\Income\InvoiceStatus;
use App\Transformers\Banking\Transaction;
use App\Transformers\Common\Contact;
use App\Transformers\Setting\Currency;
use App\Models\Income\Invoice as Model;
use League\Fractal\TransformerAbstract;
@ -16,7 +13,7 @@ class Invoice extends TransformerAbstract
/**
* @var array
*/
protected $defaultIncludes = ['currency', 'customer', 'histories', 'items', 'payments', 'status'];
protected $defaultIncludes = ['contact', 'currency', 'histories', 'items', 'status', 'transactions'];
/**
* @param Model $model
@ -30,24 +27,33 @@ class Invoice extends TransformerAbstract
'invoice_number' => $model->invoice_number,
'order_number' => $model->order_number,
'invoice_status_code' => $model->invoice_status_code,
'invoiced_at' => $model->invoiced_at->toIso8601String(),
'due_at' => $model->due_at->toIso8601String(),
'invoiced_at' => $model->invoiced_at ? $model->invoiced_at->toIso8601String() : '',
'due_at' => $model->due_at ? $model->due_at->toIso8601String() : '',
'amount' => $model->amount,
'currency_code' => $model->currency_code,
'currency_rate' => $model->currency_rate,
'customer_id' => $model->customer_id,
'customer_name' => $model->customer_name,
'customer_email' => $model->customer_email,
'customer_tax_number' => $model->customer_tax_number,
'customer_phone' => $model->customer_phone,
'customer_address' => $model->customer_address,
'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->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'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
@ -57,15 +63,6 @@ class Invoice extends TransformerAbstract
return $this->item($model->currency, new Currency());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCustomer(Model $model)
{
return $this->item($model->customer, new Customer());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
@ -84,15 +81,6 @@ class Invoice extends TransformerAbstract
return $this->collection($model->items, new InvoiceItems());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includePayments(Model $model)
{
return $this->collection($model->payments, new InvoicePayments());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
@ -101,4 +89,13 @@ class Invoice extends TransformerAbstract
{
return $this->item($model->status, new InvoiceStatus());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includeTransactions(Model $model)
{
return $this->collection($model->transactions, new Transaction());
}
}

View File

@ -20,8 +20,8 @@ class InvoiceHistories extends TransformerAbstract
'status_code' => $model->status_code,
'notify' => $model->notify,
'description' => $model->description,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -19,14 +19,12 @@ class InvoiceItems extends TransformerAbstract
'invoice_id' => $model->invoice_id,
'item_id' => $model->item_id,
'name' => $model->name,
'sku' => $model->sku,
'quantity' => $model->quantity,
'price' => $model->price,
'total' => $model->total,
'tax' => $model->tax,
'tax_id' => $model->tax_id,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -1,58 +0,0 @@
<?php
namespace App\Transformers\Income;
use App\Transformers\Banking\Account;
use App\Transformers\Setting\Currency;
use App\Models\Income\InvoicePayment as Model;
use League\Fractal\TransformerAbstract;
class InvoicePayments extends TransformerAbstract
{
/**
* @var array
*/
protected $defaultIncludes = ['account', 'currency'];
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'invoice_id' => $model->invoice_id,
'account_id' => $model->account_id,
'paid_at' => $model->paid_at->toIso8601String(),
'amount' => $model->amount,
'currency_code' => $model->currency_code,
'currency_rate' => $model->currency_rate,
'description' => $model->description,
'payment_method' => $model->payment_method,
'reference' => $model->reference,
'attachment' => $model->attachment,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
];
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeAccount(Model $model)
{
return $this->item($model->account, new Account());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCurrency(Model $model)
{
return $this->item($model->currency, new Currency());
}
}

View File

@ -18,8 +18,8 @@ class InvoiceStatus extends TransformerAbstract
'company_id' => $model->company_id,
'name' => $model->name,
'code' => $model->code,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -22,8 +22,8 @@ class InvoiceTotals extends TransformerAbstract
'name' => $model->name,
'amount' => $model->amount,
'sort_order' => $model->sort_order,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@ -1,83 +0,0 @@
<?php
namespace App\Transformers\Income;
use App\Transformers\Banking\Account;
use App\Transformers\Income\Customer;
use App\Transformers\Setting\Category;
use App\Transformers\Setting\Currency;
use App\Models\Income\Revenue as Model;
use League\Fractal\TransformerAbstract;
class Revenue extends TransformerAbstract
{
/**
* @var array
*/
protected $defaultIncludes = ['account', 'category', 'currency', 'customer'];
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'account_id' => $model->account_id,
'paid_at' => $model->paid_at->toIso8601String(),
'amount' => $model->amount,
'currency_code' => $model->currency_code,
'currency_rate' => $model->currency_rate,
'customer_id' => $model->customer_id,
'description' => $model->description,
'category_id' => $model->category_id,
'payment_method' => $model->payment_method,
'reference' => $model->reference,
'attachment' => $model->attachment,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
];
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeAccount(Model $model)
{
return $this->item($model->account, new Account());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCategory(Model $model)
{
return $this->item($model->category, new Category());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCurrency(Model $model)
{
return $this->item($model->currency, new Currency());
}
/**
* @param Model $model
* @return mixed
*/
public function includeCustomer(Model $model)
{
if (!$model->customer) {
return $this->null();
}
return $this->item($model->customer, new Customer());
}
}