mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 21:52:35 +01:00
19080933b6
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the code style applied by adding a [PHP CS Fixer][1] or [PHP CodeSniffer][2] ruleset to your project root. Feel free to use [Shift's Laravel ruleset][3] to help you get started. For more information on customizing the code style applied by Shift, [watch this short video][4]. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://github.com/squizlabs/PHP_CodeSniffer [3]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 [4]: https://laravelshift.com/videos/shift-code-style
43 lines
2.2 KiB
PHP
43 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Import\Transformers\Csv;
|
|
|
|
use App\Import\Transformers\BaseTransformer;
|
|
|
|
/**
|
|
* Class InvoiceTransformer.
|
|
*/
|
|
class ExpenseTransformer extends BaseTransformer
|
|
{
|
|
/**
|
|
* @param $data
|
|
*
|
|
* @return bool|array
|
|
*/
|
|
public function transform($data)
|
|
{
|
|
$clientId = isset($data['expense.client']) ? $this->getClientId($data['expense.client']) : null;
|
|
|
|
return [
|
|
'company_id' => $this->maps['company']->id,
|
|
'amount' => $this->getFloat($data, 'expense.amount'),
|
|
'currency_id' => $this->getCurrencyByCode($data, 'expense.currency_id'),
|
|
'vendor_id' => isset($data['expense.vendor']) ? $this->getVendorId($data['expense.vendor']) : null,
|
|
'client_id' => isset($data['expense.client']) ? $this->getClientId($data['expense.client']) : null,
|
|
'date' => isset($data['expense.date']) ? date('Y-m-d', strtotime($data['expense.date'])) : null,
|
|
'public_notes' => $this->getString($data, 'expense.public_notes'),
|
|
'private_notes' => $this->getString($data, 'expense.private_notes'),
|
|
'category_id' => isset($data['expense.category']) ? $this->getExpenseCategoryId($data['expense.category']) : null,
|
|
'project_id' => isset($data['expense.project']) ? $this->getProjectId($data['expense.project']) : null,
|
|
'payment_type_id' => isset($data['expense.payment_type']) ? $this->getPaymentTypeId($data['expense.payment_type']) : null,
|
|
'payment_date' => isset($data['expense.payment_date']) ? date('Y-m-d', strtotime($data['expense.payment_date'])) : null,
|
|
'custom_value1' => $this->getString($data, 'expense.custom_value1'),
|
|
'custom_value2' => $this->getString($data, 'expense.custom_value2'),
|
|
'custom_value3' => $this->getString($data, 'expense.custom_value3'),
|
|
'custom_value4' => $this->getString($data, 'expense.custom_value4'),
|
|
'transaction_reference' => $this->getString($data, 'expense.transaction_reference'),
|
|
'should_be_invoiced' => $clientId ? true : false,
|
|
];
|
|
}
|
|
}
|