Merge inclusive tax fix

This commit is contained in:
Hillel Coren 2017-03-24 14:53:54 +03:00
parent ec5bfb4129
commit 58af36b2d2

View File

@ -286,12 +286,13 @@ class InvoiceController extends BaseController
} }
// Check for any taxes which have been deleted // Check for any taxes which have been deleted
$taxRateOptions = $account->present()->taxRateOptions;
if ($invoice->exists) { if ($invoice->exists) {
foreach ($invoice->getTaxes() as $key => $rate) { foreach ($invoice->getTaxes() as $key => $rate) {
if (isset($options[$key])) { if (isset($taxRateOptions[$key])) {
continue; continue;
} }
$options['0 ' . $key] = $rate['name'] . ' ' . $rate['rate'] . '%'; $taxRateOptions['0 ' . $key] = $rate['name'] . ' ' . $rate['rate'] . '%';
} }
} }
@ -299,7 +300,7 @@ class InvoiceController extends BaseController
'data' => Input::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account->load('country'), 'account' => Auth::user()->account->load('country'),
'products' => Product::scope()->with('default_tax_rate')->orderBy('product_key')->get(), 'products' => Product::scope()->with('default_tax_rate')->orderBy('product_key')->get(),
'taxRateOptions' => $account->present()->taxRateOptions, 'taxRateOptions' => $taxRateOptions,
'defaultTax' => $account->default_tax_rate, 'defaultTax' => $account->default_tax_rate,
'currencies' => Cache::get('currencies'), 'currencies' => Cache::get('currencies'),
'sizes' => Cache::get('sizes'), 'sizes' => Cache::get('sizes'),
@ -401,7 +402,7 @@ class InvoiceController extends BaseController
if ($invoice->is_recurring) { if ($invoice->is_recurring) {
$response = $this->emailRecurringInvoice($invoice); $response = $this->emailRecurringInvoice($invoice);
} else { } else {
$this->dispatch(new SendInvoiceEmail($invoice, $reminder, $pdfUpload, $template)); $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $template));
$response = true; $response = true;
} }
@ -433,13 +434,8 @@ class InvoiceController extends BaseController
if ($invoice->isPaid()) { if ($invoice->isPaid()) {
return true; return true;
} else { } else {
// TODO remove this with Laravel 5.3 (https://github.com/invoiceninja/invoiceninja/issues/1303) $this->dispatch(new SendInvoiceEmail($invoice));
if (config('queue.default') === 'sync') { return true;
return app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
} else {
$this->dispatch(new SendInvoiceEmail($invoice));
return true;
}
} }
} }
@ -469,7 +465,6 @@ class InvoiceController extends BaseController
public function bulk($entityType = ENTITY_INVOICE) public function bulk($entityType = ENTITY_INVOICE)
{ {
$action = Input::get('bulk_action') ?: Input::get('action'); $action = Input::get('bulk_action') ?: Input::get('action');
;
$ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids')); $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
$count = $this->invoiceService->bulk($ids, $action); $count = $this->invoiceService->bulk($ids, $action);
@ -487,6 +482,10 @@ class InvoiceController extends BaseController
Session::flash('message', $message); Session::flash('message', $message);
} }
if (strpos(\Request::server('HTTP_REFERER'), 'recurring_invoices')) {
$entityType = ENTITY_RECURRING_INVOICE;
}
return $this->returnBulk($entityType, $action, $ids); return $this->returnBulk($entityType, $action, $ids);
} }