Improving CSV Expense imports

This commit is contained in:
David Bomba 2022-10-06 14:28:57 +11:00
parent b88e47e9d2
commit 3c4dd84a4f
4 changed files with 32 additions and 6 deletions

View File

@ -28,6 +28,15 @@ class ExpenseMap
9 => 'expense.transaction_reference', 9 => 'expense.transaction_reference',
10 => 'expense.public_notes', 10 => 'expense.public_notes',
11 => 'expense.private_notes', 11 => 'expense.private_notes',
12 => 'expense.tax_name1',
13 => 'expense.tax_rate1',
14 => 'expense.tax_name2',
15 => 'expense.tax_rate2',
16 => 'expense.tax_name3',
17 => 'expense.tax_rate3',
18 => 'expense.uses_inclusive_taxes',
19 => 'expense.payment_date',
]; ];
} }
@ -46,6 +55,15 @@ class ExpenseMap
9 => 'texts.transaction_reference', 9 => 'texts.transaction_reference',
10 => 'texts.public_notes', 10 => 'texts.public_notes',
11 => 'texts.private_notes', 11 => 'texts.private_notes',
12 => 'texts.tax_name1',
13 => 'texts.tax_rate1',
14 => 'texts.tax_name2',
15 => 'texts.tax_rate2',
16 => 'texts.tax_name3',
17 => 'texts.tax_rate3',
18 => 'texts.uses_inclusive_taxes',
19 => 'texts.payment_date',
]; ];
} }
} }

View File

@ -42,7 +42,7 @@ class ExpenseTransformer extends BaseTransformer
'client_id' => isset($data['expense.client']) 'client_id' => isset($data['expense.client'])
? $this->getClientId($data['expense.client']) ? $this->getClientId($data['expense.client'])
: null, : null,
'date' => strlen($this->getString($data, 'expense.date') > 1) ? date('Y-m-d', strtotime($data['expense.date'])) : now()->format('Y-m-d'), 'date' => strlen($this->getString($data, 'expense.date') > 1) ? date('Y-m-d', strtotime(str_replace("/","-",$data['expense.date']))) : now()->format('Y-m-d'),
'public_notes' => $this->getString($data, 'expense.public_notes'), 'public_notes' => $this->getString($data, 'expense.public_notes'),
'private_notes' => $this->getString($data, 'expense.private_notes'), 'private_notes' => $this->getString($data, 'expense.private_notes'),
'category_id' => isset($data['expense.category']) 'category_id' => isset($data['expense.category'])
@ -55,7 +55,7 @@ class ExpenseTransformer extends BaseTransformer
? $this->getPaymentTypeId($data['expense.payment_type']) ? $this->getPaymentTypeId($data['expense.payment_type'])
: null, : null,
'payment_date' => isset($data['expense.payment_date']) 'payment_date' => isset($data['expense.payment_date'])
? date('Y-m-d', strtotime($data['expense.payment_date'])) ? date('Y-m-d', strtotime(str_replace("/","-",$data['expense.payment_date'])))
: null, : null,
'custom_value1' => $this->getString($data, 'expense.custom_value1'), 'custom_value1' => $this->getString($data, 'expense.custom_value1'),
'custom_value2' => $this->getString($data, 'expense.custom_value2'), 'custom_value2' => $this->getString($data, 'expense.custom_value2'),
@ -66,6 +66,14 @@ class ExpenseTransformer extends BaseTransformer
'expense.transaction_reference' 'expense.transaction_reference'
), ),
'should_be_invoiced' => $clientId ? true : false, 'should_be_invoiced' => $clientId ? true : false,
'uses_inclusive_taxes' => (bool) $this->getString($data, 'expense.uses_inclusive_taxes'),
'tax_name1' => $this->getString($data, 'expense.tax_name1'),
'tax_rate1' => $this->getFloat($data, 'expense.tax_rate1'),
'tax_name2' => $this->getString($data, 'expense.tax_name2'),
'tax_rate2' => $this->getFloat($data, 'expense.tax_rate2'),
'tax_name3' => $this->getString($data, 'expense.tax_name3'),
'tax_rate3' => $this->getFloat($data, 'expense.tax_rate3'),
]; ];
} }
} }

View File

@ -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($invoice_data['invoice.date'])) ? date('Y-m-d', strtotime(str_replace("/","-",$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($invoice_data['invoice.due_date'])) ? date('Y-m-d', strtotime(str_replace("/","-",$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(

View File

@ -57,10 +57,10 @@ class QuoteTransformer extends BaseTransformer
'discount' => $this->getFloat($quote_data, 'quote.discount'), 'discount' => $this->getFloat($quote_data, 'quote.discount'),
'po_number' => $this->getString($quote_data, 'quote.po_number'), 'po_number' => $this->getString($quote_data, 'quote.po_number'),
'date' => isset($quote_data['quote.date']) 'date' => isset($quote_data['quote.date'])
? date('Y-m-d', strtotime($quote_data['quote.date'])) ? date('Y-m-d', strtotime(str_replace("/","-",$quote_data['quote.date'])))
: now()->format('Y-m-d'), : now()->format('Y-m-d'),
'due_date' => isset($quote_data['quote.due_date']) 'due_date' => isset($quote_data['quote.due_date'])
? date('Y-m-d', strtotime($quote_data['quote.due_date'])) ? date('Y-m-d', strtotime(str_replace("/","-",$quote_data['quote.due_date'])))
: null, : null,
'terms' => $this->getString($quote_data, 'quote.terms'), 'terms' => $this->getString($quote_data, 'quote.terms'),
'public_notes' => $this->getString( 'public_notes' => $this->getString(