Mayur Maheshwari(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-opw-575274-port-mma into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-575274-port-mma/+merge/132848

Hello,

[FIX]account_voucher: journal entry not balancing from purchase receipt

Steps to reproduce:
1. Create a Tax Ex: 14% tax from "Accounting/Configuration/Financial 
Accounting/Taxes/Taxes".
2. Create Purchase Receipt from "Accounting/Suppliers/Purchase Receipt" and 
give the Expense lines as:
Account Description Amount Analytic Account
656 Water 375.35 False
656 refuse 47.13 False
656 Service fees 38.99 False
656 sewerages 273.99 False

3. Now select the tax "14% tax", compute tax and validate the Receipt.

You will see the Journal Item state as Unbalanced. Now open Accounting/Journal 
Entries/Journal Entries, you will see that the Total Debit and Total Credit are 
not balanced.

Reason:
On the Purchase Receipt form tax are calculated on the bases of Final Total of 
the lines where in the Move line tax are calculated for each line and then the 
total of the each line is summed up. Due to rounding it has very lower 
difference into the debit and credit as a reason the Journal entries are not 
balanced.

    This branch fix this issue.
    Code is forward port from 6.1

Thanks,
Mayur


-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-575274-port-mma/+merge/132848
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-opw-575274-port-mma.
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py	2012-10-29 09:17:13 +0000
+++ account_voucher/account_voucher.py	2012-11-05 08:37:23 +0000
@@ -381,9 +381,10 @@
             total_tax = 0.0
 
             if not tax[0].price_include:
-                for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes', []):
-                    total_tax += tax_line.get('amount', 0.0)
-                total += total_tax
+                for line in voucher.line_ids:
+                    for tax_line in tax_pool.compute_all(cr, uid, tax, line.amount, 1).get('taxes', []):
+                        total_tax += tax_line.get('amount', 0.0)
+                    total += total_tax
             else:
                 for line in voucher.line_ids:
                     line_total = 0.0
@@ -413,31 +414,31 @@
 
         line_ids = resolve_o2m_operations(cr, uid, line_pool, line_ids, ["amount"], context)
 
+        total_tax = 0.0
         for line in line_ids:
             line_amount = 0.0
             line_amount = line.get('amount',0.0)
+
+            if tax_id:
+                tax = [tax_pool.browse(cr, uid, tax_id, context=context)]
+                if partner_id:
+                    partner = partner_pool.browse(cr, uid, partner_id, context=context) or False
+                    taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
+                    tax = tax_pool.browse(cr, uid, taxes, context=context)
+
+                if not tax[0].price_include:
+                    for tax_line in tax_pool.compute_all(cr, uid, tax, line_amount, 1).get('taxes', []):
+                        total_tax += tax_line.get('amount')
+
             voucher_total += line_amount
-
-        total = voucher_total
-        total_tax = 0.0
-        if tax_id:
-            tax = [tax_pool.browse(cr, uid, tax_id, context=context)]
-            if partner_id:
-                partner = partner_pool.browse(cr, uid, partner_id, context=context) or False
-                taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
-                tax = tax_pool.browse(cr, uid, taxes, context=context)
-
-            if not tax[0].price_include:
-                for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []):
-                    total_tax += tax_line.get('amount')
-                total += total_tax
+        total = voucher_total + total_tax
 
         res.update({
-            'amount':total or voucher_total,
-            'tax_amount':total_tax
+            'amount': total or voucher_total,
+            'tax_amount': total_tax
         })
         return {
-            'value':res
+            'value': res
         }
 
     def onchange_term_id(self, cr, uid, ids, term_id, amount):

_______________________________________________
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