[pos][minor] fixed sales_invoice.js for pos view
diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js
index 1bd6de1..0bae8a3 100644
--- a/accounts/doctype/sales_invoice/pos.js
+++ b/accounts/doctype/sales_invoice/pos.js
@@ -16,7 +16,7 @@
<div class="col-sm-6">\
<div class="pos-bill">\
<div class="item-cart">\
- <table class="table table-condensed table-hover" id="cart" style="table-layout: fixed;">\
+ <table class="table table-condensed table-hover" id="cart" style="table-layout: fixed;">\
<thead>\
<tr>\
<th style="width: 50%">Item</th>\
@@ -161,7 +161,7 @@
});
this.barcode.make_input();
this.barcode.$input.on("change", function() {
- me.add_item_thru_barcode();
+ setTimeout(me.add_item_thru_barcode(), 1000);
});
},
make_item_list: function() {
@@ -178,12 +178,13 @@
me.wrapper.find(".item-list").empty();
$.each(r.message, function(index, obj) {
if (obj.image)
- image = "<img src='" + obj.image + "' class='img-responsive'>";
+ image = '<img src="' + obj.image + '" class="img-responsive" \
+ style="border:1px solid #eee;height:140px;width:122px;">';
else
image = '<div class="missing-image"><i class="icon-camera"></i></div>';
$(repl('<div class="col-xs-3 pos-item" data-item_code="%(item_code)s">\
- %(item_image)s\
+ <div>%(item_image)s</div>\
<div class="small">%(item_code)s</div>\
<div class="small">%(item_name)s</div>\
<div class="small">%(item_price)s</div>\
@@ -230,7 +231,6 @@
var child = wn.model.add_child(me.frm.doc, "Sales Invoice Item", "entries");
child.item_code = item_code;
me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name);
- //me.refresh();
}
},
update_qty: function(item_code, qty) {
@@ -262,7 +262,7 @@
<td>%(item_code)s%(item_name)s</td>\
<td><input type="text" value="%(qty)s" \
class="form-control qty" style="text-align: right;"></td>\
- <td style="text-align: right;">%(rate)s<br><b>%(amount)s</b></td>\
+ <td style="text-align: right;"><b>%(amount)s</b><br>%(rate)s</td>\
</tr>',
{
item_code: d.item_code,
@@ -288,7 +288,7 @@
<tr>', {
description: d.description,
tax_amount: format_currency(d.tax_amount, me.frm.doc.price_list_currency)
- })).appendTo(".tax-table tbody");
+ })).appendTo(".tax-table tbody")
});
// set totals
@@ -297,14 +297,18 @@
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export,
cur_frm.doc.price_list_currency));
+ $("input.qty").on("focus", function() {
+ $(this).select();
+ });
+
// append quantity to the respective item after change from input box
$("input.qty").on("change", function() {
var item_code = $(this).closest("tr")[0].id;
me.update_qty(item_code, $(this).val());
});
- // on td click highlight the respective row
- $("td").on("click", function() {
+ // on td click toggle the highlighting of row
+ $("#cart tbody tr td").on("click", function() {
var row = $(this).closest("tr");
if (row.attr("data-selected") == "false") {
row.attr("class", "warning");
@@ -319,6 +323,7 @@
});
me.refresh_delete_btn();
+ cur_frm.pos.barcode.$input.focus();
},
refresh_delete_btn: function() {
$(".delete-items").toggle($(".item-cart .warning").length ? true : false);
@@ -331,10 +336,11 @@
callback: function(r) {
if (r.message) {
me.add_to_cart(r.message[0].name);
- me.refresh();
}
else
msgprint(wn._("Invalid Barcode"));
+
+ me.refresh();
}
});
},
@@ -348,20 +354,19 @@
selected_items.push(row.attr("id"));
}
}
-
- if (!selected_items[0])
- msgprint(wn._("Please select any item to remove it"));
var child = wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
"Sales Invoice");
$.each(child, function(i, d) {
for (var i in selected_items) {
if (d.item_code == selected_items[i]) {
+ // cur_frm.fields_dict["entries"].grid.grid_rows[d.idx].remove();
wn.model.clear_doc(d.doctype, d.name);
}
}
});
cur_frm.fields_dict["entries"].grid.refresh();
+ cur_frm.script_manager.trigger("calculate_taxes_and_totals");
me.refresh();
},
make_payment: function() {
@@ -394,6 +399,7 @@
"total_amount": $(".grand-total").text()
});
dialog.show();
+ cur_frm.pos.barcode.$input.focus();
dialog.get_input("total_amount").attr("disabled", "disabled");
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 109d9f8..85550c4 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -26,7 +26,9 @@
}
}
- cur_frm.cscript.toggle_pos(true);
+ if(this.frm.doc.is_pos && this.frm.doc.docstatus===0) {
+ cur_frm.cscript.toggle_pos(true);
+ }
},
refresh: function(doc, dt, dn) {
@@ -91,16 +93,13 @@
}
});
});
-
- if(cint(sys_defaults.fs_pos_view)===1)
- cur_frm.cscript.pos_btn();
-
- // setTimeout(function() { cur_frm.$pos_btn.click(); }, 1000);
-
} else {
// hide shown pos for submitted records
if(cur_frm.pos_active) cur_frm.cscript.toggle_pos(false);
}
+
+ if(cint(sys_defaults.fs_pos_view)===1)
+ cur_frm.cscript.pos_btn();
},
pos_btn: function() {
@@ -123,8 +122,8 @@
},
toggle_pos: function(show) {
- if(cint(sys_defaults.fs_pos_view)===0) return;
- if(!(this.frm.doc.is_pos && this.frm.doc.docstatus===0)) return;
+ // if(cint(sys_defaults.fs_pos_view)===0) return;
+ // if(!(this.frm.doc.is_pos && this.frm.doc.docstatus===0)) return;
if (!this.frm.doc.selling_price_list)
msgprint(wn._("Please select Price List"))