invoiceninja/app/Ninja/Import/CSV/PaymentTransformer.php

30 lines
668 B
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Import\CSV;
2015-11-24 21:45:38 +02:00
2015-12-08 12:10:20 +02:00
use App\Ninja\Import\BaseTransformer;
2015-11-24 21:45:38 +02:00
use League\Fractal\Resource\Item;
/**
2017-01-30 21:40:43 +02:00
* Class PaymentTransformer.
*/
2015-12-08 12:10:20 +02:00
class PaymentTransformer extends BaseTransformer
2015-11-24 21:45:38 +02:00
{
/**
* @param $data
2017-01-30 21:40:43 +02:00
*
* @return Item
*/
2015-12-08 12:10:20 +02:00
public function transform($data)
2015-11-24 21:45:38 +02:00
{
2015-12-08 12:10:20 +02:00
return new Item($data, function ($data) {
2015-11-24 21:45:38 +02:00
return [
2016-12-22 19:17:45 +02:00
'amount' => $this->getFloat($data, 'paid'),
2015-11-24 22:41:08 +02:00
'payment_date_sql' => isset($data->invoice_date) ? $data->invoice_date : null,
2015-11-24 21:45:38 +02:00
'client_id' => $data->client_id,
'invoice_id' => $data->invoice_id,
2015-11-24 21:45:38 +02:00
];
});
}
2016-12-22 19:17:45 +02:00
}