Files
InvoiceShelf/app/Http/Resources/TaxResource.php
mchev bf5b544ca3 Adding Flat Tax support with fixed amount (#253)
* Possibility to set a fixed amount on tax types settings

* Pint and manage flat taxes on items

* Fix display errors and handle global taxes

* Tests

* Pint with PHP 8.2 cause with PHP 8.3 version it cause workflow error

* Merging percent and fixed amount into one column

* Now display the currency on SelectTaxPopup on fixed taxes
2025-05-04 02:24:56 +02:00

44 lines
1.5 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class TaxResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'tax_type_id' => $this->tax_type_id,
'invoice_id' => $this->invoice_id,
'estimate_id' => $this->estimate_id,
'invoice_item_id' => $this->invoice_item_id,
'estimate_item_id' => $this->estimate_item_id,
'item_id' => $this->item_id,
'company_id' => $this->company_id,
'name' => $this->name,
'amount' => $this->amount,
'percent' => $this->percent,
'calculation_type' => $this->calculation_type,
'fixed_amount' => $this->fixed_amount,
'compound_tax' => $this->compound_tax,
'base_amount' => $this->base_amount,
'currency_id' => $this->currency_id,
'type' => $this->taxType->type,
'recurring_invoice_id' => $this->recurring_invoice_id,
'tax_type' => $this->when($this->taxType()->exists(), function () {
return new TaxTypeResource($this->taxType);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}