1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Improve quote document imports

This commit is contained in:
David Bomba 2021-02-14 20:25:19 +11:00
parent ac2c7b2bbe
commit 575a3b3190
2 changed files with 27 additions and 4 deletions

View File

@ -389,8 +389,8 @@ class CheckData extends Command
$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance'); $invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
$credit_balance = $client->credits->where('is_deleted', false)->sum('balance'); $credit_balance = $client->credits->where('is_deleted', false)->sum('balance');
if($client->balance != $invoice_balance) // if($client->balance != $invoice_balance)
$invoice_balance -= $credit_balance;//doesn't make sense to remove the credit amount // $invoice_balance -= $credit_balance;//doesn't make sense to remove the credit amount
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first(); $ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();

View File

@ -1029,9 +1029,32 @@ class Import implements ShouldQueue
} }
if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && array_key_exists('invoices', $this->ids)) { if (array_key_exists('invoice_id', $resource) && $resource['invoice_id'] && array_key_exists('invoices', $this->ids)) {
$try_quote = false;
$exception = null;
try{
$invoice_id = $this->transformId('invoices', $resource['invoice_id']); $invoice_id = $this->transformId('invoices', $resource['invoice_id']);
$entity = Invoice::where('id', $invoice_id)->withTrashed()->first(); $entity = Invoice::where('id', $invoice_id)->withTrashed()->first();
} }
catch(\Exception $e){
$try_quote = true;
}
if($try_quote) {
$quote_id = $this->transformId('quotes', $resource['invoice_id']);
$entity = Quote::where('id', $quote_id)->withTrashed()->first();
$exception = $e;
}
if($exception)
throw new Exception("Resource invoice/quote document not available.");
}
if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && array_key_exists('expenses', $this->ids)) { if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && array_key_exists('expenses', $this->ids)) {
$expense_id = $this->transformId('expenses', $resource['expense_id']); $expense_id = $this->transformId('expenses', $resource['expense_id']);