fixed erpnext/frappe#1441 and other pos related cleanups
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js
index 480ce02..fc6190a 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.js
+++ b/erpnext/accounts/doctype/sales_invoice/pos.js
@@ -19,7 +19,7 @@
<table class="table table-condensed table-hover" id="cart" style="table-layout: fixed;">\
<thead>\
<tr>\
- <th style="width: 40%">Item</th>\
+ <th style="width: 40%">'+__("Item")+'</th>\
<th style="width: 9%"></th>\
<th style="width: 17%; text-align: right;">Qty</th>\
<th style="width: 9%"></th>\
@@ -35,7 +35,7 @@
<div class="net-total-area">\
<table class="table table-condensed">\
<tr>\
- <td><b>Net Total</b></td>\
+ <td><b>'+__("Net Total")+'</b></td>\
<td style="text-align: right;" class="net-total"></td>\
</tr>\
</table>\
@@ -44,7 +44,7 @@
<table class="table table-condensed">\
<thead>\
<tr>\
- <th style="width: 60%">Taxes</th>\
+ <th style="width: 60%">'+__("Taxes")+'</th>\
<th style="width: 40%; text-align: right;"></th>\
</tr>\
</thead>\
@@ -55,7 +55,7 @@
<div class="discount-amount-area">\
<table class="table table-condensed">\
<tr>\
- <td style="vertical-align: middle;" width="50%"><b>Discount Amount</b></td>\
+ <td style="vertical-align: middle;" width="50%"><b>'+__("Discount Amount")+'</b></td>\
<td width="20%"></td>\
<td style="text-align: right;">\
<input type="text" class="form-control discount-amount" \
@@ -67,23 +67,32 @@
<div class="grand-total-area">\
<table class="table table-condensed">\
<tr>\
- <td style="vertical-align: middle;"><b>Grand Total</b></td>\
+ <td style="vertical-align: middle;"><b>'+__("Grand Total")+'</b></td>\
<td style="text-align: right; font-size: 200%; \
font-size: bold;" class="grand-total"></td>\
</tr>\
</table>\
</div>\
+ <div class="paid-amount-area">\
+ <table class="table table-condensed">\
+ <tr>\
+ <td style="vertical-align: middle;">'+__("Amount Paid")+'</td>\
+ <td style="text-align: right; \
+ font-size: bold;" class="paid-amount"></td>\
+ </tr>\
+ </table>\
+ </div>\
</div>\
</div>\
<br><br>\
<div class="row">\
<div class="col-sm-9">\
<button class="btn btn-success btn-lg make-payment">\
- <i class="icon-money"></i> Make Payment</button>\
+ <i class="icon-money"></i> '+__("Make Payment")+'</button>\
</div>\
<div class="col-sm-3">\
<button class="btn btn-default btn-lg remove-items" style="display: none;">\
- <i class="icon-trash"></i> Del</button>\
+ <i class="icon-trash"></i> '+__("Del")+'</button>\
</div>\
</div>\
<br><br>\
@@ -439,6 +448,12 @@
me.frm.doc.currency));
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc[this.grand_total],
me.frm.doc.currency));
+
+ $(".paid-amount-area").toggle(!!this.frm.doc.paid_amount);
+ if(this.frm.doc.paid_amount) {
+ this.wrapper.find(".paid-amount").text(format_currency(this.frm.doc.paid_amount,
+ me.frm.doc.currency));
+ }
},
call_when_local: function() {
var me = this;
@@ -484,25 +499,16 @@
disable_text_box_and_button: function() {
var me = this;
// if form is submitted & cancelled then disable all input box & buttons
- if (this.frm.doc.docstatus>=1) {
- $(this.wrapper).find('input, button').each(function () {
- $(this).prop('disabled', true);
- });
- $(this.wrapper).find(".remove-items").hide();
- $(this.wrapper).find(".make-payment").hide();
- }
- else {
- $(this.wrapper).find('input, button').each(function () {
- $(this).prop('disabled', false);
- });
- $(this.wrapper).find(".make-payment").show();
- }
+ $(this.wrapper)
+ .find(".remove-items, .make-payment, .increase-qty, .decrease-qty")
+ .toggle(this.frm.doc.docstatus===0);
+
+ $(this.wrapper).find('input, button').prop("disabled", !(this.frm.doc.docstatus===0));
},
hide_payment_button: function() {
- var me = this;
- // Show Make Payment button only in Sales Invoice
- if (this.frm.doctype != "Sales Invoice")
- $(this.wrapper).find(".make-payment").hide();
+ $(this.wrapper)
+ .find(".make-payment")
+ .toggle(this.frm.doctype == "Sales Invoice" && this.frm.doc.is_pos);
},
refresh_delete_btn: function() {
$(this.wrapper).find(".remove-items").toggle($(".item-cart .warning").length ? true : false);
@@ -568,6 +574,9 @@
frappe.call({
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_mode_of_payment',
callback: function(r) {
+ if(!r.message.length) {
+ msgprint(__("Please add to Modes of Payment from Setup."))
+ }
for (x=0; x<=r.message.length - 1; x++) {
mode_of_payment.push(r.message[x].name);
}
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 2286ed6..c2d7c4b 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -49,4 +49,4 @@
@frappe.whitelist()
def get_mode_of_payment():
- return frappe.db.sql("""select name from `tabMode of Payment`""", as_dict=1)
\ No newline at end of file
+ return frappe.get_list("Mode of Payment")
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index ac9768b..fdbead9 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -184,8 +184,6 @@
this.frm.set_value("write_off_amount",
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("write_off_amount"));
}
-
- this.frm.script_manager.trigger("write_off_amount");
},
write_off_amount: function() {
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 1b48a8e..12aca89 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -403,13 +403,15 @@
// paid_amount and write_off_amount is only for POS Invoice
// total_advance is only for non POS Invoice
if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.docstatus==0) {
- frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount",
- "paid_amount"]);
- var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount - this.frm.doc.total_advance;
- this.frm.doc.paid_amount = this.frm.doc.is_pos? flt(total_amount_to_pay): 0.0;
-
- this.frm.doc.outstanding_amount = flt(total_amount_to_pay - this.frm.doc.paid_amount,
- precision("outstanding_amount"));
+ if(this.frm.doc.paid_amount==null) {
+ frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount",
+ "paid_amount"]);
+ var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount
+ - this.frm.doc.total_advance;
+ this.frm.doc.paid_amount = this.frm.doc.is_pos ? flt (total_amount_to_pay) : 0.0;
+ this.frm.set_value("outstanding_amount", flt(total_amount_to_pay
+ - this.frm.doc.paid_amount, precision("outstanding_amount")));
+ }
}
},
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index 35e3534..9633f61 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -102,6 +102,7 @@
{'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
{'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
{'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
+
]
from frappe.modules import scrub