[FIX] point_of_sale: various fixes for the payment screen
bzr revid: fva@openerp.com-20120703165039-xu538hp9e6mnnepv
This commit is contained in:
@@ -507,29 +507,40 @@
|
||||
.point-of-sale .pos-payment-container {
|
||||
text-align: left;
|
||||
}
|
||||
.point-of-sale .pos-payment-container .payment-due {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
padding: 3px 6px 0px 6px;
|
||||
background-color: white;
|
||||
border:1px solid grey;
|
||||
border-radius: 3px;
|
||||
.point-of-sale .pos-payment-container .left-block{
|
||||
display: inline-block;
|
||||
width:49%;
|
||||
margin:0;
|
||||
padding:0;
|
||||
text-align:left;
|
||||
}
|
||||
.point-of-sale .pos-payment-container .header{
|
||||
margin-top: 50px;
|
||||
margin-bottom:20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.point-of-sale .pos-payment-container .infoline{
|
||||
margin-top:5px;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
.point-of-sale .pos-payment-container .right-block{
|
||||
display: inline-block;
|
||||
width:49%;
|
||||
margin:0;
|
||||
padding:0;
|
||||
text-align:right;
|
||||
}
|
||||
.point-of-sale .pos-payment-container table {
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.point-of-sale .pos-payment-container .paymentline-type {
|
||||
font-size: 0.8em;
|
||||
font-weight: bold;
|
||||
.point-of-sale .pos-payment-container td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.point-of-sale .screen button {
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
padding: 7px 0 7px 0;
|
||||
font-size: 0.8em;
|
||||
.point-of-sale .pos-payment-container .paymentline-type {
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
/* c) The receipt screen */
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
function openerp_pos_devices(instance,module){ //module is instance.point_of_sale
|
||||
|
||||
var QWeb = instance.web.qweb; //TODO FIXME this should NOT be of any use in this file
|
||||
|
||||
window.debug_devices = new (instance.web.Class.extend({
|
||||
active: false,
|
||||
payment_status: 'waiting_for_payment',
|
||||
|
||||
@@ -513,7 +513,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
// An orderline contains a product, its quantity, its price, discount. etc.
|
||||
// An Order contains zero or more Orderlines.
|
||||
module.Orderline = Backbone.Model.extend({
|
||||
initialize: function(options){
|
||||
initialize: function(attr,options){
|
||||
this.pos = options.pos;
|
||||
this.order = options.order;
|
||||
this.product = options.product;
|
||||
@@ -589,7 +589,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
is_selected: function(){
|
||||
return this.selected;
|
||||
},
|
||||
|
||||
// when we add an new orderline we want to merge it with the last line to see reduce the number of items
|
||||
// in the orderline. This returns true if it makes sense to merge the two
|
||||
can_be_merged_with: function(orderline){
|
||||
@@ -691,11 +690,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
model: module.Orderline,
|
||||
});
|
||||
|
||||
// Every PaymentLine has all the attributes of the corresponding CashRegister.
|
||||
// Every PaymentLine contains a cashregister and an amount CashRegister.
|
||||
module.Paymentline = Backbone.Model.extend({
|
||||
initialize: function(cashRegister) {
|
||||
initialize: function(attributes, options) {
|
||||
this.amount = 0;
|
||||
this.cashregister = cashRegister;
|
||||
this.cashregister = options.cashRegister;
|
||||
},
|
||||
//sets the amount of money on this payment line
|
||||
set_amount: function(value){
|
||||
@@ -714,7 +713,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
export_as_JSON: function(){
|
||||
return {
|
||||
name: instance.web.datetime_to_str(new Date()),
|
||||
statement_id: this.get('id'),
|
||||
statement_id: this.cashregister.get('id'),
|
||||
account_id: (this.cashregister.get('account_id'))[0],
|
||||
journal_id: (this.cashregister.get('journal_id'))[0],
|
||||
amount: this.get_amount()
|
||||
@@ -746,8 +745,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
paymentLines: new module.PaymentlineCollection(),
|
||||
name: "Order " + this.generateUniqueId(),
|
||||
});
|
||||
this.pos = attributes.pos; //TODO put that in set and remember to use 'get' to read it ...
|
||||
this.pos_widget = attributes.pos_widget; //FIXME we shouldn't depend on pos_widget in the models
|
||||
this.pos = attributes.pos;
|
||||
this.selected_orderline = undefined;
|
||||
return this;
|
||||
},
|
||||
@@ -758,7 +756,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
var attr = product.toJSON();
|
||||
attr.pos = this.pos;
|
||||
attr.order = this;
|
||||
var line = new module.Orderline({pos: this.pos, order: this, product: product});
|
||||
var line = new module.Orderline({}, {pos: this.pos, order: this, product: product});
|
||||
var self = this;
|
||||
|
||||
var last_orderline = this.getLastOrderline();
|
||||
@@ -777,13 +775,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||
return this.get('orderLines').at(this.get('orderLines').length -1);
|
||||
},
|
||||
addPaymentLine: function(cashRegister) {
|
||||
var newPaymentline;
|
||||
newPaymentline = new module.Paymentline(cashRegister);
|
||||
/* TODO: Should be 0 for cash-like accounts */
|
||||
//FIXME the following 'set' call calls this method once again via callback
|
||||
// events. Are we sure that it's what we want ???
|
||||
newPaymentline.set_amount( this.getDueLeft() );
|
||||
this.get('paymentLines').add(newPaymentline);
|
||||
var paymentLines = this.get('paymentLines');
|
||||
var newPaymentline = new module.Paymentline({},{cashRegister:cashRegister});
|
||||
if(cashRegister.get('journal').type !== 'cash'){
|
||||
newPaymentline.set_amount( this.getDueLeft() );
|
||||
}
|
||||
paymentLines.add(newPaymentline);
|
||||
},
|
||||
getName: function() {
|
||||
return this.get('name');
|
||||
|
||||
@@ -757,18 +757,19 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
||||
this.updatePaymentSummary();
|
||||
},
|
||||
deleteLine: function(lineWidget) {
|
||||
this.currentPaymentLines.remove([lineWidget.model]);
|
||||
this.currentPaymentLines.remove([lineWidget.payment_line]);
|
||||
},
|
||||
updatePaymentSummary: function() {
|
||||
var currentOrder, dueTotal, paidTotal, remaining, remainingAmount;
|
||||
currentOrder = this.pos.get('selectedOrder');
|
||||
paidTotal = currentOrder.getPaidTotal();
|
||||
dueTotal = currentOrder.getTotal();
|
||||
this.$element.find('#payment-due-total').html(dueTotal.toFixed(2));
|
||||
this.$element.find('#payment-paid-total').html(paidTotal.toFixed(2));
|
||||
remainingAmount = dueTotal - paidTotal;
|
||||
remaining = remainingAmount > 0 ? 0 : (-remainingAmount).toFixed(2);
|
||||
$('#payment-remaining').html(remaining);
|
||||
var currentOrder = this.pos.get('selectedOrder');
|
||||
var paidTotal = currentOrder.getPaidTotal();
|
||||
var dueTotal = currentOrder.getTotal();
|
||||
var remaining = dueTotal > paidTotal ? dueTotal - paidTotal : 0;
|
||||
var change = paidTotal > dueTotal ? paidTotal - dueTotal : 0;
|
||||
|
||||
this.$('#payment-due-total').html(dueTotal.toFixed(2));
|
||||
this.$('#payment-paid-total').html(paidTotal.toFixed(2));
|
||||
this.$('#payment-remaining').html(remaining.toFixed(2));
|
||||
this.$('#payment-change').html(change.toFixed(2));
|
||||
},
|
||||
set_numpad_state: function(numpadState) {
|
||||
if (this.numpadState) {
|
||||
|
||||
@@ -162,36 +162,50 @@
|
||||
<div class="pos-step-container">
|
||||
<div class="pos-payment-container">
|
||||
<br />
|
||||
<table>
|
||||
<tr>
|
||||
<td class="paymentline-type">Total:</td>
|
||||
<td class="paymentline-amount pos-right-align">
|
||||
<t t-if="widget.currency.position == 'before'" t-esc="widget.currency.symbol"/>
|
||||
<span id="payment-due-total"></span>
|
||||
<t t-if="widget.currency.position == 'after'" t-esc="widget.currency.symbol"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="header">
|
||||
<span class="left-block">
|
||||
Total:
|
||||
</span>
|
||||
<span class="right-block">
|
||||
<t t-if="widget.currency.position == 'before'" t-esc="widget.currency.symbol"/>
|
||||
<span id="payment-due-total"></span>
|
||||
<t t-if="widget.currency.position == 'after'" t-esc="widget.currency.symbol"/>
|
||||
</span>
|
||||
</div>
|
||||
<table id="paymentlines">
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="paymentline-type">Paid:</td>
|
||||
<td class="paymentline-amount pos-right-align">
|
||||
<div class="footer">
|
||||
<div class="infoline">
|
||||
<span class='left-block'>
|
||||
Paid:
|
||||
</span>
|
||||
<span class='right-block'>
|
||||
<t t-if="widget.currency.position == 'before'" t-esc="widget.currency.symbol"/>
|
||||
<span id="payment-paid-total"></span>
|
||||
<t t-if="widget.currency.position == 'after'" t-esc="widget.currency.symbol"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paymentline-type">Change:</td>
|
||||
<td class="paymentline-amount pos-right-align">
|
||||
</span>
|
||||
</div>
|
||||
<div class="infoline">
|
||||
<span class='left-block'>
|
||||
Remaining:
|
||||
</span>
|
||||
<span class='right-block'>
|
||||
<t t-if="widget.currency.position == 'before'" t-esc="widget.currency.symbol"/>
|
||||
<span id="payment-remaining"></span>
|
||||
<t t-if="widget.currency.position == 'after'" t-esc="widget.currency.symbol"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</span>
|
||||
</div>
|
||||
<div class="infoline">
|
||||
<span class='left-block'>
|
||||
Change:
|
||||
</span>
|
||||
<span class='right-block'>
|
||||
<t t-if="widget.currency.position == 'before'" t-esc="widget.currency.symbol"/>
|
||||
<span id="payment-change"></span>
|
||||
<t t-if="widget.currency.position == 'after'" t-esc="widget.currency.symbol"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -465,7 +479,7 @@
|
||||
<table>
|
||||
<tr t-foreach="widget.currentPaymentLines.toArray()" t-as="pline">
|
||||
<td>
|
||||
<t t-esc="pline.get('journal_id')[1]"/>
|
||||
<t t-esc="pline.get_cashregister().get('journal_id')[1]"/>
|
||||
</td>
|
||||
<td class="pos-right-align">
|
||||
<t t-esc="widget.format_currency((pline.get_amount()).toFixed(2))"/>
|
||||
|
||||
Reference in New Issue
Block a user