mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:44:32 -04:00
Fixes for imports - date formating
This commit is contained in:
parent
9e8edad92c
commit
befc9170fb
@ -44,6 +44,30 @@ class BaseTransformer
|
|||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function parseDate($date)
|
||||||
|
{
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
$parsed_date = Carbon::parse($date);
|
||||||
|
|
||||||
|
return $parsed_date->format('Y-m-d');
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(\Exception $e){
|
||||||
|
|
||||||
|
$parsed_date = date('Y-m-d', strtotime($date));
|
||||||
|
|
||||||
|
if($parsed_date == '1970-01-01')
|
||||||
|
return now()->format('Y-m-d');
|
||||||
|
|
||||||
|
return $parsed_date;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function getString($data, $field)
|
public function getString($data, $field)
|
||||||
{
|
{
|
||||||
return isset($data[$field]) && $data[$field] ? trim($data[$field]) : '';
|
return isset($data[$field]) && $data[$field] ? trim($data[$field]) : '';
|
||||||
|
@ -57,10 +57,10 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
'discount' => $this->getFloat($invoice_data, 'invoice.discount'),
|
'discount' => $this->getFloat($invoice_data, 'invoice.discount'),
|
||||||
'po_number' => $this->getString($invoice_data, 'invoice.po_number'),
|
'po_number' => $this->getString($invoice_data, 'invoice.po_number'),
|
||||||
'date' => isset($invoice_data['invoice.date'])
|
'date' => isset($invoice_data['invoice.date'])
|
||||||
? date('Y-m-d', strtotime(str_replace("/","-",$invoice_data['invoice.date'])))
|
? $this->parseDate($invoice_data['invoice.date'])
|
||||||
: now()->format('Y-m-d'),
|
: now()->format('Y-m-d'),
|
||||||
'due_date' => isset($invoice_data['invoice.due_date'])
|
'due_date' => isset($invoice_data['invoice.due_date'])
|
||||||
? date('Y-m-d', strtotime(str_replace("/","-",$invoice_data['invoice.due_date'])))
|
? $this->parseDate($invoice_data['invoice.due_date'])
|
||||||
: null,
|
: null,
|
||||||
'terms' => $this->getString($invoice_data, 'invoice.terms'),
|
'terms' => $this->getString($invoice_data, 'invoice.terms'),
|
||||||
'public_notes' => $this->getString(
|
'public_notes' => $this->getString(
|
||||||
@ -140,10 +140,7 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
$transformed['payments'] = [
|
$transformed['payments'] = [
|
||||||
[
|
[
|
||||||
'date' => isset($invoice_data['payment.date'])
|
'date' => isset($invoice_data['payment.date'])
|
||||||
? date(
|
? $this->parseDate($invoice_data['payment.date'])
|
||||||
'Y-m-d',
|
|
||||||
strtotime($invoice_data['payment.date'])
|
|
||||||
)
|
|
||||||
: date('y-m-d'),
|
: date('y-m-d'),
|
||||||
'transaction_reference' => $this->getString(
|
'transaction_reference' => $this->getString(
|
||||||
$invoice_data,
|
$invoice_data,
|
||||||
@ -159,10 +156,7 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
$transformed['payments'] = [
|
$transformed['payments'] = [
|
||||||
[
|
[
|
||||||
'date' => isset($invoice_data['payment.date'])
|
'date' => isset($invoice_data['payment.date'])
|
||||||
? date(
|
? $this->parseDate($invoice_data['payment.date'])
|
||||||
'Y-m-d',
|
|
||||||
strtotime($invoice_data['payment.date'])
|
|
||||||
)
|
|
||||||
: date('y-m-d'),
|
: date('y-m-d'),
|
||||||
'transaction_reference' => $this->getString(
|
'transaction_reference' => $this->getString(
|
||||||
$invoice_data,
|
$invoice_data,
|
||||||
@ -182,10 +176,7 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
$transformed['payments'] = [
|
$transformed['payments'] = [
|
||||||
[
|
[
|
||||||
'date' => isset($invoice_data['payment.date'])
|
'date' => isset($invoice_data['payment.date'])
|
||||||
? date(
|
? $this->parseDate($invoice_data['payment.date'])
|
||||||
'Y-m-d',
|
|
||||||
strtotime($invoice_data['payment.date'])
|
|
||||||
)
|
|
||||||
: date('y-m-d'),
|
: date('y-m-d'),
|
||||||
'transaction_reference' => $this->getString(
|
'transaction_reference' => $this->getString(
|
||||||
$invoice_data,
|
$invoice_data,
|
||||||
|
@ -23,6 +23,7 @@ use App\Libraries\MultiDB;
|
|||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
|
use App\Utils\Ninja;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@ -81,6 +82,10 @@ class CSVIngest implements ShouldQueue
|
|||||||
$engine->finalizeImport();
|
$engine->finalizeImport();
|
||||||
|
|
||||||
$this->checkContacts();
|
$this->checkContacts();
|
||||||
|
|
||||||
|
if(Ninja::isHosted())
|
||||||
|
app('queue.worker')->shouldQuit = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkContacts()
|
private function checkContacts()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user