1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 06:32:40 +01:00
invoiceninja/app/Ninja/Import/Harvest/PaymentTransformer.php
2015-12-07 23:41:48 +02:00

23 lines
685 B
PHP

<?php namespace App\Ninja\Import\Harvest;
use League\Fractal\TransformerAbstract;
use League\Fractal\Resource\Item;
use DateTime;
class PaymentTransformer extends TransformerAbstract
{
public function transform($data, $maps)
{
return new Item($data, function ($data) use ($maps) {
$paymentDate = DateTime::createFromFormat('m/d/Y', $data->last_payment_date);
return [
'amount' => $data->paid_amount,
'payment_date_sql' => $paymentDate ? $paymentDate->format('Y-m-d') : null,
'client_id' => $data->client_id,
'invoice_id' => $data->invoice_id,
];
});
}
}