invoiceninja/app/Ninja/Transformers/InvoiceItemTransformer.php

30 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Transformers;
2015-11-03 16:21:17 +02:00
use App\Models\InvoiceItem;
2015-11-08 23:12:50 +02:00
class InvoiceItemTransformer extends EntityTransformer
2015-11-03 16:21:17 +02:00
{
public function transform(InvoiceItem $item)
{
2016-05-03 23:02:29 +03:00
return array_merge($this->getDefaults($item), [
2015-11-15 21:43:32 +11:00
'id' => (int) $item->public_id,
2015-11-03 16:21:17 +02:00
'product_key' => $item->product_key,
2015-12-27 13:08:58 +02:00
'updated_at' => $this->getTimestamp($item->updated_at),
'archived_at' => $this->getTimestamp($item->deleted_at),
2015-11-07 23:15:37 +11:00
'notes' => $item->notes,
'cost' => (float) $item->cost,
'qty' => (float) $item->qty,
2016-04-08 21:25:06 +10:00
'tax_name1' => $item->tax_name1 ? $item->tax_name1 : '',
2016-03-31 12:29:01 +03:00
'tax_rate1' => (float) $item->tax_rate1,
2016-07-16 07:52:00 +10:00
'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '',
2016-03-31 12:29:01 +03:00
'tax_rate2' => (float) $item->tax_rate2,
2017-03-26 12:55:47 +03:00
'invoice_item_type_id' => (int) $item->invoice_item_type_id,
2017-09-20 11:33:58 +10:00
'custom_value1' => $item->custom_value1,
'custom_value2' => $item->custom_value2,
2017-12-21 19:56:07 +02:00
'discount' => (float) $item->discount,
2016-05-03 23:02:29 +03:00
]);
2015-11-03 16:21:17 +02:00
}
2016-07-16 07:52:00 +10:00
}