2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Import\Ronin;
|
2015-12-10 14:35:40 +01:00
|
|
|
|
|
|
|
use App\Ninja\Import\BaseTransformer;
|
|
|
|
use League\Fractal\Resource\Item;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class PaymentTransformer.
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2015-12-10 14:35:40 +01:00
|
|
|
class PaymentTransformer extends BaseTransformer
|
|
|
|
{
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @param $data
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @return Item
|
|
|
|
*/
|
2016-06-02 21:03:59 +02:00
|
|
|
public function transform($data)
|
2015-12-10 14:35:40 +01:00
|
|
|
{
|
2016-06-02 21:03:59 +02:00
|
|
|
return new Item($data, function ($data) {
|
2015-12-10 14:35:40 +01:00
|
|
|
return [
|
|
|
|
'amount' => (float) $data->total - (float) $data->balance,
|
|
|
|
'payment_date_sql' => $data->date_paid,
|
|
|
|
'client_id' => $data->client_id,
|
2015-12-31 15:14:30 +01:00
|
|
|
'invoice_id' => $data->invoice_id,
|
2015-12-10 14:35:40 +01:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2016-06-02 21:03:59 +02:00
|
|
|
}
|