Reviewers: ,
Please review this at http://codereview.tryton.org/397001/
Affected files:
M CHANGELOG
M statement.py
M tests/scenario_account_statement.rst
Index: CHANGELOG
===================================================================
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Allow to use credit note on statement line
+
Version 2.4.0 - 2012-04-23
* Bug fixes (see mercurial logs for details)
* Don't deactivate payment wizard on invoice
Index: statement.py
===================================================================
--- a/statement.py
+++ b/statement.py
@@ -355,9 +355,7 @@
on_change=['account', 'invoice'], domain=[
('company', '=', Eval('_parent_statement', {}).get('company',
0)),
If(Bool(Eval('party')),
- If(Eval('amount', 0) > 0,
- ('kind', '=', 'receivable'),
- ('kind', '=', 'payable')),
+ ('kind', 'in', ['receivable', 'payable']),
('kind', 'in',
['payable', 'receivable', 'revenue', 'expense',
'other'])),
],
Index: tests/scenario_account_statement.rst
===================================================================
--- a/tests/scenario_account_statement.rst
+++ b/tests/scenario_account_statement.rst
@@ -166,6 +166,22 @@
>>> customer_invoice2.state
u'open'
+Create 1 customer credit note::
+
+ >>> customer_credit_note = Invoice(type='out_credit_note')
+ >>> customer_credit_note.party = customer
+ >>> customer_credit_note.payment_term = payment_term
+ >>> invoice_line = InvoiceLine()
+ >>> customer_credit_note.lines.append(invoice_line)
+ >>> invoice_line.quantity = 1
+ >>> invoice_line.unit_price = Decimal('50')
+ >>> invoice_line.account = revenue
+ >>> invoice_line.description = 'Test'
+ >>> customer_credit_note.save()
+ >>> Invoice.open([customer_credit_note.id], config.context)
+ >>> customer_credit_note.state
+ u'open'
+
Create 1 supplier invoices::
>>> supplier_invoice = Invoice(type='in_invoice')
@@ -208,7 +224,7 @@
>>> statement = Statement(journal=statement_journal,
... start_balance=Decimal('0'),
- ... end_balance=Decimal('130'),
+ ... end_balance=Decimal('80'),
... )
Received 180 from customer::
@@ -234,6 +250,16 @@
>>> statement_line.amount == Decimal('80')
True
+Paid 50 to customer::
+
+ >>> statement_line = StatementLine()
+ >>> statement.lines.append(statement_line)
+ >>> statement_line.date = today
+ >>> statement_line.amount = Decimal('-50')
+ >>> statement_line.party = customer
+ >>> statement_line.account = receivable
+ >>> statement_line.invoice = customer_credit_note
+
Paid 50 to supplier::
>>> statement_line = StatementLine()
@@ -263,6 +289,9 @@
u'open'
>>> customer_invoice2.amount_to_pay == Decimal('70')
True
+ >>> customer_credit_note.reload()
+ >>> customer_credit_note.state
+ u'paid'
>>> supplier_invoice.reload()
>>> supplier_invoice.state
u'paid'
--
[email protected] mailing list