[FIX] point of sale: function is_paid:

When rounding globally, the function compute_all in charge to compute the taxes for
each line uses a very high currency rounding to avoid rounding per line.
The round must be done on the sum of each total amount line with taxes. To validate a payment with the pos,
the function is_paid verified that this sum is the same that the amount just paid.
Inspired from "sale.order.line", the precision of 'price_unit' and 'price_subtotal' in "pos.order.line"
must be taken from 'Product Price' to avoid rounding per line.

ps: we could not use the function get_all_prices to round globally because it used on every line.

Fixes #6681
Closes #6682
opw:639686
This commit is contained in:
Goffin Simon 2015-05-16 15:42:21 +02:00
parent 6d25a1a18a
commit c5a613840f
2 changed files with 14 additions and 14 deletions

View File

@ -1335,9 +1335,9 @@ class pos_order_line(osv.osv):
'name': fields.char('Line No', required=True, copy=False),
'notice': fields.char('Discount Notice'),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True, change_default=True),
'price_unit': fields.float(string='Unit Price', digits_compute=dp.get_precision('Account')),
'price_unit': fields.float(string='Unit Price', digits_compute=dp.get_precision('Product Price')),
'qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoS')),
'price_subtotal': fields.function(_amount_line_all, multi='pos_order_line_amount', digits_compute=dp.get_precision('Account'), string='Subtotal w/o Tax', store=True),
'price_subtotal': fields.function(_amount_line_all, multi='pos_order_line_amount', digits_compute=dp.get_precision('Product Price'), string='Subtotal w/o Tax', store=True),
'price_subtotal_incl': fields.function(_amount_line_all, multi='pos_order_line_amount', digits_compute=dp.get_precision('Account'), string='Subtotal', store=True),
'discount': fields.float('Discount (%)', digits_compute=dp.get_precision('Account')),
'order_id': fields.many2one('pos.order', 'Order Ref', ondelete='cascade'),

View File

@ -1118,29 +1118,29 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return this.get('name');
},
getSubtotal : function(){
return (this.get('orderLines')).reduce((function(sum, orderLine){
return round_pr((this.get('orderLines')).reduce((function(sum, orderLine){
return sum + orderLine.get_display_price();
}), 0);
}), 0), this.pos.currency.rounding);
},
getTotalTaxIncluded: function() {
return (this.get('orderLines')).reduce((function(sum, orderLine) {
return round_pr((this.get('orderLines')).reduce((function(sum, orderLine) {
return sum + orderLine.get_price_with_tax();
}), 0);
}), 0), this.pos.currency.rounding);
},
getDiscountTotal: function() {
return (this.get('orderLines')).reduce((function(sum, orderLine) {
return round_pr((this.get('orderLines')).reduce((function(sum, orderLine) {
return sum + (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
}), 0);
}), 0), this.pos.currency.rounding);
},
getTotalTaxExcluded: function() {
return (this.get('orderLines')).reduce((function(sum, orderLine) {
return round_pr((this.get('orderLines')).reduce((function(sum, orderLine) {
return sum + orderLine.get_price_without_tax();
}), 0);
}), 0), this.pos.currency.rounding);
},
getTax: function() {
return (this.get('orderLines')).reduce((function(sum, orderLine) {
return round_pr((this.get('orderLines')).reduce((function(sum, orderLine) {
return sum + orderLine.get_tax();
}), 0);
}), 0), this.pos.currency.rounding);
},
getTaxDetails: function(){
var details = {};
@ -1164,9 +1164,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return fulldetails;
},
getPaidTotal: function() {
return (this.get('paymentLines')).reduce((function(sum, paymentLine) {
return round_pr((this.get('paymentLines')).reduce((function(sum, paymentLine) {
return sum + paymentLine.get_amount();
}), 0);
}), 0), this.pos.currency.rounding);
},
getChange: function() {
return this.getPaidTotal() - this.getTotalTaxIncluded();