Amit Dodiya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-18393-ado into 
lp:~openerp/openobject-addons/6.0-certified-addons.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-18393-ado/+merge/123932

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
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-18393-ado/+merge/123932
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-18393-ado.
=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
--- account_invoice_cash_discount/account_invoice_cash_discount.py	2011-09-19 09:55:44 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount.py	2012-09-12 11:46:29 +0000
@@ -251,6 +251,11 @@
             move_line = context['tax_move_ids']
             for move_line_id in move_line:
                 move_line_data = move_line_obj_memory.browse(cr, uid,move_line_id)
+                amount_tax = 0.0
+                if invoice.partner_id.customer:
+                    amount_tax = move_line_data.tax_amount
+                elif invoice.partner_id.supplier:
+                    amount_tax = -move_line_data.tax_amount
                 l3 = {
                     'debit': move_line_data.debit,
                     'credit': move_line_data.credit,
@@ -262,7 +267,7 @@
                     'amount_currency': move_line_data.amount_currency and direction * move_line_data.amount_currency or 0.0,
                     'name': move_line_data.name,
                     'tax_code_id': move_line_data.tax_code_id.id,
-                    'tax_amount': move_line_data.tax_amount,
+                    'tax_amount': amount_tax,
                 }
                 lines.append((0, 0, l3))
         else:
@@ -297,6 +302,11 @@
 
                             if invoice.company_id.currency_id.id <> invoice.currency_id.id:
                                 tax_amount_currency = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, tax_real_amt, context=context)
+                            amount_tax = 0.0
+                            if invoice.partner_id.customer:
+                                amount_tax = tax_real_amt
+                            elif invoice.partner_id.supplier:
+                                amount_tax = -tax_real_amt
                             l3 = {
                                 'debit': direction * tax_real_amt < 0 and abs(tax_real_amt) or 0.0,
                                 'credit': direction * tax_real_amt > 0 and abs(tax_real_amt) or 0.0,
@@ -307,7 +317,7 @@
                                 'currency_id': currency_id,
                                 'amount_currency': tax_amount_currency and direction * tax_amount_currency or 0.0,
                                 'tax_code_id': tax_code_id,
-                                'tax_amount': -tax_real_amt,
+                                'tax_amount': amount_tax,
                                 'name': name,
                             }
                             lines.append((0, 0, l3))
@@ -316,6 +326,11 @@
             move_line = context['discount_move_ids']
             for move_line_id in move_line:
                 move_line_data = move_line_obj_memory.browse(cr, uid, move_line_id)
+                amount_tax = 0.0
+                if invoice.partner_id.customer:
+                    amount_tax = +move_line_data.tax_amount
+                elif invoice.partner_id.supplier:
+                    amount_tax = -move_line_data.tax_amount
                 l4 = {
                     'debit': move_line_data.debit,
                     'credit':move_line_data.credit,
@@ -327,7 +342,7 @@
                     'amount_currency': move_line_data.amount_currency and direction * move_line_data.amount_currency or 0.0,
                     'name': move_line_data.name,
                     'tax_code_id': move_line_data.tax_code_id.id,
-                    'tax_amount': -move_line_data.tax_amount,
+                    'tax_amount': amount_tax,
                 }
                 lines.append((0, 0, l4))
         else:
@@ -375,6 +390,11 @@
                     if invoice.company_id.currency_id.id <> invoice.currency_id.id:
                         discount_amount = discount_ratio - total_tax_amount
                         discount_amount_currency = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, discount_amount, context=context)
+                    amount_tax = 0.0
+                    if invoice.partner_id.customer:
+                        amount_tax = -(discount_ratio - total_tax_amount)
+                    elif invoice.partner_id.supplier:
+                        amount_tax = (discount_ratio - total_tax_amount)
                     l4 = {
                         'debit': direction * (discount_ratio - total_tax_amount) < 0 and abs(discount_ratio - total_tax_amount) or 0.0,
                         'credit': direction * (discount_ratio - total_tax_amount) > 0 and abs(discount_ratio - total_tax_amount) or 0.0,
@@ -385,7 +405,7 @@
                         'currency_id': currency_id,
                         'amount_currency': discount_amount_currency and direction * discount_amount_currency or 0.0,
                         'tax_code_id': base_code_id,
-                        'tax_amount': -(discount_ratio - total_tax_amount),
+                        'tax_amount': amount_tax,
                         'name': name,
                     }
                     lines.append((0, 0, l4))

=== modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py'
--- account_invoice_cash_discount/wizard/account_pay_invoice.py	2011-09-19 09:55:44 +0000
+++ account_invoice_cash_discount/wizard/account_pay_invoice.py	2012-09-12 11:46:29 +0000
@@ -178,6 +178,12 @@
                         discount_amount = discount - tax_real_amt
                         amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, discount_amount, context=context)
 
+                    amount_tax = 0.0
+                    if invoice.partner_id.customer:
+                        amount_tax = -(discount_pay - total_tax_amount)
+                    elif invoice.partner_id.supplier:
+                        amount_tax = (discount_pay - total_tax_amount)
+
                     l4 = {
                         'debit': direction * (discount_pay - total_tax_amount) < 0 and abs(discount_pay - total_tax_amount) or 0.0,
                         'credit': direction * (discount_pay - total_tax_amount) > 0 and abs(discount_pay - total_tax_amount) or 0.0,
@@ -187,7 +193,7 @@
                         'currency_id': invoice.currency_id and invoice.currency_id.id,
                         'journal_id': invoice.journal_id and invoice.journal_id.id,
                         'tax_code_id': base_code_id,
-                        'tax_amount': -(discount_pay - total_tax_amount),
+                        'tax_amount': amount_tax,
                         'amount_currency': amount and direction * amount or 0.0,
                         'analytic_account_id': line.account_analytic_id.id,
                     }
@@ -256,6 +262,11 @@
                             if invoice.company_id.currency_id.id <> invoice.currency_id.id:
                                 amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, tax_real_amt, context=context)
 
+                            amount_tax = 0.0
+                            if invoice.partner_id.customer:
+                                amount_tax = -tax_real_amt
+                            elif invoice.partner_id.supplier:
+                                amount_tax = tax_real_amt
                             l3 = {
                                 'debit': direction * tax_real_amt < 0 and abs(tax_real_amt) or 0.0,
                                 'credit': direction * tax_real_amt > 0 and abs(tax_real_amt) or 0.0,
@@ -265,7 +276,7 @@
                                 'name': name,
                                 'currency_id': invoice.currency_id and invoice.currency_id.id,
                                 'tax_code_id': tax_code_id,
-                                'tax_amount': -tax_real_amt,
+                                'tax_amount': amount_tax,
                                 'amount_currency': amount and direction * amount or 0.0,
                                 'analytic_account_id': line.account_analytic_id.id,
                             }
@@ -376,6 +387,11 @@
                         if invoice.company_id.currency_id.id <> invoice.currency_id.id:
                             amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, tax_real_amt, context=context)
 
+                        amount_tax = 0.0
+                        if invoice.partner_id.customer:
+                            amount_tax = -tax_real_amt
+                        elif invoice.partner_id.supplier:
+                            amount_tax = tax_real_amt
                         l3 = {
                             'debit': direction * tax_real_amt < 0 and abs(tax_real_amt) or 0.0,
                             'credit': direction * tax_real_amt > 0 and abs(tax_real_amt) or 0.0,
@@ -385,7 +401,7 @@
                             'name': name,
                             'currency_id': invoice.currency_id and invoice.currency_id.id,
                             'tax_code_id': tax_code_id,
-                            'tax_amount': -tax_real_amt,
+                            'tax_amount': amount_tax,
                             'amount_currency': amount and direction * amount or 0.0,
                             'analytic_account_id': line.account_analytic_id.id,
                         }
@@ -411,6 +427,11 @@
                     discount_amount = discount_pay - tax_real_amt
                     amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, discount_amount, context=context)
 
+                amount_tax = 0.0
+                if invoice.partner_id.customer:
+                    amount_tax = -(discount_pay - total_tax_amount)
+                elif invoice.partner_id.supplier:
+                    amount_tax = (discount_pay - total_tax_amount)
                 l4 = {
                     'debit': direction * (discount_pay - total_tax_amount) < 0 and abs(discount_pay - total_tax_amount) or 0.0,
                     'credit': direction * (discount_pay - total_tax_amount) > 0 and abs(discount_pay - total_tax_amount) or 0.0,
@@ -420,7 +441,7 @@
                     'currency_id': invoice.currency_id and invoice.currency_id.id,
                     'journal_id': data.get('journal_id', False),
                     'tax_code_id': base_code_id,
-                    'tax_amount': -(discount_pay - total_tax_amount),
+                    'tax_amount': amount_tax,
                     'amount_currency': amount and direction * amount or 0.0,
                     'analytic_account_id': line.account_analytic_id.id,
                 }

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to