[fix] POS, amount not updating on change of price, on zero of discount rate has not reset, pricing rule not working for brand
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 471263f..49e2f15 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -139,7 +139,7 @@
select
name, item_code, item_name, description, item_group, expense_account, has_batch_no,
has_serial_no, expense_account, selling_cost_center, stock_uom, image,
- default_warehouse, is_stock_item, barcode
+ default_warehouse, is_stock_item, barcode, brand
from
tabItem
where
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 1dafb87..c021000 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -26,6 +26,7 @@
this.onload();
this.make_menu_list();
this.bind_events();
+ this.bind_items_event();
this.si_docs = this.get_doc_from_localstorage();
},
@@ -78,6 +79,7 @@
make_menu_list: function () {
var me = this;
+ this.page.clear_menu();
this.page.add_menu_item(__("New Sales Invoice"), function () {
me.save_previous_entry();
me.create_new();
@@ -96,12 +98,6 @@
me.sync_sales_invoice()
});
- this.page.add_menu_item(__("Email"), function () {
- if(me.frm.doc.docstatus == 1) {
- me.email_prompt()
- }
- });
-
this.page.add_menu_item(__("POS Profile"), function () {
frappe.set_route('List', 'POS Profile');
});
@@ -1043,12 +1039,12 @@
bind_qty_event: function () {
var me = this;
-
+
$(this.wrapper).on("change", ".pos-item-qty", function () {
var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code");
var qty = $(this).val();
me.update_qty(item_code, qty)
- me.render_selected_item()
+ me.update_value()
})
$(this.wrapper).find("[data-action='increase-qty']").on("click", function () {
@@ -1067,7 +1063,7 @@
var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code");
var discount = $(this).val();
me.update_discount(item_code, discount)
- me.render_selected_item()
+ me.update_value()
})
},
@@ -1082,6 +1078,7 @@
if (me.frm.doc.docstatus == 0) {
me.items = me.get_items($(this).attr("data-item-code"))
me.add_to_cart();
+ me.clear_selected_row();
}
});
@@ -1106,18 +1103,42 @@
$(this.wrapper).on("change", ".pos-item-price", function () {
var item_code = $(this).parents(".pos-selected-item-action").attr("data-item-code");
me.set_item_details(item_code, "rate", $(this).val());
+ me.update_value()
})
},
- render_selected_item: function() {
- doc = this.get_child_item(this.item_code);
- $(this.wrapper).find('.selected-item').empty();
- if(doc.length) {
- this.selected_row = $(frappe.render_template("pos_selected_item", doc[0]))
- $(this.wrapper).find('.selected-item').html(this.selected_row)
+ update_value: function() {
+ var me = this;
+ var fields = {qty: ".pos-item-qty", "discount_percentage": ".pos-item-disc",
+ "rate": ".pos-item-price", "amount": ".pos-amount"}
+ this.child_doc = this.get_child_item(this.item_code);
+
+ if(me.child_doc.length) {
+ $.each(fields, function(key, field) {
+ $(me.selected_row).find(field).val(me.child_doc[0][key])
+ })
+ } else {
+ this.clear_selected_row();
}
},
-
+
+ clear_selected_row: function() {
+ $(this.wrapper).find('.selected-item').empty();
+ },
+
+ render_selected_item: function() {
+ this.child_doc = this.get_child_item(this.item_code);
+ $(this.wrapper).find('.selected-item').empty();
+ if(this.child_doc.length) {
+ this.selected_row = $(frappe.render_template("pos_selected_item", this.child_doc[0]))
+ $(this.wrapper).find('.selected-item').html(this.selected_row)
+ }
+
+ $(this.selected_row).find('.form-control').click(function(){
+ $(this).select();
+ })
+ },
+
get_child_item: function(item_code) {
var me = this;
return $.map(me.frm.doc.items, function(doc){
@@ -1145,6 +1166,10 @@
if (d.qty == 0) {
me.remove_item.push(d.idx)
}
+
+ if(field=="discount_percentage" && value == 0) {
+ d.rate = d.price_list_rate;
+ }
}
});
@@ -1243,6 +1268,7 @@
this.child.item_code = this.items[0].item_code;
this.child.item_name = this.items[0].item_name;
this.child.stock_uom = this.items[0].stock_uom;
+ this.child.brand = this.items[0].brand;
this.child.description = this.items[0].description;
this.child.discount_percentage = 0.0;
this.child.qty = 1;
@@ -1272,7 +1298,6 @@
refresh: function (update_paid_amount) {
var me = this;
this.refresh_fields(update_paid_amount);
- this.bind_items_event();
this.set_primary_action();
},
@@ -1361,6 +1386,7 @@
var me = this;
this.page.set_primary_action(__("New Cart"), function () {
me.make_new_cart()
+ me.make_menu_list()
}, "fa fa-plus")
if (this.frm.doc.docstatus == 1) {
@@ -1368,10 +1394,14 @@
html = frappe.render(me.print_template_data, me.frm.doc)
me.print_document(html)
})
+ this.page.add_menu_item(__("Email"), function () {
+ me.email_prompt()
+ })
}
},
make_new_cart: function (){
+ this.page.clear_secondary_action();
this.save_previous_entry();
this.create_new();
this.refresh();
@@ -1715,7 +1745,7 @@
var me = this;
return $.grep(this.pricing_rules, function (data) {
if (item.qty >= data.min_qty && (item.qty <= (data.max_qty ? data.max_qty : item.qty))) {
- if (data.item_code == item.item_code || in_list(['All Item Groups', item.item_group], data.item_group)) {
+ if (data.item_code == item.item_code || in_list(['All Item Groups', item.item_group], data.item_group) || item.brand == data.brand) {
if (in_list(['Customer', 'Customer Group', 'Territory', 'Campaign'], data.applicable_for)) {
return me.validate_condition(data)
} else {
diff --git a/erpnext/public/js/pos/pos_selected_item.html b/erpnext/public/js/pos/pos_selected_item.html
index 30cf0f0..dfc9915 100644
--- a/erpnext/public/js/pos/pos_selected_item.html
+++ b/erpnext/public/js/pos/pos_selected_item.html
@@ -1,12 +1,13 @@
<div class="pos-selected-item-action" data-item-code="{%= item_code %}">
<div class="pos-list-row">
- <span class="cell bold">{{item_name}}</span>
- </div>
- <div class="pos-list-row">
<div class="cell">Quantity:</div>
<input class="form-control cell pos-item-qty" value="{%= qty %}"/>
</div>
<div class="pos-list-row">
+ <div class="cell">Price List Rate:</div>
+ <input class="form-control cell" disabled value="{%= price_list_rate %}"/>
+ </div>
+ <div class="pos-list-row">
<div class="cell">Discount:</div>
<input class="form-control cell pos-item-disc" value="{%= discount_percentage %}">
</div>
@@ -16,6 +17,6 @@
</div>
<div class="pos-list-row">
<div class="cell">Amount:</div>
- <input class="form-control cell" value="{%= amount %}"/>
+ <input class="form-control cell pos-amount" value="{%= amount %}"/>
</div>
</div>
\ No newline at end of file