akaunting 3.0 (the last dance)
This commit is contained in:
38
app/Http/Resources/Banking/Account.php
Normal file
38
app/Http/Resources/Banking/Account.php
Normal 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() : '',
|
||||
];
|
||||
}
|
||||
}
|
34
app/Http/Resources/Banking/Reconciliation.php
Normal file
34
app/Http/Resources/Banking/Reconciliation.php
Normal 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),
|
||||
];
|
||||
}
|
||||
}
|
50
app/Http/Resources/Banking/Transaction.php
Normal file
50
app/Http/Resources/Banking/Transaction.php
Normal 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),
|
||||
];
|
||||
}
|
||||
}
|
37
app/Http/Resources/Banking/Transfer.php
Normal file
37
app/Http/Resources/Banking/Transfer.php
Normal 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() : '',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user