mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 06:04:34 -04:00
Improvements for Wave imports
This commit is contained in:
parent
d6a4f4b4ca
commit
210a25b9ba
@ -85,7 +85,7 @@ class ImportController extends Controller
|
|||||||
$contents = $this->convertEncoding($contents);
|
$contents = $this->convertEncoding($contents);
|
||||||
|
|
||||||
// Store the csv in cache with an expiry of 10 minutes
|
// Store the csv in cache with an expiry of 10 minutes
|
||||||
Cache::put($hash.'-'.$entityType, base64_encode($contents), 600);
|
Cache::put($hash.'-'.$entityType, base64_encode($contents), 1200);
|
||||||
|
|
||||||
// Parse CSV
|
// Parse CSV
|
||||||
$csv_array = $this->getCsvData($contents);
|
$csv_array = $this->getCsvData($contents);
|
||||||
|
@ -98,7 +98,7 @@ class BaseImport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var string $base64_encoded_csv */
|
/** @var string $base64_encoded_csv */
|
||||||
$base64_encoded_csv = Cache::pull($this->hash.'-'.$entity_type);
|
$base64_encoded_csv = Cache::get($this->hash.'-'.$entity_type);
|
||||||
|
|
||||||
if (empty($base64_encoded_csv)) {
|
if (empty($base64_encoded_csv)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -172,7 +172,7 @@ class Wave extends BaseImport implements ImportInterface
|
|||||||
{
|
{
|
||||||
$entity_type = 'expense';
|
$entity_type = 'expense';
|
||||||
|
|
||||||
$data = $this->getCsvData($entity_type);
|
$data = $this->getCsvData('invoice');
|
||||||
|
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
$this->entity_count['expense'] = 0;
|
$this->entity_count['expense'] = 0;
|
||||||
@ -244,14 +244,17 @@ class Wave extends BaseImport implements ImportInterface
|
|||||||
if (empty($expense_data['vendor_id'])) {
|
if (empty($expense_data['vendor_id'])) {
|
||||||
$vendor_data['user_id'] = $this->getUserIDForRecord($expense_data);
|
$vendor_data['user_id'] = $this->getUserIDForRecord($expense_data);
|
||||||
|
|
||||||
$vendor_repository->save(
|
if(isset($raw_expense['Vendor Name']) || isset($raw_expense['Vendor']))
|
||||||
['name' => $raw_expense['Vendor Name']],
|
{
|
||||||
$vendor = VendorFactory::create(
|
$vendor_repository->save(
|
||||||
$this->company->id,
|
['name' => isset($raw_expense['Vendor Name']) ? $raw_expense['Vendor Name'] : isset($raw_expense['Vendor'])],
|
||||||
$vendor_data['user_id']
|
$vendor = VendorFactory::create(
|
||||||
)
|
$this->company->id,
|
||||||
);
|
$vendor_data['user_id']
|
||||||
$expense_data['vendor_id'] = $vendor->id;
|
)
|
||||||
|
);
|
||||||
|
$expense_data['vendor_id'] = $vendor->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$validator = Validator::make(
|
$validator = Validator::make(
|
||||||
|
@ -36,18 +36,26 @@ class ExpenseTransformer extends BaseTransformer
|
|||||||
$total_tax += floatval($record['Sales Tax Amount']);
|
$total_tax += floatval($record['Sales Tax Amount']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tax_rate = round(($total_tax / $amount) * 100, 3);
|
$tax_rate = $total_tax > 0 ? round(($total_tax / $amount) * 100, 3) : 0;
|
||||||
|
|
||||||
|
if(isset($data['Notes / Memo']) && strlen($data['Notes / Memo']) > 1)
|
||||||
|
$public_notes = $data['Notes / Memo'];
|
||||||
|
elseif (isset($data['Transaction Description']) && strlen($data['Transaction Description']) > 1)
|
||||||
|
$public_notes = $data['Transaction Description'];
|
||||||
|
else
|
||||||
|
$public_notes = '';
|
||||||
|
|
||||||
|
|
||||||
$transformed = [
|
$transformed = [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'vendor_id' => $this->getVendorIdOrCreate($this->getString($data, 'Vendor')),
|
'vendor_id' => $this->getVendorIdOrCreate($this->getString($data, 'Vendor')),
|
||||||
'number' => $this->getString($data, 'Bill Number'),
|
'number' => $this->getString($data, 'Bill Number'),
|
||||||
'public_notes' => $this->getString($data, 'Notes / Memo'),
|
'public_notes' => $public_notes,
|
||||||
'date' => $this->parseDate($data['Transaction Date Added']) ?: now()->format('Y-m-d'), //27-01-2022
|
'date' => $this->parseDate($data['Transaction Date Added']) ?: now()->format('Y-m-d'), //27-01-2022
|
||||||
'currency_id' => $this->company->settings->currency_id,
|
'currency_id' => $this->company->settings->currency_id,
|
||||||
'category_id' => $this->getOrCreateExpenseCategry($data['Account Name']),
|
'category_id' => $this->getOrCreateExpenseCategry($data['Account Name']),
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'tax_name1' => $data['Sales Tax Name'],
|
'tax_name1' => isset($data['Sales Tax Name']) ? $data['Sales Tax Name'] : '',
|
||||||
'tax_rate1' => $tax_rate,
|
'tax_rate1' => $tax_rate,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user