1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Transformers/InvoiceItemTransformer.php

38 lines
1.3 KiB
PHP
Raw Normal View History

2019-04-02 07:16:39 +02:00
<?php
2019-05-11 05:32:07 +02:00
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
2019-04-02 07:16:39 +02:00
namespace App\Transformers;
class InvoiceItemTransformer extends EntityTransformer
{
2019-04-02 07:16:39 +02:00
public function transform($item)
{
return [
2019-04-03 02:09:22 +02:00
'id' => (int) $item->id,
2019-04-02 07:16:39 +02:00
'product_key' => $item->product_key,
'updated_at' => $item->updated_at,
'archived_at' => $item->deleted_at,
2019-09-27 00:14:02 +02:00
'notes' => $item->notes ?: '',
'cost' => (float) $item->cost ?: '',
'quantity' => (float) ($item->quantity ?: 0.0),
2019-04-02 07:16:39 +02:00
'tax_name1' => $item->tax_name1 ? $item->tax_name1 : '',
'tax_rate1' => (float) ($item->tax_rate1 ?: 0.0),
'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '',
'tax_rate2' => (float) ($item->tax_rate2 ?: 0.0),
2019-09-27 00:14:02 +02:00
'invoice_item_type_id' => (string) $item->invoice_item_type_id ?: '',
2019-04-02 07:16:39 +02:00
'custom_value1' => $item->custom_value1 ?: '',
'custom_value2' => $item->custom_value2 ?: '',
2019-09-27 00:14:02 +02:00
'discount' => (float) $item->discount ?: '',
2019-04-02 07:16:39 +02:00
];
}
}