Merge lp:~openerp-dev/openobject-addons/6.0-opw-18393-ado into lp:~openerp/openobject-addons/6.0-certified-addons

Proposed by Amit Dodiya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-18393-ado
Merge into: lp:~openerp/openobject-addons/6.0-certified-addons
Diff against target: 176 lines (+49/-8)
2 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+24/-4)
account_invoice_cash_discount/wizard/account_pay_invoice.py (+25/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-18393-ado
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+123932@code.launchpad.net

Description of the change

Hello,

"[FIX] sign of tax amount in payment wizard for customer should be negative and for supplier it should be positive"

1). Install module account_payment_discount extension with its dependencies.
2). Create payment term: 2% Cash Discount for payment in 14 days, 30 days net
3). Create customer invoice for 100EUR net with 19% VAT, Validate it and pay by "Pay Invoice" wizard to the right of invoice form. Amounts in Pay Invoice wizard are correct, but when you click "Full Payment" and take a look on account moves you will see that

Tax Base for discount has wrong sign. In the wizard Tax Base (-2.00) and Tax Amount (-0.38) has the same negative sign. On Account move Tax Base is positive (2.00) and Tax Amount is negative (-0.38). Both should be negative.

The same bug is for Supplier invoices. Both values should be positive in this case but they are:
In "Pay Invoice" wizard both are negative (should be positive)
And in account moves:
Tax Base 2.00 (ok)
Tax Amount -0.38 (should be +0.38)

Regards,
Amit Dodiya

To post a comment you must log in.

Unmerged revisions

5. By Amit Dodiya<email address hidden>

[FIX] sign of tax amount in payment wizard for customer should be negative and for supplier it should be positive

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
2--- account_invoice_cash_discount/account_invoice_cash_discount.py 2011-09-19 09:55:44 +0000
3+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2012-09-12 11:46:29 +0000
4@@ -251,6 +251,11 @@
5 move_line = context['tax_move_ids']
6 for move_line_id in move_line:
7 move_line_data = move_line_obj_memory.browse(cr, uid,move_line_id)
8+ amount_tax = 0.0
9+ if invoice.partner_id.customer:
10+ amount_tax = move_line_data.tax_amount
11+ elif invoice.partner_id.supplier:
12+ amount_tax = -move_line_data.tax_amount
13 l3 = {
14 'debit': move_line_data.debit,
15 'credit': move_line_data.credit,
16@@ -262,7 +267,7 @@
17 'amount_currency': move_line_data.amount_currency and direction * move_line_data.amount_currency or 0.0,
18 'name': move_line_data.name,
19 'tax_code_id': move_line_data.tax_code_id.id,
20- 'tax_amount': move_line_data.tax_amount,
21+ 'tax_amount': amount_tax,
22 }
23 lines.append((0, 0, l3))
24 else:
25@@ -297,6 +302,11 @@
26
27 if invoice.company_id.currency_id.id <> invoice.currency_id.id:
28 tax_amount_currency = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, tax_real_amt, context=context)
29+ amount_tax = 0.0
30+ if invoice.partner_id.customer:
31+ amount_tax = tax_real_amt
32+ elif invoice.partner_id.supplier:
33+ amount_tax = -tax_real_amt
34 l3 = {
35 'debit': direction * tax_real_amt < 0 and abs(tax_real_amt) or 0.0,
36 'credit': direction * tax_real_amt > 0 and abs(tax_real_amt) or 0.0,
37@@ -307,7 +317,7 @@
38 'currency_id': currency_id,
39 'amount_currency': tax_amount_currency and direction * tax_amount_currency or 0.0,
40 'tax_code_id': tax_code_id,
41- 'tax_amount': -tax_real_amt,
42+ 'tax_amount': amount_tax,
43 'name': name,
44 }
45 lines.append((0, 0, l3))
46@@ -316,6 +326,11 @@
47 move_line = context['discount_move_ids']
48 for move_line_id in move_line:
49 move_line_data = move_line_obj_memory.browse(cr, uid, move_line_id)
50+ amount_tax = 0.0
51+ if invoice.partner_id.customer:
52+ amount_tax = +move_line_data.tax_amount
53+ elif invoice.partner_id.supplier:
54+ amount_tax = -move_line_data.tax_amount
55 l4 = {
56 'debit': move_line_data.debit,
57 'credit':move_line_data.credit,
58@@ -327,7 +342,7 @@
59 'amount_currency': move_line_data.amount_currency and direction * move_line_data.amount_currency or 0.0,
60 'name': move_line_data.name,
61 'tax_code_id': move_line_data.tax_code_id.id,
62- 'tax_amount': -move_line_data.tax_amount,
63+ 'tax_amount': amount_tax,
64 }
65 lines.append((0, 0, l4))
66 else:
67@@ -375,6 +390,11 @@
68 if invoice.company_id.currency_id.id <> invoice.currency_id.id:
69 discount_amount = discount_ratio - total_tax_amount
70 discount_amount_currency = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, discount_amount, context=context)
71+ amount_tax = 0.0
72+ if invoice.partner_id.customer:
73+ amount_tax = -(discount_ratio - total_tax_amount)
74+ elif invoice.partner_id.supplier:
75+ amount_tax = (discount_ratio - total_tax_amount)
76 l4 = {
77 'debit': direction * (discount_ratio - total_tax_amount) < 0 and abs(discount_ratio - total_tax_amount) or 0.0,
78 'credit': direction * (discount_ratio - total_tax_amount) > 0 and abs(discount_ratio - total_tax_amount) or 0.0,
79@@ -385,7 +405,7 @@
80 'currency_id': currency_id,
81 'amount_currency': discount_amount_currency and direction * discount_amount_currency or 0.0,
82 'tax_code_id': base_code_id,
83- 'tax_amount': -(discount_ratio - total_tax_amount),
84+ 'tax_amount': amount_tax,
85 'name': name,
86 }
87 lines.append((0, 0, l4))
88
89=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py'
90--- account_invoice_cash_discount/wizard/account_pay_invoice.py 2011-09-19 09:55:44 +0000
91+++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2012-09-12 11:46:29 +0000
92@@ -178,6 +178,12 @@
93 discount_amount = discount - tax_real_amt
94 amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, discount_amount, context=context)
95
96+ amount_tax = 0.0
97+ if invoice.partner_id.customer:
98+ amount_tax = -(discount_pay - total_tax_amount)
99+ elif invoice.partner_id.supplier:
100+ amount_tax = (discount_pay - total_tax_amount)
101+
102 l4 = {
103 'debit': direction * (discount_pay - total_tax_amount) < 0 and abs(discount_pay - total_tax_amount) or 0.0,
104 'credit': direction * (discount_pay - total_tax_amount) > 0 and abs(discount_pay - total_tax_amount) or 0.0,
105@@ -187,7 +193,7 @@
106 'currency_id': invoice.currency_id and invoice.currency_id.id,
107 'journal_id': invoice.journal_id and invoice.journal_id.id,
108 'tax_code_id': base_code_id,
109- 'tax_amount': -(discount_pay - total_tax_amount),
110+ 'tax_amount': amount_tax,
111 'amount_currency': amount and direction * amount or 0.0,
112 'analytic_account_id': line.account_analytic_id.id,
113 }
114@@ -256,6 +262,11 @@
115 if invoice.company_id.currency_id.id <> invoice.currency_id.id:
116 amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, tax_real_amt, context=context)
117
118+ amount_tax = 0.0
119+ if invoice.partner_id.customer:
120+ amount_tax = -tax_real_amt
121+ elif invoice.partner_id.supplier:
122+ amount_tax = tax_real_amt
123 l3 = {
124 'debit': direction * tax_real_amt < 0 and abs(tax_real_amt) or 0.0,
125 'credit': direction * tax_real_amt > 0 and abs(tax_real_amt) or 0.0,
126@@ -265,7 +276,7 @@
127 'name': name,
128 'currency_id': invoice.currency_id and invoice.currency_id.id,
129 'tax_code_id': tax_code_id,
130- 'tax_amount': -tax_real_amt,
131+ 'tax_amount': amount_tax,
132 'amount_currency': amount and direction * amount or 0.0,
133 'analytic_account_id': line.account_analytic_id.id,
134 }
135@@ -376,6 +387,11 @@
136 if invoice.company_id.currency_id.id <> invoice.currency_id.id:
137 amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, tax_real_amt, context=context)
138
139+ amount_tax = 0.0
140+ if invoice.partner_id.customer:
141+ amount_tax = -tax_real_amt
142+ elif invoice.partner_id.supplier:
143+ amount_tax = tax_real_amt
144 l3 = {
145 'debit': direction * tax_real_amt < 0 and abs(tax_real_amt) or 0.0,
146 'credit': direction * tax_real_amt > 0 and abs(tax_real_amt) or 0.0,
147@@ -385,7 +401,7 @@
148 'name': name,
149 'currency_id': invoice.currency_id and invoice.currency_id.id,
150 'tax_code_id': tax_code_id,
151- 'tax_amount': -tax_real_amt,
152+ 'tax_amount': amount_tax,
153 'amount_currency': amount and direction * amount or 0.0,
154 'analytic_account_id': line.account_analytic_id.id,
155 }
156@@ -411,6 +427,11 @@
157 discount_amount = discount_pay - tax_real_amt
158 amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, discount_amount, context=context)
159
160+ amount_tax = 0.0
161+ if invoice.partner_id.customer:
162+ amount_tax = -(discount_pay - total_tax_amount)
163+ elif invoice.partner_id.supplier:
164+ amount_tax = (discount_pay - total_tax_amount)
165 l4 = {
166 'debit': direction * (discount_pay - total_tax_amount) < 0 and abs(discount_pay - total_tax_amount) or 0.0,
167 'credit': direction * (discount_pay - total_tax_amount) > 0 and abs(discount_pay - total_tax_amount) or 0.0,
168@@ -420,7 +441,7 @@
169 'currency_id': invoice.currency_id and invoice.currency_id.id,
170 'journal_id': data.get('journal_id', False),
171 'tax_code_id': base_code_id,
172- 'tax_amount': -(discount_pay - total_tax_amount),
173+ 'tax_amount': amount_tax,
174 'amount_currency': amount and direction * amount or 0.0,
175 'analytic_account_id': line.account_analytic_id.id,
176 }

Subscribers

People subscribed via source and target branches