From f1bf1455a21282071618369a5fcbb3abe10866d6 Mon Sep 17 00:00:00 2001 From: Francois Gaudin Date: Sun, 2 Oct 2011 01:30:18 +0200 Subject: [PATCH] Fix bug on invoice with empty proposal and balancing payments. Closes #242 --- accounts/tests.py | 32 ++++++++++++++++++++++++++++++++ accounts/views.py | 2 +- core/context_processors.py | 2 +- media/js/rows.js | 12 ++++++++++++ templates/changelog.html | 4 ++++ templates/invoice/edit.html | 6 ++++++ 6 files changed, 56 insertions(+), 2 deletions(-) diff --git a/accounts/tests.py b/accounts/tests.py index 4f3b2f9..8b904a1 100644 --- a/accounts/tests.py +++ b/accounts/tests.py @@ -1757,6 +1757,38 @@ def testCanCreateInvoiceWithoutProposal(self): unit_price='100') self.assertEqual(len(invoice_rows), 1) + def testBug242(self): + contacts = Contact.objects.filter(name='New customer').count() + self.assertEquals(contacts, 0) + response = self.client.post(reverse('invoice_add_without_proposal'), + {'contact-name': 'New customer', + 'address-street': '1 rue de la paix', + 'address-zipcode': '75001', + 'address-city': 'Paris', + 'invoice-invoice_id': 1, + 'invoice-state': INVOICE_STATE_PAID, + 'invoice-amount': 1000, + 'invoice-edition_date': '2010-8-31', + 'invoice-payment_date': '2010-9-30', + 'invoice-paid_date': '2010-10-10', + 'invoice-payment_type': PAYMENT_TYPE_CHECK, + 'invoice-execution_begin_date': '2010-8-1', + 'invoice-execution_end_date': '2010-8-7', + 'invoice-penalty_date': '2010-10-8', + 'invoice-penalty_rate': 1.5, + 'invoice-discount_conditions':'Nothing', + 'invoice_rows-TOTAL_FORMS': 1, + 'invoice_rows-INITIAL_FORMS': 0, + 'invoice_rows-0-ownedobject_ptr': '', + 'invoice_rows-0-label': 'Day of work', + 'invoice_rows-0-proposal': '', + 'invoice_rows-0-balance_payments': 'on', + 'invoice_rows-0-category': ROW_CATEGORY_SERVICE, + 'invoice_rows-0-quantity': 10, + 'invoice_rows-0-unit_price': 100 }) + + self.assertEqual(response.status_code, 302) + def testCanReferenceExistentContact(self): self.assertEquals(Contact.objects.count(), 2) diff --git a/accounts/views.py b/accounts/views.py index 17ead93..05d931c 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -364,7 +364,7 @@ def invoice_create_or_edit(request, id=None, customer_id=None, proposal_id=None) invoicerow.invoice = invoice invoicerow.save(user=user) - if invoicerow.balance_payments and invoice.paid_date: + if invoicerow.proposal and invoicerow.balance_payments and invoice.paid_date: invoicerow.proposal.state = PROPOSAL_STATE_BALANCED invoicerow.proposal.save() diff --git a/core/context_processors.py b/core/context_processors.py index aaa86c6..1217350 100644 --- a/core/context_processors.py +++ b/core/context_processors.py @@ -3,6 +3,6 @@ def common(request=None): return {'logo_url': settings.LOGO_URL, 'parent_site_url': settings.PARENT_SITE_URL, - 'version': '1.4.1', + 'version': '1.4.2', 'GOOGLE_API_KEY': settings.GOOGLE_API_KEY, 'demo_mode': settings.DEMO} diff --git a/media/js/rows.js b/media/js/rows.js index 3e982b2..516eca5 100644 --- a/media/js/rows.js +++ b/media/js/rows.js @@ -92,4 +92,16 @@ }); }); }; + + $.fn.toggleBalanceCheckbox = function(){ + return $(this).each(function(){ + if($(this).val()) { + $(this).siblings('.balance_payments_label').show(); + $(this).siblings('.balance-payments-field').show(); + } else { + $(this).siblings('.balance_payments_label').hide(); + $(this).siblings('.balance-payments-field').hide(); + } + }); + }; })( jQuery ); \ No newline at end of file diff --git a/templates/changelog.html b/templates/changelog.html index 1659b81..ce73584 100644 --- a/templates/changelog.html +++ b/templates/changelog.html @@ -14,6 +14,10 @@ +

Version 1.4.2

+

Version 1.4.1