@@ -105,9 +108,9 @@
- Tél. : [[ o.address_invoice_id.phone or '' ]]
+ Tel. : [[ o.address_invoice_id.phone or '' ]]
Fax : [[ o.address_invoice_id.fax or '' ]]
- TVAÂ : [[ o.partner_id.vat or '' ]]
+ VATÂ : [[ o.partner_id.vat or '' ]]
@@ -152,10 +155,10 @@
Unit Price
- Disc.
+ Disc. (%)
|
- Net Price
+ Price
|
@@ -176,7 +179,7 @@
[[ '%.2f' % l.price_unit ]]
- [[ '%.3f' % (l.discount or 0.0) ]]
+ [[ '%.2f' % (l.discount or 0.0) ]]
|
[[ '%.2f' %l.price_subtotal ]] [[o.currency_id.code ]]
@@ -229,7 +232,7 @@
- Subtotal :
+ Total (excl. taxes):
|
[[ '%.2f' % o.amount_untaxed ]] [[o.currency_id.code ]]
@@ -237,7 +240,7 @@
|
- Taxes :
+ Taxes:
|
[[ '%.2f' % o.amount_tax ]] [[o.currency_id.code ]]
@@ -245,7 +248,7 @@
|
- Total :
+ Total (incl. taxes):
|
[[ '%.2f' % o.amount_total ]] [[o.currency_id.code ]]
diff --git a/addons/account_tax_include/account.py b/addons/account_tax_include/account.py
index 59b1bbbe369..832cc2f92d8 100644
--- a/addons/account_tax_include/account.py
+++ b/addons/account_tax_include/account.py
@@ -40,24 +40,22 @@ class account_tax(osv.osv):
_defaults = {
'python_compute_inv': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n\nresult = price_unit * 0.10''',
}
- def _unit_compute_inv(self, cr, uid, ids, price_unit, address_id=None):
- taxes = self.browse(cr, uid, ids)
- return self._unit_compute_inv_br(cr, uid, taxes, price_unit, address_id)
-
- def _unit_compute_inv_br(self, cr, uid, taxes, price_unit, address_id=None):
+ def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None):
taxes = self._applicable(cr, uid, taxes, price_unit, address_id)
res = []
+ taxes.reverse()
+ cur_price_unit=price_unit
for tax in taxes:
# we compute the amount for the current tax object and append it to the result
if tax.type=='percent':
- amount = price_unit - (price_unit / (1 + tax.amount))
- res.append({'id':tax.id, 'name':tax.name, 'amount':amount, 'account_collected_id':tax.account_collected_id.id, 'account_paid_id':tax.account_paid_id.id})
+ amount = cur_price_unit - (cur_price_unit / (1 + tax.amount))
+ res.append({'id':tax.id, 'name':tax.name, 'amount':amount, 'account_collected_id':tax.account_collected_id.id, 'account_paid_id':tax.account_paid_id.id, 'base_code_id': tax.base_code_id.id, 'ref_base_code_id': tax.ref_base_code_id.id, 'sequence': tax.sequence, 'base_sign': tax.base_sign, 'ref_base_sign': tax.ref_base_sign, 'price_unit': cur_price_unit - amount,})
elif tax.type=='fixed':
- res.append({'id':tax.id, 'name':tax.name, 'amount':tax.amount, 'account_collected_id':tax.account_collected_id.id, 'account_paid_id':tax.account_paid_id.id})
+ res.append({'id':tax.id, 'name':tax.name, 'amount':tax.amount, 'account_collected_id':tax.account_collected_id.id, 'account_paid_id':tax.account_paid_id.id, 'base_code_id': tax.base_code_id.id, 'ref_base_code_id': tax.ref_base_code_id.id, 'sequence': tax.sequence, 'base_sign': tax.base_sign, 'ref_base_sign': tax.ref_base_sign, 'price_unit': 1,})
elif tax.type=='code':
address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None
- localdict = {'price_unit':price_unit, 'address':address}
+ localdict = {'price_unit':cur_price_unit, 'address':address}
exec tax.python_compute_inv in localdict
amount = localdict['result']
res.append({
@@ -65,7 +63,13 @@ class account_tax(osv.osv):
'name': tax.name,
'amount': amount,
'account_collected_id': tax.account_collected_id.id,
- 'account_paid_id': tax.account_paid_id.id
+ 'account_paid_id': tax.account_paid_id.id,
+ 'base_code_id': tax.base_code_id.id,
+ 'ref_base_code_id': tax.ref_base_code_id.id,
+ 'sequence': tax.sequence,
+ 'base_sign': tax.base_sign,
+ 'ref_base_sign': tax.ref_base_sign,
+ 'price_unit': cur_price_unit - amount,
})
amount2 = res[-1]['amount']
if len(tax.child_ids):
@@ -75,11 +79,14 @@ class account_tax(osv.osv):
else:
amount = amount2
for t in tax.child_ids:
- parent_tax = self._unit_compute_inv_br(cr, uid, [t], amount, address_id)
+ parent_tax = self._unit_compute_inv(cr, uid, [t], amount, address_id)
res.extend(parent_tax)
+ if tax.include_base_amount:
+ cur_price_unit-=amount
+ taxes.reverse()
return res
- def compute_inv(self, cr, uid, ids, price_unit, quantity, address_id=None):
+ def compute_inv(self, cr, uid, taxes, price_unit, quantity, address_id=None):
"""
Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
Price Unit is a VAT included price
@@ -89,7 +96,7 @@ class account_tax(osv.osv):
tax = {'name':'', 'amount':0.0, 'account_collected_id':1, 'account_paid_id':2}
one tax for each tax id in IDS and their childs
"""
- res = self._unit_compute_inv(cr, uid, ids, price_unit, address_id)
+ res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id)
for r in res:
r['amount'] *= quantity
return res
diff --git a/addons/account_tax_include/invoice_tax_incl.py b/addons/account_tax_include/invoice_tax_incl.py
index 557b3d628e0..a5ed9b227c7 100644
--- a/addons/account_tax_include/invoice_tax_incl.py
+++ b/addons/account_tax_include/invoice_tax_incl.py
@@ -90,6 +90,8 @@ class account_invoice_line(osv.osv):
res = []
tax_grouped = {}
tax_obj = self.pool.get('account.tax')
+ cur_obj = self.pool.get('res.currency')
+ cur = inv.currency_id
for line in inv.invoice_line:
res.append( {
'type':'src',
@@ -100,37 +102,41 @@ class account_invoice_line(osv.osv):
'account_id':line.account_id.id,
'tax_amount': 0.0
})
- for tax2 in line.invoice_line_tax_id:
- for tax in tax_obj.compute_inv(cr, uid, [tax2.id], line.price_unit, line.quantity, inv.address_invoice_id.id):
- tax['amount'] = round(tax['amount']*(1.0- (line['discount'] or 0.0)/100.0),2)
- tax['sequence'] = tax2.sequence
+ for tax in tax_obj.compute_inv(cr, uid, line.invoice_line_tax_id, (line.price_unit *(1.0-(line['discount'] or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id):
+ tax['amount'] = cur_obj.round(cr, uid, cur, tax['amount'])
+ tax['sequence'] = tax['sequence']
- res[-1]['tax_amount'] += (line['price_unit'] * line['quantity'] * (1.0- (line['discount'] or 0.0)/100.0) * tax2.base_sign)
- #
- # Setting the tax account and amount for the line
- #
- if inv.type in ('out_invoice','in_refund'):
- res[-1]['tax_code_id'] = tax2.base_code_id.id
- else:
- res[-1]['tax_code_id'] = tax2.ref_base_code_id.id
+ #res[-1]['tax_amount'] += (line['price_unit'] * line['quantity'] * (1.0- (line['discount'] or 0.0)/100.0) * tax2.base_sign)
+ #
+ # Setting the tax account and amount for the line
+ #
+ if inv.type in ('out_invoice','out_refund'):
+ res[-1]['tax_code_id'] = tax['base_code_id']
+ res[-1]['tax_amount'] = tax['amount'] * tax['base_sign']
+ else:
+ res[-1]['tax_code_id'] = tax['ref_base_code_id']
+ res[-1]['tax_amount'] = tax['amount'] * tax['ref_base_sign']
+ if inv.type in ('out_refund','in_refund'):
+ res[-1]['tax_amount'] = -res[-1]['tax_amount']
- if inv.type in ('out_invoice','in_refund'):
- tax['account_id'] = tax['account_collected_id'] or line.account_id.id
- else:
- tax['account_id'] = tax['account_paid_id'] or line.account_id.id
- #
- # Revoir la clé: tax.id ?
- #
- key = (tax['id'], tax['account_id'])
-
- res[-1]['price'] -= tax['amount']
- res[-1]['tax_amount'] -= (tax['amount']* tax2.base_sign)
- if not key in tax_grouped:
- tax_grouped[key] = tax
- tax_grouped[key]['base'] = res[-1]['price']
- else:
- tax_grouped[key]['amount'] += tax['amount']
- tax_grouped[key]['base'] += res[-1]['price']
+ if inv.type in ('out_invoice','out_refund'):
+ tax['account_id'] = tax['account_collected_id'] or line.account_id.id
+ else:
+ tax['account_id'] = tax['account_paid_id'] or line.account_id.id
+ #
+ # Revoir la clé: tax.id ?
+ #
+ key = (res[-1]['tax_code_id'], tax['account_id'])
+ #res[-1]['price'] -= tax['amount']
+ #res[-1]['tax_amount'] -= (tax['amount']* tax2.base_sign)
+ if not key in tax_grouped:
+ tax_grouped[key] = tax
+ #tax_grouped[key]['base'] = res[-1]['price']
+ tax_grouped[key]['base'] = tax['price_unit'] * line['quantity']
+ else:
+ tax_grouped[key]['amount'] += tax['amount']
+ #tax_grouped[key]['base'] += res[-1]['price']
+ tax_grouped[key]['base'] += tax['price_unit'] * line['quantity']
# delete automatic tax lines for this invoice
cr.execute("DELETE FROM account_invoice_tax WHERE NOT manual AND invoice_id=%d", (invoice_id,))
self.move_line_tax_create(cr, uid, inv, tax_grouped, context)
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index be673f5286c..5a74798e4a4 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -65,9 +65,8 @@ class purchase_order(osv.osv):
val = 0.0
cur=order.pricelist_id.currency_id
for line in order.order_line:
- for tax in line.taxes_id:
- for c in self.pool.get('account.tax').compute(cr, uid, [tax.id], line.price_unit, line.product_qty, order.partner_address_id.id):
- val+= cur_obj.round(cr, uid, cur, c['amount'])
+ for c in self.pool.get('account.tax').compute(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id):
+ val+= cur_obj.round(cr, uid, cur, c['amount'])
res[order.id]=cur_obj.round(cr, uid, cur, val)
return res
diff --git a/addons/purchase_tax_include/purchase_tax_incl.py b/addons/purchase_tax_include/purchase_tax_incl.py
index 9f686decc21..a9c5146837b 100644
--- a/addons/purchase_tax_include/purchase_tax_incl.py
+++ b/addons/purchase_tax_include/purchase_tax_incl.py
@@ -50,17 +50,18 @@ class purchase_order(osv.osv):
def _amount_tax(self, cr, uid, ids, field_name, arg, context):
res = {}
+ cur_obj=self.pool.get('res.currency')
for order in self.browse(cr, uid, ids):
val = 0.0
+ cur=order.pricelist_id.currency_id
for line in order.order_line:
- for tax in line.taxes_id:
- if order.price_type=='tax_included':
- ttt = self.pool.get('account.tax').compute_inv(cr, uid, [tax.id], line.price_unit, line.product_qty, order.partner_address_id.id)
- else:
- ttt = self.pool.get('account.tax').compute(cr, uid, [tax.id], line.price_unit, line.product_qty, order.partner_address_id.id)
- for c in ttt:
- val += round(c['amount'], 2)
- res[order.id]=round(val,2)
+ if order.price_type=='tax_included':
+ ttt = self.pool.get('account.tax').compute_inv(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id)
+ else:
+ ttt = self.pool.get('account.tax').compute(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id)
+ for c in ttt:
+ val += cur_obj.round(cr, uid, cur, c['amount'])
+ res[order.id]=cur_obj.round(cr, uid, cur, val)
return res
_inherit = "purchase.order"
_columns = {
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 84f7e221c94..53cc29ffcf5 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -85,9 +85,8 @@ class sale_order(osv.osv):
val = 0.0
cur=order.pricelist_id.currency_id
for line in order.order_line:
- for tax in line.tax_id:
- for c in self.pool.get('account.tax').compute(cr, uid, [tax.id], line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, order.partner_invoice_id.id):
- val+= cur_obj.round(cr, uid, cur, c['amount'])
+ for c in self.pool.get('account.tax').compute(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, order.partner_invoice_id.id):
+ val+= cur_obj.round(cr, uid, cur, c['amount'])
res[order.id]=cur_obj.round(cr, uid, cur, val)
return res
diff --git a/addons/sale_rebate/sale.py b/addons/sale_rebate/sale.py
index 81dc61a965d..290481be30d 100644
--- a/addons/sale_rebate/sale.py
+++ b/addons/sale_rebate/sale.py
@@ -64,13 +64,14 @@ class sale_order_rebate(osv.osv):
def _amount_tax(self, cr, uid, ids, field_name, arg, context):
res = {}
+ cur_obj=self.pool.get('res.currency')
for order in self.browse(cr, uid, ids):
val = 0.0
+ cur=order.pricelist_id.currency_id
for line in order.order_line:
- for tax in line.tax_id:
- for c in self.pool.get('account.tax').compute(cr, uid, [tax.id], line.price_unit, line.product_uom_qty, order.partner_invoice_id.id):
- val += c['amount'] * (100.0 - order.rebate_percent) / 100.0
- res[order.id] = val
+ for c in self.pool.get('account.tax').compute(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, order.partner_invoice_id.id):
+ val += cur_obj.round(cr, uid, cur, (c['amount'] * (100.0 - order.rebate_percent) / 100.0))
+ res[order.id] = cur_obj.round(cr, uid, cur, val)
return res
_columns = {
diff --git a/addons/sale_tax_include/sale_tax_incl.py b/addons/sale_tax_include/sale_tax_incl.py
index 094f6624433..0636dacc097 100644
--- a/addons/sale_tax_include/sale_tax_incl.py
+++ b/addons/sale_tax_include/sale_tax_incl.py
@@ -50,17 +50,18 @@ class sale_order(osv.osv):
def _amount_tax(self, cr, uid, ids, field_name, arg, context):
res = {}
+ cur_obj=self.pool.get('res.currency')
for order in self.browse(cr, uid, ids):
val = 0.0
+ cur=order.pricelist_id.currency_id
for line in order.order_line:
- for tax in line.tax_id:
- if order.price_type=='tax_included':
- ttt = self.pool.get('account.tax').compute_inv(cr, uid, [tax.id], line.price_unit * (1-(line.discount or 0)/100.0), line.product_uom_qty, order.partner_invoice_id.id)
- else:
- ttt = self.pool.get('account.tax').compute(cr, uid, [tax.id], line.price_unit * (1-(line.discount or 0)/100.0), line.product_uom_qty, order.partner_invoice_id.id)
- for c in ttt:
- val += round(c['amount'], 2)
- res[order.id]=round(val,2)
+ if order.price_type=='tax_included':
+ ttt = self.pool.get('account.tax').compute_inv(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0)/100.0), line.product_uom_qty, order.partner_invoice_id.id)
+ else:
+ ttt = self.pool.get('account.tax').compute(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0)/100.0), line.product_uom_qty, order.partner_invoice_id.id)
+ for c in ttt:
+ val += cur_obj.round(cr, uid, cur, c['amount'])
+ res[order.id]=cur_obj.round(cr, uid, cur, val)
return res
_inherit = "sale.order"
_columns = {
| |