brotherton-erpnext/erpnext/public/js/utils/serial_no_batch_selector.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

598 lines
17 KiB
JavaScript
Raw Normal View History

2017-06-22 10:19:42 +00:00
erpnext.SerialNoBatchSelector = class SerialNoBatchSelector {
constructor(opts, show_dialog) {
2017-06-22 10:19:42 +00:00
$.extend(this, opts);
2019-04-16 12:55:53 +00:00
this.show_dialog = show_dialog;
2017-06-22 10:19:42 +00:00
// frm, item, warehouse_details, has_batch, oldest
2017-06-23 06:09:03 +00:00
let d = this.item;
this.has_batch = 0; this.has_serial_no = 0;
if (d && d.has_batch_no && (!d.batch_no || this.show_dialog)) this.has_batch = 1;
2019-04-17 10:16:15 +00:00
// !(this.show_dialog == false) ensures that show_dialog is implictly true, even when undefined
if(d && d.has_serial_no && !(this.show_dialog == false)) this.has_serial_no = 1;
this.setup();
2017-06-22 10:19:42 +00:00
}
setup() {
this.item_code = this.item.item_code;
this.qty = this.item.qty;
this.make_dialog();
2017-12-14 10:36:23 +00:00
this.on_close_dialog();
2017-06-22 10:19:42 +00:00
}
make_dialog() {
var me = this;
this.data = this.oldest ? this.oldest : [];
let title = "";
let fields = [
2017-06-26 10:01:46 +00:00
{
fieldname: 'item_code',
read_only: 1,
fieldtype:'Link',
options: 'Item',
label: __('Item Code'),
default: me.item_code
},
2017-06-22 10:19:42 +00:00
{
fieldname: 'warehouse',
fieldtype:'Link',
options: 'Warehouse',
reqd: me.has_batch && !me.has_serial_no ? 0 : 1,
2017-06-22 10:19:42 +00:00
label: __(me.warehouse_details.type),
default: typeof me.warehouse_details.name == "string" ? me.warehouse_details.name : '',
2017-06-22 10:19:42 +00:00
onchange: function(e) {
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
me.warehouse_details.name = this.get_value();
if(me.has_batch && !me.has_serial_no) {
fields = fields.concat(me.get_batch_fields());
} else {
fields = fields.concat(me.get_serial_no_fields());
}
2017-06-22 10:19:42 +00:00
var batches = this.layout.fields_dict.batches;
if(batches) {
batches.grid.df.data = [];
batches.grid.refresh();
batches.grid.add_new_row(null, null, null);
}
},
get_query: function() {
return {
query: "erpnext.controllers.queries.warehouse_query",
filters: [
["Bin", "item_code", "=", me.item_code],
["Warehouse", "is_group", "=", 0],
["Warehouse", "company", "=", me.frm.doc.company]
]
}
2017-06-22 10:19:42 +00:00
}
},
{fieldtype:'Column Break'},
2017-06-26 10:01:46 +00:00
{
fieldname: 'qty',
fieldtype:'Float',
read_only: me.has_batch && !me.has_serial_no,
label: __(me.has_batch && !me.has_serial_no ? 'Selected Qty' : 'Qty'),
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
default: flt(me.item.stock_qty),
2017-06-26 10:01:46 +00:00
},
...get_pending_qty_fields(me),
{
fieldname: 'uom',
read_only: 1,
fieldtype: 'Link',
options: 'UOM',
label: __('UOM'),
default: me.item.uom
},
2019-04-16 07:17:39 +00:00
{
fieldname: 'auto_fetch_button',
fieldtype:'Button',
hidden: me.has_batch && !me.has_serial_no,
label: __('Auto Fetch'),
description: __('Fetch Serial Numbers based on FIFO'),
2019-04-17 04:56:21 +00:00
click: () => {
2019-04-16 12:55:53 +00:00
let qty = this.dialog.fields_dict.qty.get_value();
2019-04-16 07:17:39 +00:00
let numbers = frappe.call({
method: "erpnext.stock.doctype.serial_no.serial_no.auto_fetch_serial_number",
args: {
qty: qty,
2019-04-16 07:17:39 +00:00
item_code: me.item_code,
warehouse: typeof me.warehouse_details.name == "string" ? me.warehouse_details.name : '',
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
batch_no: me.item.batch_no || null,
posting_date: me.frm.doc.posting_date || me.frm.doc.transaction_date
2019-04-16 07:17:39 +00:00
}
});
numbers.then((data) => {
let auto_fetched_serial_numbers = data.message;
2019-04-16 12:55:53 +00:00
let records_length = auto_fetched_serial_numbers.length;
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
if (!records_length) {
const warehouse = me.dialog.fields_dict.warehouse.get_value().bold();
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.msgprint(
__('Serial numbers unavailable for Item {0} under warehouse {1}. Please try changing warehouse.', [me.item.item_code.bold(), warehouse])
);
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
}
2019-04-17 10:16:15 +00:00
if (records_length < qty) {
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.msgprint(__('Fetched only {0} available serial numbers.', [records_length]));
}
2019-04-16 07:17:39 +00:00
let serial_no_list_field = this.dialog.fields_dict.serial_no;
numbers = auto_fetched_serial_numbers.join('\n');
serial_no_list_field.set_value(numbers);
2019-04-16 11:33:25 +00:00
});
2019-04-16 07:17:39 +00:00
}
}
2017-06-22 10:19:42 +00:00
];
if (this.has_batch && !this.has_serial_no) {
2017-06-22 10:19:42 +00:00
title = __("Select Batch Numbers");
fields = fields.concat(this.get_batch_fields());
} else {
// if only serial no OR
// if both batch_no & serial_no then only select serial_no and auto set batches nos
2017-06-22 10:19:42 +00:00
title = __("Select Serial Numbers");
fields = fields.concat(this.get_serial_no_fields());
}
this.dialog = new frappe.ui.Dialog({
title: title,
fields: fields
});
this.dialog.set_primary_action(__('Insert'), function() {
me.values = me.dialog.get_values();
2017-06-22 10:24:18 +00:00
if(me.validate()) {
frappe.run_serially([
() => me.update_batch_items(),
() => me.update_serial_no_item(),
() => me.update_batch_serial_no_items(),
() => {
refresh_field("items");
2021-02-12 05:59:24 +00:00
refresh_field("packed_items");
if (me.callback) {
return me.callback(me.item);
}
},
() => me.dialog.hide()
])
2017-06-22 10:24:18 +00:00
}
2017-06-22 10:19:42 +00:00
});
if(this.show_dialog) {
let d = this.item;
if (this.item.serial_no) {
this.dialog.fields_dict.serial_no.set_value(this.item.serial_no);
}
2021-02-12 05:59:24 +00:00
if (this.has_batch && !this.has_serial_no && d.batch_no) {
this.frm.doc.items.forEach(data => {
if(data.item_code == d.item_code) {
this.dialog.fields_dict.batches.df.data.push({
'batch_no': data.batch_no,
'actual_qty': data.actual_qty,
'selected_qty': data.qty,
'available_qty': data.actual_batch_qty
});
}
});
this.dialog.fields_dict.batches.grid.refresh();
}
}
if (this.has_batch && !this.has_serial_no) {
this.update_total_qty();
this.update_pending_qtys();
}
2017-06-22 10:19:42 +00:00
this.dialog.show();
}
2017-12-14 10:36:23 +00:00
on_close_dialog() {
this.dialog.get_close_btn().on('click', () => {
this.on_close && this.on_close(this.item);
});
}
2017-06-22 10:19:42 +00:00
validate() {
let values = this.values;
if(!values.warehouse) {
frappe.throw(__("Please select a warehouse"));
return false;
}
if(this.has_batch && !this.has_serial_no) {
2017-06-22 10:19:42 +00:00
if(values.batches.length === 0 || !values.batches) {
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.throw(__("Please select batches for batched item {0}", [values.item_code]));
2017-06-22 10:19:42 +00:00
}
values.batches.map((batch, i) => {
if(!batch.selected_qty || batch.selected_qty === 0 ) {
if (!this.show_dialog) {
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.throw(__("Please select quantity on row {0}", [i+1]));
}
2017-06-22 10:19:42 +00:00
}
});
return true;
} else {
let serial_nos = values.serial_no || '';
if (!serial_nos || !serial_nos.replace(/\s/g, '').length) {
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.throw(__("Please enter serial numbers for serialized item {0}", [values.item_code]));
2017-06-22 10:19:42 +00:00
}
return true;
}
}
update_batch_items() {
// clones an items if muliple batches are selected.
if(this.has_batch && !this.has_serial_no) {
2017-06-22 10:19:42 +00:00
this.values.batches.map((batch, i) => {
let batch_no = batch.batch_no;
let row = '';
if (i !== 0 && !this.batch_exists(batch_no)) {
row = this.frm.add_child("items", { ...this.item });
} else {
row = this.frm.doc.items.find(i => i.batch_no === batch_no);
}
if (!row) {
row = this.item;
}
// this ensures that qty & batch no is set
2017-06-27 08:33:56 +00:00
this.map_row_values(row, batch, 'batch_no',
2017-06-23 06:09:03 +00:00
'selected_qty', this.values.warehouse);
2017-06-22 10:19:42 +00:00
});
2021-02-12 05:59:24 +00:00
}
}
update_serial_no_item() {
// just updates serial no for the item
if(this.has_serial_no && !this.has_batch) {
this.map_row_values(this.item, this.values, 'serial_no', 'qty');
2017-06-22 10:19:42 +00:00
}
}
update_batch_serial_no_items() {
// if serial no selected is from different batches, adds new rows for each batch.
if(this.has_batch && this.has_serial_no) {
const selected_serial_nos = this.values.serial_no.split(/\n/g).filter(s => s);
return frappe.db.get_list("Serial No", {
filters: { 'name': ["in", selected_serial_nos]},
fields: ["batch_no", "name"]
}).then((data) => {
2021-02-12 05:59:24 +00:00
// data = [{batch_no: 'batch-1', name: "SR-001"},
// {batch_no: 'batch-2', name: "SR-003"}, {batch_no: 'batch-2', name: "SR-004"}]
const batch_serial_map = data.reduce((acc, d) => {
if (!acc[d['batch_no']]) acc[d['batch_no']] = [];
acc[d['batch_no']].push(d['name'])
return acc
}, {})
// batch_serial_map = { "batch-1": ['SR-001'], "batch-2": ["SR-003", "SR-004"]}
Object.keys(batch_serial_map).map((batch_no, i) => {
let row = '';
const serial_no = batch_serial_map[batch_no];
if (i == 0) {
row = this.item;
this.map_row_values(row, {qty: serial_no.length, batch_no: batch_no}, 'batch_no',
'qty', this.values.warehouse);
} else if (!this.batch_exists(batch_no)) {
row = this.frm.add_child("items", { ...this.item });
row.batch_no = batch_no;
} else {
row = this.frm.doc.items.find(i => i.batch_no === batch_no);
}
const values = {
'qty': serial_no.length,
'serial_no': serial_no.join('\n')
}
this.map_row_values(row, values, 'serial_no',
'qty', this.values.warehouse);
});
})
}
2017-06-22 10:19:42 +00:00
}
batch_exists(batch) {
const batches = this.frm.doc.items.map(data => data.batch_no);
return (batches && in_list(batches, batch)) ? true : false;
}
2017-06-27 08:33:56 +00:00
map_row_values(row, values, number, qty_field, warehouse) {
2017-06-23 06:09:03 +00:00
row.qty = values[qty_field];
row.transfer_qty = flt(values[qty_field]) * flt(row.conversion_factor);
row[number] = values[number];
2017-06-22 10:19:42 +00:00
if(this.warehouse_details.type === 'Source Warehouse') {
2017-06-23 06:09:03 +00:00
row.s_warehouse = values.warehouse || warehouse;
2017-06-22 10:24:18 +00:00
} else if(this.warehouse_details.type === 'Target Warehouse') {
2017-06-23 06:09:03 +00:00
row.t_warehouse = values.warehouse || warehouse;
2017-06-22 10:24:18 +00:00
} else {
2017-06-23 06:09:03 +00:00
row.warehouse = values.warehouse || warehouse;
}
2021-02-12 05:59:24 +00:00
this.frm.dirty();
2017-06-22 10:19:42 +00:00
}
update_total_qty() {
2017-06-22 10:19:42 +00:00
let qty_field = this.dialog.fields_dict.qty;
let total_qty = 0;
2017-06-22 10:19:42 +00:00
this.dialog.fields_dict.batches.df.data.forEach(data => {
total_qty += flt(data.selected_qty);
});
qty_field.set_input(total_qty);
2017-06-22 10:19:42 +00:00
}
update_pending_qtys() {
const pending_qty_field = this.dialog.fields_dict.pending_qty;
const total_selected_qty_field = this.dialog.fields_dict.total_selected_qty;
2017-06-22 10:19:42 +00:00
if (!pending_qty_field || !total_selected_qty_field) return;
const me = this;
const required_qty = this.dialog.fields_dict.required_qty.value;
const selected_qty = this.dialog.fields_dict.qty.value;
const total_selected_qty = selected_qty + calc_total_selected_qty(me);
const pending_qty = required_qty - total_selected_qty;
pending_qty_field.set_input(pending_qty);
total_selected_qty_field.set_input(total_selected_qty);
2021-05-31 05:51:18 +00:00
}
get_batch_fields() {
2017-06-22 10:19:42 +00:00
var me = this;
2017-06-22 10:19:42 +00:00
return [
{fieldtype:'Section Break', label: __('Batches')},
2019-04-16 07:17:39 +00:00
{fieldname: 'batches', fieldtype: 'Table', label: __('Batch Entries'),
2017-06-22 10:19:42 +00:00
fields: [
{
'fieldtype': 'Link',
'read_only': 0,
'fieldname': 'batch_no',
'options': 'Batch',
'label': __('Select Batch'),
'in_list_view': 1,
get_query: function () {
return {
filters: {
item_code: me.item_code,
warehouse: me.warehouse || typeof me.warehouse_details.name == "string" ? me.warehouse_details.name : ''
},
query: 'erpnext.controllers.queries.get_batch_no'
};
2017-06-22 10:19:42 +00:00
},
2019-06-10 12:20:52 +00:00
change: function () {
const batch_no = this.get_value();
if (!batch_no) {
2017-06-22 10:19:42 +00:00
this.grid_row.on_grid_fields_dict
.available_qty.set_value(0);
return;
}
2017-06-26 10:01:46 +00:00
let selected_batches = this.grid.grid_rows.map((row) => {
if (row === this.grid_row) {
2017-06-26 10:01:46 +00:00
return "";
}
if (row.on_grid_fields_dict.batch_no) {
return row.on_grid_fields_dict.batch_no.get_value();
}
2017-06-26 10:01:46 +00:00
});
if (selected_batches.includes(batch_no)) {
2017-06-26 10:01:46 +00:00
this.set_value("");
frappe.throw(__('Batch {0} already selected.', [batch_no]));
2017-06-26 10:01:46 +00:00
}
if (me.warehouse_details.name) {
2017-06-22 10:19:42 +00:00
frappe.call({
method: 'erpnext.stock.doctype.batch.batch.get_batch_qty',
args: {
batch_no,
2017-06-22 10:19:42 +00:00
warehouse: me.warehouse_details.name,
item_code: me.item_code
},
callback: (r) => {
this.grid_row.on_grid_fields_dict
.available_qty.set_value(r.message || 0);
}
});
} else {
2017-06-26 10:01:46 +00:00
this.set_value("");
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.throw(__('Please select a warehouse to get available quantities'));
2017-06-22 10:19:42 +00:00
}
// e.stopImmediatePropagation();
}
},
{
'fieldtype': 'Float',
'read_only': 1,
'fieldname': 'available_qty',
'label': __('Available'),
'in_list_view': 1,
'default': 0,
change: function () {
2017-06-22 10:19:42 +00:00
this.grid_row.on_grid_fields_dict.selected_qty.set_value('0');
}
},
{
'fieldtype': 'Float',
'read_only': 0,
'fieldname': 'selected_qty',
'label': __('Qty'),
'in_list_view': 1,
2017-06-22 10:19:42 +00:00
'default': 0,
2019-06-10 12:20:52 +00:00
change: function () {
2017-06-22 10:19:42 +00:00
var batch_no = this.grid_row.on_grid_fields_dict.batch_no.get_value();
var available_qty = this.grid_row.on_grid_fields_dict.available_qty.get_value();
var selected_qty = this.grid_row.on_grid_fields_dict.selected_qty.get_value();
if (batch_no.length === 0 && parseInt(selected_qty) !== 0) {
2017-06-22 10:19:42 +00:00
frappe.throw(__("Please select a batch"));
}
if (me.warehouse_details.type === 'Source Warehouse' &&
2017-06-22 10:19:42 +00:00
parseFloat(available_qty) < parseFloat(selected_qty)) {
2017-06-26 12:15:49 +00:00
this.set_value('0');
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
frappe.throw(__('For transfer from source, selected quantity cannot be greater than available quantity'));
2017-06-22 10:19:42 +00:00
} else {
this.grid.refresh();
}
me.update_total_qty();
me.update_pending_qtys();
2017-06-22 10:19:42 +00:00
}
},
],
in_place_edit: true,
data: this.data,
get_data: function () {
2017-06-22 10:19:42 +00:00
return this.data;
},
}
];
}
get_serial_no_fields() {
var me = this;
this.serial_list = [];
let serial_no_filters = {
item_code: me.item_code,
delivery_document_no: ""
}
if (this.item.batch_no) {
2020-01-23 10:19:39 +00:00
serial_no_filters["batch_no"] = this.item.batch_no;
}
if (me.warehouse_details.name) {
serial_no_filters['warehouse'] = me.warehouse_details.name;
}
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
if (me.frm.doc.doctype === 'POS Invoice' && !this.showing_reserved_serial_nos_error) {
frappe.call({
method: "erpnext.stock.doctype.serial_no.serial_no.get_pos_reserved_serial_nos",
args: {
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
filters: {
item_code: me.item_code,
warehouse: typeof me.warehouse_details.name == "string" ? me.warehouse_details.name : '',
}
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
}
}).then((data) => {
serial_no_filters['name'] = ["not in", data.message[0]]
})
}
2017-06-22 10:19:42 +00:00
return [
2019-04-16 08:02:41 +00:00
{fieldtype: 'Section Break', label: __('Serial Numbers')},
2017-06-22 10:19:42 +00:00
{
fieldtype: 'Link', fieldname: 'serial_no_select', options: 'Serial No',
2019-04-16 08:02:41 +00:00
label: __('Select to add Serial Number.'),
2017-06-22 10:19:42 +00:00
get_query: function() {
return {
filters: serial_no_filters
};
},
onchange: function(e) {
if(this.in_local_change) return;
this.in_local_change = 1;
let serial_no_list_field = this.layout.fields_dict.serial_no;
let qty_field = this.layout.fields_dict.qty;
let new_number = this.get_value();
let list_value = serial_no_list_field.get_value();
let new_line = '\n';
if(!list_value) {
new_line = '';
} else {
me.serial_list = list_value.replace(/\n/g, ' ').match(/\S+/g) || [];
}
if(!me.serial_list.includes(new_number)) {
this.set_new_description('');
serial_no_list_field.set_value(me.serial_list.join('\n') + new_line + new_number);
me.serial_list = serial_no_list_field.get_value().replace(/\n/g, ' ').match(/\S+/g) || [];
} else {
this.set_new_description(new_number + ' is already selected.');
}
qty_field.set_input(me.serial_list.length);
this.$input.val("");
this.in_local_change = 0;
2017-06-22 10:19:42 +00:00
}
},
{fieldtype: 'Column Break'},
{
fieldname: 'serial_no',
fieldtype: 'Small Text',
label: __(me.has_batch && !me.has_serial_no ? 'Selected Batch Numbers' : 'Selected Serial Numbers'),
onchange: function() {
me.serial_list = this.get_value()
.replace(/\n/g, ' ').match(/\S+/g) || [];
this.layout.fields_dict.qty.set_input(me.serial_list.length);
}
}
2017-06-22 10:19:42 +00:00
];
}
};
function get_pending_qty_fields(me) {
if (!check_can_calculate_pending_qty(me)) return [];
const { frm: { doc: { fg_completed_qty }}, item: { item_code, stock_qty }} = me;
const { qty_consumed_per_unit } = erpnext.stock.bom.items[item_code];
const total_selected_qty = calc_total_selected_qty(me);
const required_qty = flt(fg_completed_qty) * flt(qty_consumed_per_unit);
const pending_qty = required_qty - (flt(stock_qty) + total_selected_qty);
const pending_qty_fields = [
{ fieldtype: 'Section Break', label: __('Pending Quantity') },
{
fieldname: 'required_qty',
read_only: 1,
fieldtype: 'Float',
label: __('Required Qty'),
default: required_qty
},
{ fieldtype: 'Column Break' },
{
fieldname: 'total_selected_qty',
read_only: 1,
fieldtype: 'Float',
label: __('Total Selected Qty'),
default: total_selected_qty
},
{ fieldtype: 'Column Break' },
{
fieldname: 'pending_qty',
read_only: 1,
fieldtype: 'Float',
label: __('Pending Qty'),
default: pending_qty
},
];
return pending_qty_fields;
}
function calc_total_selected_qty(me) {
const { frm: { doc: { items }}, item: { name, item_code }} = me;
const totalSelectedQty = items
.filter( item => ( item.name !== name ) && ( item.item_code === item_code ) )
.map( item => flt(item.qty) )
.reduce( (i, j) => i + j, 0);
return totalSelectedQty;
}
function check_can_calculate_pending_qty(me) {
const { frm: { doc }, item } = me;
const docChecks = doc.bom_no
&& doc.fg_completed_qty
&& erpnext.stock.bom
&& erpnext.stock.bom.name === doc.bom_no;
const itemChecks = !!item && !item.allow_alternative_item;
return docChecks && itemChecks;
}