From 9341ea0c87708946d5eb3f66534eda3df2f7e3a7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 22 Dec 2015 14:06:53 +0200 Subject: [PATCH] Bug fixes --- app/Http/Controllers/DashboardController.php | 2 +- app/Ninja/Import/CSV/InvoiceTransformer.php | 1 + .../Import/FreshBooks/InvoiceTransformer.php | 1 + .../Import/Harvest/InvoiceTransformer.php | 1 + .../Import/Hiveage/InvoiceTransformer.php | 1 + .../Import/Invoiceable/InvoiceTransformer.php | 1 + .../Import/Nutcache/InvoiceTransformer.php | 1 + app/Ninja/Import/Ronin/InvoiceTransformer.php | 1 + app/Ninja/Import/Zoho/InvoiceTransformer.php | 1 + app/Ninja/Repositories/InvoiceRepository.php | 2 +- app/Services/AuthService.php | 1 - .../views/accounts/customize_design.blade.php | 34 +++++++++++++++---- resources/views/invoices/edit.blade.php | 2 +- 13 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 452c668eab50..27d4ab04af57 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -115,7 +115,7 @@ class DashboardController extends BaseController ->where('contacts.deleted_at', '=', null) ->where('contacts.is_primary', '=', true) ->select(['payments.payment_date', 'payments.amount', 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id']) - ->orderBy('payments.id', 'desc') + ->orderBy('payments.payment_date', 'desc') ->take(50) ->get(); diff --git a/app/Ninja/Import/CSV/InvoiceTransformer.php b/app/Ninja/Import/CSV/InvoiceTransformer.php index d9c1228572d0..108763c4baf7 100644 --- a/app/Ninja/Import/CSV/InvoiceTransformer.php +++ b/app/Ninja/Import/CSV/InvoiceTransformer.php @@ -26,6 +26,7 @@ class InvoiceTransformer extends BaseTransformer 'invoice_date_sql' => isset($data->invoice_date) ? $data->invoice_date : null, 'invoice_items' => [ [ + 'product_key' => '', 'notes' => isset($data->notes) ? $data->notes : null, 'cost' => isset($data->amount) ? (float) $data->amount : null, 'qty' => 1, diff --git a/app/Ninja/Import/FreshBooks/InvoiceTransformer.php b/app/Ninja/Import/FreshBooks/InvoiceTransformer.php index d2389beaf842..66f768873e4f 100644 --- a/app/Ninja/Import/FreshBooks/InvoiceTransformer.php +++ b/app/Ninja/Import/FreshBooks/InvoiceTransformer.php @@ -26,6 +26,7 @@ class InvoiceTransformer extends BaseTransformer 'invoice_date_sql' => $data->create_date, 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->notes, 'cost' => (float) $data->amount, 'qty' => 1, diff --git a/app/Ninja/Import/Harvest/InvoiceTransformer.php b/app/Ninja/Import/Harvest/InvoiceTransformer.php index c8c5a3b9d95e..e33bd9d14548 100644 --- a/app/Ninja/Import/Harvest/InvoiceTransformer.php +++ b/app/Ninja/Import/Harvest/InvoiceTransformer.php @@ -24,6 +24,7 @@ class InvoiceTransformer extends BaseTransformer 'invoice_date_sql' => $this->getDate($data->issue_date, 'm/d/Y'), 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->subject, 'cost' => (float) $data->invoice_amount, 'qty' => 1, diff --git a/app/Ninja/Import/Hiveage/InvoiceTransformer.php b/app/Ninja/Import/Hiveage/InvoiceTransformer.php index b13dc3d05628..72193308946b 100644 --- a/app/Ninja/Import/Hiveage/InvoiceTransformer.php +++ b/app/Ninja/Import/Hiveage/InvoiceTransformer.php @@ -24,6 +24,7 @@ class InvoiceTransformer extends BaseTransformer 'due_date_sql' => $this->getDate($data->due_date), 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->summary, 'cost' => (float) $data->billed_total, 'qty' => 1, diff --git a/app/Ninja/Import/Invoiceable/InvoiceTransformer.php b/app/Ninja/Import/Invoiceable/InvoiceTransformer.php index dc16a9352a37..1d08d56f2d58 100644 --- a/app/Ninja/Import/Invoiceable/InvoiceTransformer.php +++ b/app/Ninja/Import/Invoiceable/InvoiceTransformer.php @@ -26,6 +26,7 @@ class InvoiceTransformer extends BaseTransformer 'paid' => (float) $data->paid, 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->description, 'cost' => (float) $data->total, 'qty' => 1, diff --git a/app/Ninja/Import/Nutcache/InvoiceTransformer.php b/app/Ninja/Import/Nutcache/InvoiceTransformer.php index dfe4dc21f0b1..3d9a8c9cbd7a 100644 --- a/app/Ninja/Import/Nutcache/InvoiceTransformer.php +++ b/app/Ninja/Import/Nutcache/InvoiceTransformer.php @@ -27,6 +27,7 @@ class InvoiceTransformer extends BaseTransformer 'due_date_sql' => $this->getDate($data->due_date), 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->description, 'cost' => (float) $data->total, 'qty' => 1, diff --git a/app/Ninja/Import/Ronin/InvoiceTransformer.php b/app/Ninja/Import/Ronin/InvoiceTransformer.php index 9829774ffdc5..ca92e33a8f44 100644 --- a/app/Ninja/Import/Ronin/InvoiceTransformer.php +++ b/app/Ninja/Import/Ronin/InvoiceTransformer.php @@ -25,6 +25,7 @@ class InvoiceTransformer extends BaseTransformer 'due_date_sql' => $data->date_due, 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->line_item, 'cost' => (float) $data->total, 'qty' => 1, diff --git a/app/Ninja/Import/Zoho/InvoiceTransformer.php b/app/Ninja/Import/Zoho/InvoiceTransformer.php index f89d1c0630ab..e27fbbd038df 100644 --- a/app/Ninja/Import/Zoho/InvoiceTransformer.php +++ b/app/Ninja/Import/Zoho/InvoiceTransformer.php @@ -25,6 +25,7 @@ class InvoiceTransformer extends BaseTransformer 'invoice_date_sql' => $data->invoice_date, 'invoice_items' => [ [ + 'product_key' => '', 'notes' => $data->item_desc, 'cost' => (float) $data->total, 'qty' => 1, diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 31de427be56d..763a539c8061 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -387,7 +387,7 @@ class InvoiceRepository extends BaseRepository $task->save(); } - if (isset($item['product_key']) && $item['product_key']) { + if ($item['product_key']) { if (!\Auth::user()->account->update_products) { continue; } diff --git a/app/Services/AuthService.php b/app/Services/AuthService.php index f5fbc0c53236..9b62b1e7008a 100644 --- a/app/Services/AuthService.php +++ b/app/Services/AuthService.php @@ -52,7 +52,6 @@ class AuthService if ($result === true) { if (!$isRegistered) { - event(new UserSignedUp()); Session::flash('warning', trans('texts.success_message')); Session::flash('onReady', 'handleSignedUp();'); } else { diff --git a/resources/views/accounts/customize_design.blade.php b/resources/views/accounts/customize_design.blade.php index 00f4c8c78571..d66361322fcf 100644 --- a/resources/views/accounts/customize_design.blade.php +++ b/resources/views/accounts/customize_design.blade.php @@ -73,9 +73,10 @@ function saveEditor(data) { setTimeout(function() { - customDesign[editorSection] = editor.get(); - refreshPDF(); - }, 100) + customDesign[editorSection] = editor.get(); + clearError(); + refreshPDF(); + }, 100) } function onSelectChange() @@ -89,16 +90,34 @@ } loadEditor(editorSection); - refreshPDF(true); + clearError(); + refreshPDF(true); } function submitForm() { + if (!NINJA.isPDFValid) { + return; + } + $('#custom_design').val(JSON.stringify(customDesign)); $('form.warn-on-exit').submit(); } - $(function() { + window.onerror = function(e) { + $('#pdf-error').html(e.message ? e.message : e).show(); + $('button.save-button').prop('disabled', true); + NINJA.isPDFValid = false; + } + + function clearError() { + NINJA.isPDFValid = true; + $('#pdf-error').hide(); + $('button.save-button').prop('disabled', false); + } + + $(function() { + clearError(); refreshPDF(true); var container = document.getElementById("jsoneditor"); @@ -109,14 +128,14 @@ saveEditor(); } }; - window.editor = new JSONEditor(container, options); + window.editor = new JSONEditor(container, options); loadEditor('content'); $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { var target = $(e.target).attr("href") // activated tab target = target.substring(1); // strip leading # loadEditor(target); - }); + }); }); @@ -195,6 +214,7 @@
+ @include('invoices.pdf', ['account' => Auth::user()->account, 'pdfHeight' => 800]) diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index c250299aaee7..bb670858c317 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -355,7 +355,7 @@ @endif - + {{ trans($entityType == ENTITY_INVOICE ? 'texts.balance_due' : 'texts.total') }}