mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
fix(pos): rounded total and search fixes (#24738)
This commit is contained in:
@@ -498,10 +498,11 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
|
|
||||||
async on_cart_update(args) {
|
async on_cart_update(args) {
|
||||||
frappe.dom.freeze();
|
frappe.dom.freeze();
|
||||||
|
let item_row = undefined;
|
||||||
try {
|
try {
|
||||||
let { field, value, item } = args;
|
let { field, value, item } = args;
|
||||||
const { item_code, batch_no, serial_no, uom } = item;
|
const { item_code, batch_no, serial_no, uom } = item;
|
||||||
let item_row = this.get_item_from_frm(item_code, batch_no, uom);
|
item_row = this.get_item_from_frm(item_code, batch_no, uom);
|
||||||
|
|
||||||
const item_selected_from_selector = field === 'qty' && value === "+1"
|
const item_selected_from_selector = field === 'qty' && value === "+1"
|
||||||
|
|
||||||
@@ -553,10 +554,12 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
this.check_serial_batch_selection_needed(item_row) && this.edit_item_details_of(item_row);
|
this.check_serial_batch_selection_needed(item_row) && this.edit_item_details_of(item_row);
|
||||||
this.update_cart_html(item_row);
|
this.update_cart_html(item_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
|
return item_row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -472,7 +472,8 @@ erpnext.PointOfSale.ItemCart = class {
|
|||||||
if (!frm) frm = this.events.get_frm();
|
if (!frm) frm = this.events.get_frm();
|
||||||
|
|
||||||
this.render_net_total(frm.doc.net_total);
|
this.render_net_total(frm.doc.net_total);
|
||||||
this.render_grand_total(frm.doc.grand_total);
|
const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? frm.doc.grand_total : frm.doc.rounded_total;
|
||||||
|
this.render_grand_total(grand_total);
|
||||||
|
|
||||||
const taxes = frm.doc.taxes.map(t => {
|
const taxes = frm.doc.taxes.map(t => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -152,6 +152,10 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
this.item_group_field.toggle_label(false);
|
this.item_group_field.toggle_label(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_search_value(value) {
|
||||||
|
$(this.search_field.$input[0]).val(value).trigger("input");
|
||||||
|
}
|
||||||
|
|
||||||
bind_events() {
|
bind_events() {
|
||||||
const me = this;
|
const me = this;
|
||||||
window.onScan = onScan;
|
window.onScan = onScan;
|
||||||
@@ -159,7 +163,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
onScan: (sScancode) => {
|
onScan: (sScancode) => {
|
||||||
if (this.search_field && this.$component.is(':visible')) {
|
if (this.search_field && this.$component.is(':visible')) {
|
||||||
this.search_field.set_focus();
|
this.search_field.set_focus();
|
||||||
$(this.search_field.$input[0]).val(sScancode).trigger("input");
|
this.set_search_value(sScancode);
|
||||||
this.barcode_scanned = true;
|
this.barcode_scanned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,6 +182,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
uom = uom === "undefined" ? undefined : uom;
|
uom = uom === "undefined" ? undefined : uom;
|
||||||
|
|
||||||
me.events.item_selected({ field: 'qty', value: "+1", item: { item_code, batch_no, serial_no, uom }});
|
me.events.item_selected({ field: 'qty', value: "+1", item: { item_code, batch_no, serial_no, uom }});
|
||||||
|
me.set_search_value('');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.search_field.$input.on('input', (e) => {
|
this.search_field.$input.on('input', (e) => {
|
||||||
|
|||||||
@@ -223,7 +223,8 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
title = __("Payment Received");
|
title = __("Payment Received");
|
||||||
if (amount >= doc.grand_total) {
|
const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total;
|
||||||
|
if (amount >= grand_total) {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
message = __("Payment of {0} received successfully.", [format_currency(amount, doc.currency, 0)]);
|
message = __("Payment of {0} received successfully.", [format_currency(amount, doc.currency, 0)]);
|
||||||
this.events.submit_invoice();
|
this.events.submit_invoice();
|
||||||
@@ -243,7 +244,8 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
|
|
||||||
auto_set_remaining_amount() {
|
auto_set_remaining_amount() {
|
||||||
const doc = this.events.get_frm().doc;
|
const doc = this.events.get_frm().doc;
|
||||||
const remaining_amount = doc.grand_total - doc.paid_amount;
|
const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total;
|
||||||
|
const remaining_amount = grand_total - doc.paid_amount;
|
||||||
const current_value = this.selected_mode ? this.selected_mode.get_value() : undefined;
|
const current_value = this.selected_mode ? this.selected_mode.get_value() : undefined;
|
||||||
if (!current_value && remaining_amount > 0 && this.selected_mode) {
|
if (!current_value && remaining_amount > 0 && this.selected_mode) {
|
||||||
this.selected_mode.set_value(remaining_amount);
|
this.selected_mode.set_value(remaining_amount);
|
||||||
@@ -389,7 +391,7 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
attach_cash_shortcuts(doc) {
|
attach_cash_shortcuts(doc) {
|
||||||
const grand_total = doc.grand_total;
|
const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total;
|
||||||
const currency = doc.currency;
|
const currency = doc.currency;
|
||||||
|
|
||||||
const shortcuts = this.get_cash_shortcuts(flt(grand_total));
|
const shortcuts = this.get_cash_shortcuts(flt(grand_total));
|
||||||
@@ -499,7 +501,8 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
update_totals_section(doc) {
|
update_totals_section(doc) {
|
||||||
if (!doc) doc = this.events.get_frm().doc;
|
if (!doc) doc = this.events.get_frm().doc;
|
||||||
const paid_amount = doc.paid_amount;
|
const paid_amount = doc.paid_amount;
|
||||||
const remaining = doc.grand_total - doc.paid_amount;
|
const grand_total = cint(frappe.sys_defaults.disable_rounded_total) ? doc.grand_total : doc.rounded_total;
|
||||||
|
const remaining = grand_total - doc.paid_amount;
|
||||||
const change = doc.change_amount || remaining <= 0 ? -1 * remaining : undefined;
|
const change = doc.change_amount || remaining <= 0 ? -1 * remaining : undefined;
|
||||||
const currency = doc.currency;
|
const currency = doc.currency;
|
||||||
const label = change ? __('Change') : __('To Be Paid');
|
const label = change ? __('Change') : __('To Be Paid');
|
||||||
@@ -507,7 +510,7 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
this.$totals.html(
|
this.$totals.html(
|
||||||
`<div class="col">
|
`<div class="col">
|
||||||
<div class="total-label">Grand Total</div>
|
<div class="total-label">Grand Total</div>
|
||||||
<div class="value">${format_currency(doc.grand_total, currency)}</div>
|
<div class="value">${format_currency(grand_total, currency)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="seperator-y"></div>
|
<div class="seperator-y"></div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|||||||
Reference in New Issue
Block a user