Skip to content

Commit

Permalink
Fix bug on invoice with empty proposal and balancing payments. Closes f…
Browse files Browse the repository at this point in the history
  • Loading branch information
fgaudin committed Oct 1, 2011
1 parent 1618cd1 commit f1bf145
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
32 changes: 32 additions & 0 deletions accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
12 changes: 12 additions & 0 deletions media/js/rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
4 changes: 4 additions & 0 deletions templates/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
</head>

<body style="margin:10px">
<h1>Version 1.4.2</h1>
<ul>
<li>Correction d'un bug sur l'ajout de facture si non rattachée à un devis et "solde les paiements" coché</li>
</ul>
<h1>Version 1.4.1</h1>
<ul>
<li>Agrandissement du champ titre dans le forum</li>
Expand Down
6 changes: 6 additions & 0 deletions templates/invoice/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
jQuery(e.currentTarget).siblings('.row-detail.empty-field').show();
});

jQuery('.form-row').delegate('.proposal-field', 'change', function(){
$(this).toggleBalanceCheckbox();
});
$('.proposal-field').toggleBalanceCheckbox();

jQuery('#invoice-edit-form').submit(function() {
jQuery('.invoice-row input.empty-field:text').val('');
jQuery('.invoice-row textarea.empty-field').val('');
Expand Down Expand Up @@ -125,6 +130,7 @@
jQuery('textarea', new_row).labelInside();
jQuery('.row-detail.empty-field', new_row).hide();
jQuery('.proposal-field', new_row).proposalOverview('{% trans "Proposal" %}', '{% url proposal_detail id=0 %}');
jQuery('.proposal-field', new_row).toggleBalanceCheckbox();
jQuery('.balance_payments_label', new_row).rowHelp();
jQuery('.balance-payments-field', new_row).balanceAll();

Expand Down

0 comments on commit f1bf145

Please sign in to comment.