akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace App\Http\Resources\Auth;
use Illuminate\Http\Resources\Json\JsonResource;
class Role extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->display_name,
'code' => $this->name,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Resources\Auth;
use App\Http\Resources\Auth\Role;
use App\Http\Resources\Common\Company;
use Illuminate\Http\Resources\Json\JsonResource;
class User extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'locale' => $this->locale,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'companies' => [static::$wrap => Company::collection($this->companies)],
'roles' => [static::$wrap => Role::collection($this->roles)],
];
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Http\Resources\Banking;
use Illuminate\Http\Resources\Json\JsonResource;
class Account extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'name' => $this->name,
'number' => $this->number,
'currency_code' => $this->currency_code,
'opening_balance' => $this->opening_balance,
'opening_balance_formatted' => money($this->opening_balance, $this->currency_code, true)->format(),
'current_balance' => $this->balance,
'current_balance_formatted' => money($this->balance, $this->currency_code, true)->format(),
'bank_name' => $this->bank_name,
'bank_phone' => $this->bank_phone,
'bank_address' => $this->bank_address,
'enabled' => $this->enabled,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Resources\Banking;
use App\Http\Resources\Banking\Account;
use Illuminate\Http\Resources\Json\JsonResource;
class Reconciliation extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'account_id' => $this->account_id,
'started_at' => $this->started_at->toIso8601String(),
'ended_at' => $this->ended_at->toIso8601String(),
'closing_balance' => $this->closing_balance,
'closing_balance_formatted' => money($this->closing_balance, setting('default.currency'), true)->format(),
'reconciled' => $this->reconciled,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
'account' => new Account($this->account),
];
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Http\Resources\Banking;
use App\Http\Resources\Banking\Account;
use App\Http\Resources\Common\Contact;
use App\Http\Resources\Setting\Category;
use App\Http\Resources\Setting\Currency;
use Illuminate\Http\Resources\Json\JsonResource;
class Transaction extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'account_id' => $this->account_id,
'paid_at' => $this->paid_at->toIso8601String(),
'amount' => $this->amount,
'amount_formatted' => money($this->amount, $this->currency_code, true)->format(),
'currency_code' => $this->currency_code,
'currency_rate' => $this->currency_rate,
'document_id' => $this->document_id,
'contact_id' => $this->contact_id,
'description' => $this->description,
'category_id' => $this->category_id,
'payment_method' => $this->payment_method,
'reference' => $this->reference,
'parent_id' => $this->parent_id,
'split_id' => $this->split_id,
'attachment' => $this->attachment,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
'account' => new Account($this->account),
'category' => new Category($this->category),
'currency' => new Currency($this->currency),
'contact' => new Contact($this->contact),
];
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Resources\Banking;
use Illuminate\Http\Resources\Json\JsonResource;
class Transfer extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
$expense_transaction = $this->expense_transaction;
$income_transaction = $this->income_transaction;
return [
'id' => $this->id,
'company_id' => $this->company_id,
'from_account' => $expense_transaction->account->name,
'from_account_id' => $expense_transaction->account->id,
'to_account' => $income_transaction->account->name,
'to_account_id' => $income_transaction->account->id,
'amount' => $expense_transaction->amount,
'amount_formatted' => money($expense_transaction->amount, $expense_transaction->currency_code, true)->format(),
'currency_code' => $expense_transaction->currency_code,
'paid_at' => $expense_transaction->paid_at ? $expense_transaction->paid_at->toIso8601String() : '',
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Resources\Common;
use Illuminate\Http\Resources\Json\JsonResource;
class Company extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'currency' => $this->currency,
'domain' => $this->domain,
'address' => $this->address,
'logo' => $this->logo,
'enabled' => $this->enabled,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Resources\Common;
use Illuminate\Http\Resources\Json\JsonResource;
class Contact extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'user_id' => $this->user_id,
'type' => $this->type,
'name' => $this->name,
'email' => $this->email,
'tax_number' => $this->tax_number,
'phone' => $this->phone,
'address' => $this->address,
'website' => $this->website,
'currency_code' => $this->currency_code,
'enabled' => $this->enabled,
'reference' => $this->reference,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Resources\Common;
use App\Http\Resources\Common\Widget;
use App\Utilities\Widgets;
use Illuminate\Http\Resources\Json\JsonResource;
class Dashboard extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
$widgets = $this->widgets->filter(function ($widget) {
return Widgets::canShow($widget->class);
});
return [
'id' => $this->id,
'company_id' => $this->company_id,
'name' => $this->name,
'enabled' => $this->enabled,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'widgets' => [static::$wrap => Widget::collection($widgets)],
];
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\Http\Resources\Common;
use App\Http\Resources\Common\ItemTax;
use App\Http\Resources\Setting\Category;
use Illuminate\Http\Resources\Json\JsonResource;
class Item extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'name' => $this->name,
'description' => $this->description,
'sale_price' => $this->sale_price,
'sale_price_formatted' => money($this->sale_price, setting('default.currency'), true)->format(),
'purchase_price' => $this->purchase_price,
'purchase_price_formatted' => money($this->purchase_price, setting('default.currency'), true)->format(),
'category_id' => $this->category_id,
'picture' => $this->picture,
'enabled' => $this->enabled,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'taxes' => [static::$wrap => ItemTax::collection($this->taxes)],
'category' => new Category($this->category),
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources\Common;
use App\Http\Resources\Setting\Tax;
use Illuminate\Http\Resources\Json\JsonResource;
class ItemTax extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'item_id' => $this->item_id,
'tax_id' => $this->tax_id,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'tax' => new Tax($this->tax),
];
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace App\Http\Resources\Common;
use App\Utilities\Reports as Utility;
use Illuminate\Http\Resources\Json\JsonResource;
class Report extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'class' => $this->class,
'name' => $this->name,
'description' => $this->description,
'settings' => $this->settings,
'data' => $this->getReportData(),
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
protected function getReportData()
{
if (! Utility::canShow($this->class)) {
return [];
}
$report = Utility::getClassInstance($this);
if (empty($report)) {
return [];
}
$unset_attributes = ['model', 'views', 'loaded', 'column_name_width', 'column_value_width'];
foreach ($unset_attributes as $attribute) {
unset($report->$attribute);
}
return $report;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Resources\Common;
use Illuminate\Http\Resources\Json\JsonResource;
class Widget extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'dashboard_id' => $this->dashboard_id,
'class' => $this->class,
'name' => $this->name,
'sort' => $this->sort,
'settings' => $this->settings,
'data' => show_widget($this),
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace App\Http\Resources\Document;
use App\Http\Resources\Banking\Transaction;
use App\Http\Resources\Common\Contact;
use App\Http\Resources\Document\DocumentHistory;
use App\Http\Resources\Document\DocumentItem;
use App\Http\Resources\Document\DocumentItemTax;
use App\Http\Resources\Document\DocumentTotal;
use App\Http\Resources\Setting\Currency;
use Illuminate\Http\Resources\Json\JsonResource;
class Document extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'document_number' => $this->document_number,
'order_number' => $this->order_number,
'status' => $this->status,
'issued_at' => $this->issued_at ? $this->issued_at->toIso8601String() : '',
'due_at' => $this->due_at ? $this->due_at->toIso8601String() : '',
'amount' => $this->amount,
'amount_formatted' => money($this->amount, $this->currency_code, true)->format(),
'currency_code' => $this->currency_code,
'currency_rate' => $this->currency_rate,
'contact_id' => $this->contact_id,
'contact_name' => $this->contact_name,
'contact_email' => $this->contact_email,
'contact_tax_number' => $this->contact_tax_number,
'contact_phone' => $this->contact_phone,
'contact_address' => $this->contact_address,
'contact_city' => $this->contact_city,
'contact_zip_code' => $this->contact_zip_code,
'contact_state' => $this->contact_state,
'contact_country' => $this->contact_country,
'notes' => $this->notes,
'attachment' => $this->attachment,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'currency' => new Currency($this->currency),
'contact' => new Contact($this->contact),
'histories' => [static::$wrap => DocumentHistory::collection($this->histories)],
'items' => [static::$wrap => DocumentItem::collection($this->items)],
'item_taxes' => [static::$wrap => DocumentItemTax::collection($this->item_taxes)],
'totals' => [static::$wrap => DocumentTotal::collection($this->totals)],
'transactions' => [static::$wrap => Transaction::collection($this->transactions)],
];
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources\Document;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentHistory extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'document_id' => $this->document_id,
'status' => $this->status,
'notify' => $this->notify,
'description' => $this->description,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Http\Resources\Document;
use App\Http\Resources\Document\DocumentItemTax;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentItem extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'document_id' => $this->document_id,
'item_id' => $this->item_id,
'name' => $this->name,
'price' => $this->price,
'price_formatted' => money($this->price, $this->document->currency_code, true)->format(),
'total' => $this->total,
'total_formatted' => money($this->total, $this->document->currency_code, true)->format(),
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'taxes' => [static::$wrap => DocumentItemTax::collection($this->taxes)],
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Resources\Document;
use App\Http\Resources\Setting\Tax;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentItemTax extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'document_id' => $this->document_id,
'document_item_id' => $this->document_item_id,
'tax_id' => $this->tax_id,
'name' => $this->name,
'amount' => $this->amount,
'amount_formatted' => money($this->amount, $this->document->currency_code, true)->format(),
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
'tax' => new Tax($this->tax),
];
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Resources\Document;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentTotal extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'type' => $this->type,
'document_id' => $this->document_id,
'code' => $this->code,
'name' => $this->name,
'amount' => $this->amount,
'amount_formatted' => money($this->amount, $this->document->currency_code, true)->format(),
'sort_order' => $this->sort_order,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources\Setting;
use Illuminate\Http\Resources\Json\JsonResource;
class Category extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'name' => $this->name,
'type' => $this->type,
'color' => $this->color,
'enabled' => $this->enabled,
'parent_id' => $this->parent_id,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Resources\Setting;
use Illuminate\Http\Resources\Json\JsonResource;
class Currency extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'name' => $this->name,
'code' => $this->code,
'rate' => $this->rate,
'enabled' => $this->enabled,
'precision' => $this->precision,
'symbol' => $this->symbol,
'symbol_first' => $this->symbol_first,
'decimal_mark' => $this->decimal_mark,
'thousands_separator' => $this->thousands_separator,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Resources\Setting;
use Illuminate\Http\Resources\Json\JsonResource;
class Setting extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'key' => $this->key,
'value' => $this->value,
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Resources\Setting;
use Illuminate\Http\Resources\Json\JsonResource;
class Tax extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'name' => $this->name,
'rate' => $this->rate,
'enabled' => $this->enabled,
'created_from' => $this->created_from,
'created_by' => $this->created_by,
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
'updated_at' => $this->updated_at ? $this->updated_at->toIso8601String() : '',
];
}
}