1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/Ninja/Import/Harvest/InvoiceTransformer.php

35 lines
1.0 KiB
PHP
Raw Normal View History

<?php namespace App\Ninja\Import\Harvest;
2015-12-08 11:10:20 +01:00
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
2015-12-08 11:10:20 +01:00
class InvoiceTransformer extends BaseTransformer
{
2015-12-08 11:10:20 +01:00
public function transform($data)
{
2015-12-08 11:10:20 +01:00
if ( ! $this->getClientId($data->client)) {
return false;
}
2015-12-08 11:10:20 +01:00
if ($this->hasInvoice($data->id)) {
return false;
}
2015-12-08 11:10:20 +01:00
return new Item($data, function ($data) {
return [
2015-12-08 11:10:20 +01:00
'client_id' => $this->getClientId($data->client),
2015-12-10 14:35:40 +01:00
'invoice_number' => $this->getInvoiceNumber($data->id),
'paid' => (float) $data->paid_amount,
'po_number' => $data->po_number,
2015-12-08 11:10:20 +01:00
'invoice_date_sql' => $this->getDate($data->issue_date, 'm/d/Y'),
'invoice_items' => [
[
'notes' => $data->subject,
'cost' => (float) $data->invoice_amount,
'qty' => 1,
]
],
];
});
}
}