fix(pos): rounded total and search fixes (#24738)

This commit is contained in:
Saqib 2021-02-26 16:49:28 +05:30 committed by GitHub
parent f8a7e000f5
commit 2a1b1537f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 8 deletions

View File

@ -498,10 +498,11 @@ erpnext.PointOfSale.Controller = class {
async on_cart_update(args) {
frappe.dom.freeze();
let item_row = undefined;
try {
let { field, value, item } = args;
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"
@ -553,10 +554,12 @@ erpnext.PointOfSale.Controller = class {
this.check_serial_batch_selection_needed(item_row) && this.edit_item_details_of(item_row);
this.update_cart_html(item_row);
}
} catch (error) {
console.log(error);
} finally {
frappe.dom.unfreeze();
return item_row;
}
}

View File

@ -472,7 +472,8 @@ erpnext.PointOfSale.ItemCart = class {
if (!frm) frm = this.events.get_frm();
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 => {
return {

View File

@ -152,6 +152,10 @@ erpnext.PointOfSale.ItemSelector = class {
this.item_group_field.toggle_label(false);
}
set_search_value(value) {
$(this.search_field.$input[0]).val(value).trigger("input");
}
bind_events() {
const me = this;
window.onScan = onScan;
@ -159,7 +163,7 @@ erpnext.PointOfSale.ItemSelector = class {
onScan: (sScancode) => {
if (this.search_field && this.$component.is(':visible')) {
this.search_field.set_focus();
$(this.search_field.$input[0]).val(sScancode).trigger("input");
this.set_search_value(sScancode);
this.barcode_scanned = true;
}
}
@ -178,6 +182,7 @@ erpnext.PointOfSale.ItemSelector = class {
uom = uom === "undefined" ? undefined : 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) => {

View File

@ -223,7 +223,8 @@ erpnext.PointOfSale.Payment = class {
if (success) {
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();
message = __("Payment of {0} received successfully.", [format_currency(amount, doc.currency, 0)]);
this.events.submit_invoice();
@ -243,7 +244,8 @@ erpnext.PointOfSale.Payment = class {
auto_set_remaining_amount() {
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;
if (!current_value && remaining_amount > 0 && this.selected_mode) {
this.selected_mode.set_value(remaining_amount);
@ -389,7 +391,7 @@ erpnext.PointOfSale.Payment = class {
}
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 shortcuts = this.get_cash_shortcuts(flt(grand_total));
@ -499,7 +501,8 @@ erpnext.PointOfSale.Payment = class {
update_totals_section(doc) {
if (!doc) doc = this.events.get_frm().doc;
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 currency = doc.currency;
const label = change ? __('Change') : __('To Be Paid');
@ -507,7 +510,7 @@ erpnext.PointOfSale.Payment = class {
this.$totals.html(
`<div class="col">
<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 class="seperator-y"></div>
<div class="col">