[FIX] point_of_sale: decimal precision was hardcoded to 2 in various places
This commit is contained in:
parent
a2313b6311
commit
fade5ab2c2
|
@ -235,6 +235,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
ids: function(self){ return [self.pricelist.currency_id[0]]; },
|
||||
loaded: function(self, currencies){
|
||||
self.currency = currencies[0];
|
||||
if (self.currency.rounding > 0) {
|
||||
self.currency.decimals = Math.ceil(Math.log(1.0 / self.currency.rounding) / Math.log(10));
|
||||
} else {
|
||||
self.currency.decimals = 0;
|
||||
}
|
||||
|
||||
},
|
||||
},{
|
||||
model: 'product.packaging',
|
||||
|
@ -789,7 +795,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_di(parseFloat(price) || 0, 2);
|
||||
this.price = round_di(parseFloat(price) || 0, this.pos.currency.decimals);
|
||||
this.trigger('change',this);
|
||||
},
|
||||
get_unit_price: function(){
|
||||
|
@ -874,16 +880,20 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
this.cashregister = options.cashregister;
|
||||
this.name = this.cashregister.journal_id[1];
|
||||
this.selected = false;
|
||||
this.pos = options.pos;
|
||||
},
|
||||
//sets the amount of money on this payment line
|
||||
set_amount: function(value){
|
||||
this.amount = round_di(parseFloat(value) || 0, 2);
|
||||
this.amount = round_di(parseFloat(value) || 0, this.pos.currency.decimals);
|
||||
this.trigger('change:amount',this);
|
||||
},
|
||||
// returns the amount of money on this paymentline
|
||||
get_amount: function(){
|
||||
return this.amount;
|
||||
},
|
||||
get_amount_str: function(){
|
||||
return this.amount.toFixed(this.pos.currency.decimals);
|
||||
},
|
||||
set_selected: function(selected){
|
||||
if(this.selected !== selected){
|
||||
this.selected = selected;
|
||||
|
@ -1008,7 +1018,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
},
|
||||
addPaymentline: function(cashregister) {
|
||||
var paymentLines = this.get('paymentLines');
|
||||
var newPaymentline = new module.Paymentline({},{cashregister:cashregister});
|
||||
var newPaymentline = new module.Paymentline({},{cashregister:cashregister, pos:this.pos});
|
||||
if(cashregister.journal.type !== 'cash'){
|
||||
newPaymentline.set_amount( Math.max(this.getDueLeft(),0) );
|
||||
}
|
||||
|
|
|
@ -1130,7 +1130,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
paymentlines.bind('change:selected', this.rerender_paymentline, this);
|
||||
paymentlines.bind('change:amount', function(line){
|
||||
if(!line.selected && line.node){
|
||||
line.node.value = line.amount.toFixed(2);
|
||||
line.node.value = line.amount.toFixed(this.pos.currency.decimals);
|
||||
}
|
||||
this.update_payment_summary();
|
||||
},this);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
function openerp_pos_basewidget(instance, module){ //module is instance.point_of_sale
|
||||
|
||||
var round_di = instance.web.round_decimals;
|
||||
var round_pr = instance.web.round_precision
|
||||
|
||||
// This is a base class for all Widgets in the POS. It exposes relevant data to the
|
||||
// templates :
|
||||
// - widget.currency : { symbol: '$' | '€' | ..., position: 'before' | 'after }
|
||||
|
@ -25,12 +28,10 @@ function openerp_pos_basewidget(instance, module){ //module is instance.point_of
|
|||
this.currency = {symbol: '$', position: 'after', rounding: 0.01};
|
||||
}
|
||||
|
||||
var decimals = Math.max(0,Math.ceil(Math.log(1.0 / this.currency.rounding) / Math.log(10)));
|
||||
|
||||
this.format_currency = function(amount){
|
||||
if(typeof amount === 'number'){
|
||||
amount = Math.round(amount*100)/100;
|
||||
amount = amount.toFixed(decimals);
|
||||
amount = round_di(amount,this.currency.decimals).toFixed(this.currency.decimals);
|
||||
}
|
||||
if(this.currency.position === 'after'){
|
||||
return amount + ' ' + (this.currency.symbol || '');
|
||||
|
|
|
@ -873,7 +873,7 @@
|
|||
<div class='paymentline-name'>
|
||||
<t t-esc="line.name"/>
|
||||
</div>
|
||||
<input class='paymentline-input' type="number" step="0.01" t-att-value="line.get_amount().toFixed(2)" />
|
||||
<input class='paymentline-input' type="number" step="0.01" t-att-value="line.get_amount_str()" />
|
||||
<span class='paymentline-delete'>
|
||||
<img src="/point_of_sale/static/src/img/search_reset.gif" />
|
||||
</span>
|
||||
|
@ -886,7 +886,7 @@
|
|||
<t t-esc="line.name"/>
|
||||
</td>
|
||||
<td class="paymentline-amount pos-right-align">
|
||||
<input type="number" step="0.01" t-att-value="line.get_amount().toFixed(2)" />
|
||||
<input type="number" step="0.01" t-att-value="line.get_amount_str()" />
|
||||
<span class='delete-payment-line'><img src="/point_of_sale/static/src/img/search_reset.gif" /></span>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue