[MERGE] point_of_sale fix tax rouding
lp bug: https://launchpad.net/bugs/1157761 fixed bzr revid: al@openerp.com-20130411221119-cng0p4mct4pdf5tv
This commit is contained in:
commit
0dded37377
|
@ -909,6 +909,7 @@ class pos_order(osv.osv):
|
|||
account_tax_obj = self.pool.get('account.tax')
|
||||
user_proxy = self.pool.get('res.users')
|
||||
property_obj = self.pool.get('ir.property')
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
|
||||
period = account_period_obj.find(cr, uid, context=context)[0]
|
||||
|
||||
|
@ -1010,11 +1011,11 @@ class pos_order(osv.osv):
|
|||
computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit * (100.0-line.discount) / 100.0, line.qty)['taxes']
|
||||
|
||||
for tax in computed_taxes:
|
||||
tax_amount += round(tax['amount'], 2)
|
||||
tax_amount += cur_obj.round(cr, uid, cur, tax['amount'])
|
||||
group_key = (tax['tax_code_id'], tax['base_code_id'], tax['account_collected_id'], tax['id'])
|
||||
|
||||
group_tax.setdefault(group_key, 0)
|
||||
group_tax[group_key] += round(tax['amount'], 2)
|
||||
group_tax[group_key] += cur_obj.round(cr, uid, cur, tax['amount'])
|
||||
|
||||
amount = line.price_subtotal
|
||||
|
||||
|
|
|
@ -1,24 +1,8 @@
|
|||
function openerp_pos_models(instance, module){ //module is instance.point_of_sale
|
||||
var QWeb = instance.web.qweb;
|
||||
|
||||
// rounds a value with a fixed number of decimals.
|
||||
// round(3.141492,2) -> 3.14
|
||||
function round(value,decimals){
|
||||
var mult = Math.pow(10,decimals || 0);
|
||||
return Math.round(value*mult)/mult;
|
||||
}
|
||||
window.round = round;
|
||||
|
||||
// rounds a value with decimal form precision
|
||||
// round(3.141592,0.025) ->3.125
|
||||
function round_pr(value,precision){
|
||||
if(!precision || precision < 0){
|
||||
throw new Error('round_pr(): needs a precision greater than zero, got '+precision+' instead');
|
||||
}
|
||||
return Math.round(value / precision) * precision;
|
||||
}
|
||||
window.round_pr = round_pr;
|
||||
|
||||
var round_di = instance.web.round_decimals;
|
||||
var round_pr = instance.web.round_precision
|
||||
|
||||
// The PosModel contains the Point Of Sale's representation of the backend.
|
||||
// Since the PoS must work in standalone ( Without connection to the server )
|
||||
|
@ -391,7 +375,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
var quant = Math.max(parseFloat(quantity) || 0, 0);
|
||||
var unit = this.get_unit();
|
||||
if(unit){
|
||||
this.quantity = Math.max(unit.rounding, Math.round(quant / unit.rounding) * unit.rounding);
|
||||
this.quantity = Math.max(unit.rounding, round_pr(quant, unit.rounding));
|
||||
this.quantityStr = this.quantity.toFixed(Math.max(0,Math.ceil(Math.log(1.0 / unit.rounding) / Math.log(10))));
|
||||
}else{
|
||||
this.quantity = quant;
|
||||
|
@ -484,7 +468,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
},
|
||||
// changes the base price of the product for this orderline
|
||||
set_unit_price: function(price){
|
||||
this.price = round(parseFloat(price) || 0, 2);
|
||||
this.price = round_di(parseFloat(price) || 0, 2);
|
||||
this.trigger('change');
|
||||
},
|
||||
get_unit_price: function(){
|
||||
|
|
|
@ -983,7 +983,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
}
|
||||
|
||||
if(this.pos_widget.action_bar){
|
||||
this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0);
|
||||
this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0.000001);
|
||||
}
|
||||
},
|
||||
set_numpad_state: function(numpadState) {
|
||||
|
|
Loading…
Reference in New Issue