diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 42737940bbe8..ec6e3e78f171 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -110,7 +110,8 @@ class AccountController extends BaseController Auth::login($user, true); Event::fire(new UserLoggedIn()); - return Redirect::to('invoices/create')->with('sign_up', Input::get('sign_up')); + $redirectTo = Input::get('redirect_to', 'invoices/create'); + return Redirect::to($redirectTo)->with('sign_up', Input::get('sign_up')); } public function enableProPlan() @@ -235,7 +236,7 @@ class AccountController extends BaseController $data['invoice'] = $invoice; $data['invoiceLabels'] = json_decode($account->invoice_labels) ?: []; $data['title'] = trans('texts.invoice_design'); - $data['invoiceDesigns'] = InvoiceDesign::getDesigns($subSection == ACCOUNT_CUSTOMIZE_DESIGN); + $data['invoiceDesigns'] = InvoiceDesign::getDesigns(); $design = false; foreach ($data['invoiceDesigns'] as $item) { @@ -301,11 +302,6 @@ class AccountController extends BaseController $account = Auth::user()->account; $account->custom_design = Input::get('custom_design'); $account->invoice_design_id = CUSTOM_DESIGN; - - if (!$account->utf8_invoices) { - $account->utf8_invoices = true; - } - $account->save(); Session::flash('message', trans('texts.updated_settings')); @@ -365,7 +361,6 @@ class AccountController extends BaseController $account->share_counter = Input::get('share_counter') ? true : false; $account->pdf_email_attachment = Input::get('pdf_email_attachment') ? true : false; - $account->utf8_invoices = Input::get('utf8_invoices') ? true : false; $account->auto_wrap = Input::get('auto_wrap') ? true : false; if (!$account->share_counter) { @@ -706,9 +701,9 @@ class AccountController extends BaseController $image = Image::make($path); $mimeType = $file->getMimeType(); - if ($mimeType == 'image/jpeg' && $account->utf8_invoices) { + if ($mimeType == 'image/jpeg') { $file->move('logo/', $account->account_key . '.jpg'); - } else if ($mimeType == 'image/png' && $account->utf8_invoices) { + } else if ($mimeType == 'image/png') { $file->move('logo/', $account->account_key . '.png'); } else { $image->resize(200, 120, function ($constraint) { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 0f8226f077b1..1308a4378b26 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -50,7 +50,8 @@ class HomeController extends BaseController } if (Auth::check()) { - return Redirect::to('invoices/create')->with('sign_up', Input::get('sign_up')); + $redirectTo = Input::get('redirect_to', 'invoices/create'); + return Redirect::to($redirectTo)->with('sign_up', Input::get('sign_up')); } else { return View::make('public.header', ['invoiceNow' => true]); } diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 6426333f1d5b..430280ddc849 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -214,7 +214,7 @@ class InvoiceController extends BaseController if ($invoice->invoice_design_id == CUSTOM_DESIGN) { $invoice->invoice_design->javascript = $account->custom_design; - } elseif ($account->utf8_invoices) { + } else { $invoice->invoice_design->javascript = $invoice->invoice_design->pdfmake; } diff --git a/app/Models/Account.php b/app/Models/Account.php index 243715ceaadd..7df9c09b2410 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -12,10 +12,12 @@ class Account extends Eloquent use SoftDeletes; protected $dates = ['deleted_at']; + /* protected $casts = [ - 'utf8_invoice' => 'boolean', + 'hide_quantity' => 'boolean', ]; - + */ + public function users() { return $this->hasMany('App\Models\User'); @@ -153,7 +155,7 @@ class Account extends Eloquent { $fileName = 'logo/' . $this->account_key; - return file_exists($fileName.'.png') && $this->utf8_invoices ? $fileName.'.png' : $fileName.'.jpg'; + return file_exists($fileName.'.png') ? $fileName.'.png' : $fileName.'.jpg'; } public function getLogoWidth() @@ -427,11 +429,4 @@ class Account extends Eloquent { return $this->token_billing_type_id == TOKEN_BILLING_OPT_OUT; } -} - -Account::updating(function ($account) { - // Lithuanian requires UTF8 support - if (!Utils::isPro() && $account->language_id == 13) { - $account->utf8_invoices = true; - } -}); +} \ No newline at end of file diff --git a/app/Models/InvoiceDesign.php b/app/Models/InvoiceDesign.php index d7682c24f742..2b53ac6383c7 100644 --- a/app/Models/InvoiceDesign.php +++ b/app/Models/InvoiceDesign.php @@ -9,24 +9,21 @@ class InvoiceDesign extends Eloquent { public $timestamps = false; - public static function getDesigns($forceUtf8 = false) + public static function getDesigns() { $account = Auth::user()->account; $designs = Cache::get('invoiceDesigns'); - $utf8 = $forceUtf8 || $account->utf8_invoices; foreach ($designs as $design) { if ($design->id > Auth::user()->maxInvoiceDesignId()) { $designs->pull($design->id); } - - if ($utf8) { - $design->javascript = $design->pdfmake; - } + + $design->javascript = $design->pdfmake; $design->pdfmake = null; if ($design->id == CUSTOM_DESIGN) { - if ($utf8 && $account->custom_design) { + if ($account->custom_design) { $design->javascript = $account->custom_design; } else { $designs->pop(); diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index bfbf62658f45..cde24e302dfd 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -315,6 +315,7 @@ class InvoiceRepository } $total = 0; + $itemTax = 0; foreach ($data['invoice_items'] as $item) { $item = (array) $item; @@ -324,15 +325,29 @@ class InvoiceRepository $invoiceItemCost = round(Utils::parseFloat($item['cost']), 2); $invoiceItemQty = round(Utils::parseFloat($item['qty']), 2); - $invoiceItemTaxRate = 0; - - if (isset($item['tax_rate']) && Utils::parseFloat($item['tax_rate']) > 0) { - $invoiceItemTaxRate = Utils::parseFloat($item['tax_rate']); - } $lineTotal = $invoiceItemCost * $invoiceItemQty; + $total += round($lineTotal, 2); + } - $total += round($lineTotal + ($lineTotal * $invoiceItemTaxRate / 100), 2); + foreach ($data['invoice_items'] as $item) { + $item = (array) $item; + if (isset($item['tax_rate']) && Utils::parseFloat($item['tax_rate']) > 0) { + $invoiceItemCost = round(Utils::parseFloat($item['cost']), 2); + $invoiceItemQty = round(Utils::parseFloat($item['qty']), 2); + $invoiceItemTaxRate = Utils::parseFloat($item['tax_rate']); + $lineTotal = $invoiceItemCost * $invoiceItemQty; + + if ($invoice->discount > 0) { + if ($invoice->is_amount_discount) { + $lineTotal -= round(($lineTotal/$total) * $invoice->discount, 2); + } else { + $lineTotal -= round($lineTotal * ($invoice->discount/100), 2); + } + } + + $itemTax += round($lineTotal * $invoiceItemTaxRate / 100, 2); + } } if ($invoice->discount > 0) { @@ -358,6 +373,7 @@ class InvoiceRepository $total += $total * $invoice->tax_rate / 100; $total = round($total, 2); + $total += $itemTax; // custom fields not charged taxes if ($invoice->custom_value1 && !$invoice->custom_taxes1) { diff --git a/public/js/built.js b/public/js/built.js index 1438074afcf9..109abfe56d86 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -30799,22 +30799,49 @@ function displayNotesAndTerms(doc, layout, invoice, y) function calculateAmounts(invoice) { var total = 0; var hasTaxes = false; + var taxes = {}; + + // sum line item + for (var i=0; i 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index b807a2cda038..4350c84da457 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -713,7 +713,6 @@ return array( 'add_to_invoice' => 'Zur Rechnung :invoice hinzufügen', 'create_new_invoice' => 'Neue Rechnung erstellen', 'task_errors' => 'Bitte korrigieren Sie alle überlappenden Zeiten', - 'utf8_invoices' => 'Neue PDF Engine Beta', 'from' => 'Von', 'to' => 'An', 'font_size' => 'Schriftgrösse', @@ -732,7 +731,7 @@ return array( 'invoice_no' => 'Rechnung Nr.', 'recent_payments' => 'Kürzliche Zahlungen', 'manage_companies' => 'Unternehmen verwalten', - 'total_revenue' => 'Gesamteinnahmen', + 'total_revenue' => 'Gesamteinnahmen', 'current_user' => 'Aktueller Benutzer', 'new_recurring_invoice' => 'Neue wiederkehrende Rechnung', diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index b622681b52cb..153d217b67f7 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -597,7 +597,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/es/texts.php b/resources/lang/es/texts.php index 6fadcb003371..abb73def2593 100644 --- a/resources/lang/es/texts.php +++ b/resources/lang/es/texts.php @@ -569,7 +569,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/es_ES/texts.php b/resources/lang/es_ES/texts.php index 8eab55859465..47b452a327b4 100644 --- a/resources/lang/es_ES/texts.php +++ b/resources/lang/es_ES/texts.php @@ -598,7 +598,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/fr/texts.php b/resources/lang/fr/texts.php index 521dd05cab1c..fc4fe086c2c7 100644 --- a/resources/lang/fr/texts.php +++ b/resources/lang/fr/texts.php @@ -590,7 +590,6 @@ return array( 'less_fields' => 'Moins de champs', 'client_name' => 'Nom du client', 'pdf_settings' => 'Réglages PDF', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Réglages du produit', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/fr_CA/texts.php b/resources/lang/fr_CA/texts.php index 003d0a5df062..1ae99b9c49f1 100644 --- a/resources/lang/fr_CA/texts.php +++ b/resources/lang/fr_CA/texts.php @@ -590,7 +590,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/it/texts.php b/resources/lang/it/texts.php index a406d467a80c..26ccaa791bb4 100644 --- a/resources/lang/it/texts.php +++ b/resources/lang/it/texts.php @@ -592,7 +592,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php index c9b9da05ca03..9b2e313c670e 100644 --- a/resources/lang/lt/texts.php +++ b/resources/lang/lt/texts.php @@ -600,7 +600,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/nb_NO/texts.php b/resources/lang/nb_NO/texts.php index 2609e567eeb4..a23c1ce99c79 100644 --- a/resources/lang/nb_NO/texts.php +++ b/resources/lang/nb_NO/texts.php @@ -598,7 +598,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/nl/texts.php b/resources/lang/nl/texts.php index 478675558ee1..7cef450cd692 100644 --- a/resources/lang/nl/texts.php +++ b/resources/lang/nl/texts.php @@ -593,7 +593,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/pt_BR/texts.php b/resources/lang/pt_BR/texts.php index 30141f665a39..fde8e8f4451a 100644 --- a/resources/lang/pt_BR/texts.php +++ b/resources/lang/pt_BR/texts.php @@ -593,7 +593,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/lang/sv/texts.php b/resources/lang/sv/texts.php index 1f479c5a4ffa..c6a1687cd478 100644 --- a/resources/lang/sv/texts.php +++ b/resources/lang/sv/texts.php @@ -596,7 +596,6 @@ return array( 'less_fields' => 'Less Fields', 'client_name' => 'Client Name', 'pdf_settings' => 'PDF Settings', - 'utf8_invoices' => 'New PDF Engine Beta', 'product_settings' => 'Product Settings', 'auto_wrap' => 'Auto Line Wrap', 'duplicate_post' => 'Warning: the previous page was submitted twice. The second submission had been ignored.', diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 8b9a91abc54e..0e93c4727115 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -3,13 +3,10 @@ @section('head') @parent - - - - @if (Auth::user()->account->utf8_invoices) - - - @endif + + + + @stop @@ -102,10 +99,7 @@ {!! Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id') !!} @endif - @if (Auth::user()->account->utf8_invoices) - {!! Former::text('font_size')->type('number')->min('0')->step('1')->style('width:120px') !!} - @endif - + {!! Former::text('font_size')->type('number')->min('0')->step('1')->style('width:120px') !!} {!! Former::text('primary_color') !!} {!! Former::text('secondary_color') !!} diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index b3b03011578c..8fc5a4f6b920 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -23,7 +23,6 @@ {{ Former::populateField('custom_invoice_taxes2', intval($account->custom_invoice_taxes2)) }} {{ Former::populateField('share_counter', intval($account->share_counter)) }} {{ Former::populateField('pdf_email_attachment', intval($account->pdf_email_attachment)) }} - {{ Former::populateField('utf8_invoices', intval($account->utf8_invoices)) }}
@@ -97,7 +96,6 @@
{!! Former::checkbox('pdf_email_attachment')->text(trans('texts.enable')) !!} - {!! Former::checkbox('utf8_invoices')->text(trans('texts.enable')) !!}
diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 35c889e7eddf..a45f195e8436 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -5,11 +5,8 @@ - - @if (Auth::user()->account->utf8_invoices) - - - @endif + + @stop @@ -138,7 +135,7 @@

 

- +
@@ -246,6 +243,15 @@ @endif + + + @endif + + + +
+ @if (!$account->hide_quantity) + {{ trans('texts.tax') }}