2017-01-30 21:40:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Ninja\Import\Wave;
|
2015-12-31 16:11:44 +02:00
|
|
|
|
|
|
|
|
use App\Ninja\Import\BaseTransformer;
|
|
|
|
|
use League\Fractal\Resource\Item;
|
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-01-30 21:40:43 +02:00
|
|
|
* Class PaymentTransformer.
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2015-12-31 16:11:44 +02:00
|
|
|
class PaymentTransformer extends BaseTransformer
|
|
|
|
|
{
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
|
* @param $data
|
2017-01-30 21:40:43 +02:00
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @return bool|Item
|
|
|
|
|
*/
|
2016-06-02 22:03:59 +03:00
|
|
|
public function transform($data)
|
2015-12-31 16:11:44 +02:00
|
|
|
{
|
2017-01-30 18:05:31 +02:00
|
|
|
if (! $this->getInvoiceClientId($data->invoice_num)) {
|
2015-12-31 16:11:44 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-06-02 22:03:59 +03:00
|
|
|
|
|
|
|
|
return new Item($data, function ($data) {
|
2015-12-31 16:11:44 +02:00
|
|
|
return [
|
|
|
|
|
'amount' => (float) $data->amount,
|
2017-01-15 21:48:31 +02:00
|
|
|
'payment_date_sql' => $this->getDate($data, 'payment_date'),
|
2015-12-31 16:11:44 +02:00
|
|
|
'client_id' => $this->getInvoiceClientId($data->invoice_num),
|
|
|
|
|
'invoice_id' => $this->getInvoiceId($data->invoice_num),
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-06-02 22:03:59 +03:00
|
|
|
}
|