refactor: build point of sale min js
This commit is contained in:
parent
937dc467a0
commit
96feae608d
@ -56,5 +56,15 @@
|
|||||||
"stock/dashboard/item_dashboard.html",
|
"stock/dashboard/item_dashboard.html",
|
||||||
"stock/dashboard/item_dashboard_list.html",
|
"stock/dashboard/item_dashboard_list.html",
|
||||||
"stock/dashboard/item_dashboard.js"
|
"stock/dashboard/item_dashboard.js"
|
||||||
|
],
|
||||||
|
"js/point-of-sale.min.js": [
|
||||||
|
"selling/page/point_of_sale/pos_item_selector.js",
|
||||||
|
"selling/page/point_of_sale/pos_item_cart.js",
|
||||||
|
"selling/page/point_of_sale/pos_item_details.js",
|
||||||
|
"selling/page/point_of_sale/pos_number_pad.js",
|
||||||
|
"selling/page/point_of_sale/pos_payment.js",
|
||||||
|
"selling/page/point_of_sale/pos_past_order_list.js",
|
||||||
|
"selling/page/point_of_sale/pos_past_order_summary.js",
|
||||||
|
"selling/page/point_of_sale/pos_controller.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,4 @@
|
|||||||
/* global Clusterize */
|
|
||||||
frappe.provide('erpnext.PointOfSale');
|
frappe.provide('erpnext.PointOfSale');
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_controller.js" %}
|
|
||||||
frappe.provide('erpnext.queries');
|
|
||||||
|
|
||||||
frappe.pages['point-of-sale'].on_page_load = function(wrapper) {
|
frappe.pages['point-of-sale'].on_page_load = function(wrapper) {
|
||||||
frappe.ui.make_app_page({
|
frappe.ui.make_app_page({
|
||||||
@ -10,8 +7,10 @@ frappe.pages['point-of-sale'].on_page_load = function(wrapper) {
|
|||||||
single_column: true
|
single_column: true
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.pos = new erpnext.PointOfSale.Controller(wrapper);
|
frappe.require('assets/js/point-of-sale.min.js', function() {
|
||||||
window.cur_pos = wrapper.pos;
|
wrapper.pos = new erpnext.PointOfSale.Controller(wrapper);
|
||||||
|
window.cur_pos = wrapper.pos;
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
frappe.pages['point-of-sale'].refresh = function(wrapper) {
|
frappe.pages['point-of-sale'].refresh = function(wrapper) {
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
{% include "erpnext/selling/page/point_of_sale/onscan.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_item_selector.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_item_cart.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_item_details.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_payment.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_number_pad.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_past_order_list.js" %}
|
|
||||||
{% include "erpnext/selling/page/point_of_sale/pos_past_order_summary.js" %}
|
|
||||||
|
|
||||||
erpnext.PointOfSale.Controller = class {
|
erpnext.PointOfSale.Controller = class {
|
||||||
constructor(wrapper) {
|
constructor(wrapper) {
|
||||||
this.wrapper = $(wrapper).find('.layout-main-section');
|
this.wrapper = $(wrapper).find('.layout-main-section');
|
||||||
@ -31,6 +22,7 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_opening_voucher() {
|
create_opening_voucher() {
|
||||||
|
const me = this;
|
||||||
const table_fields = [
|
const table_fields = [
|
||||||
{
|
{
|
||||||
fieldname: "mode_of_payment", fieldtype: "Link",
|
fieldname: "mode_of_payment", fieldtype: "Link",
|
||||||
@ -88,7 +80,7 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
fields: table_fields
|
fields: table_fields
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
primary_action: async ({ company, pos_profile, balance_details }) => {
|
primary_action: async function({ company, pos_profile, balance_details }) {
|
||||||
if (!balance_details.length) {
|
if (!balance_details.length) {
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
message: __("Please add Mode of payments and opening balance details."),
|
message: __("Please add Mode of payments and opening balance details."),
|
||||||
@ -98,7 +90,7 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
}
|
}
|
||||||
const method = "erpnext.selling.page.point_of_sale.point_of_sale.create_opening_voucher";
|
const method = "erpnext.selling.page.point_of_sale.point_of_sale.create_opening_voucher";
|
||||||
const res = await frappe.call({ method, args: { pos_profile, company, balance_details }, freeze:true });
|
const res = await frappe.call({ method, args: { pos_profile, company, balance_details }, freeze:true });
|
||||||
!res.exc && this.prepare_app_defaults(res.message);
|
!res.exc && me.prepare_app_defaults(res.message);
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
},
|
},
|
||||||
primary_action_label: __('Submit')
|
primary_action_label: __('Submit')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import onScan from 'onscan.js';
|
||||||
|
|
||||||
erpnext.PointOfSale.ItemSelector = class {
|
erpnext.PointOfSale.ItemSelector = class {
|
||||||
constructor({ frm, wrapper, events, pos_profile }) {
|
constructor({ frm, wrapper, events, pos_profile }) {
|
||||||
this.wrapper = wrapper;
|
this.wrapper = wrapper;
|
||||||
@ -46,7 +48,8 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_items({start = 0, page_length = 40, search_value=''}) {
|
get_items({start = 0, page_length = 40, search_value=''}) {
|
||||||
const price_list = this.events.get_frm().doc?.selling_price_list || this.price_list;
|
const doc = this.events.get_frm().doc;
|
||||||
|
const price_list = (doc && doc.selling_price_list) || this.price_list;
|
||||||
let { item_group, pos_profile } = this;
|
let { item_group, pos_profile } = this;
|
||||||
|
|
||||||
!item_group && (item_group = this.parent_item_group);
|
!item_group && (item_group = this.parent_item_group);
|
||||||
@ -104,6 +107,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
|
|
||||||
make_search_bar() {
|
make_search_bar() {
|
||||||
const me = this;
|
const me = this;
|
||||||
|
const doc = me.events.get_frm().doc;
|
||||||
this.$component.find('.search-field').html('');
|
this.$component.find('.search-field').html('');
|
||||||
this.$component.find('.item-group-field').html('');
|
this.$component.find('.item-group-field').html('');
|
||||||
|
|
||||||
@ -131,7 +135,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
return {
|
return {
|
||||||
query: 'erpnext.selling.page.point_of_sale.point_of_sale.item_group_query',
|
query: 'erpnext.selling.page.point_of_sale.point_of_sale.item_group_query',
|
||||||
filters: {
|
filters: {
|
||||||
pos_profile: me.events.get_frm().doc?.pos_profile
|
pos_profile: doc ? doc.pos_profile : ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -145,6 +149,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
|
|
||||||
bind_events() {
|
bind_events() {
|
||||||
const me = this;
|
const me = this;
|
||||||
|
window.onScan = onScan;
|
||||||
onScan.attachTo(document, {
|
onScan.attachTo(document, {
|
||||||
onScan: (sScancode) => {
|
onScan: (sScancode) => {
|
||||||
if (this.search_field && this.$component.is(':visible')) {
|
if (this.search_field && this.$component.is(':visible')) {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
{% include "erpnext/selling/page/point_of_sale/pos_number_pad.js" %}
|
|
||||||
|
|
||||||
erpnext.PointOfSale.Payment = class {
|
erpnext.PointOfSale.Payment = class {
|
||||||
constructor({ events, wrapper }) {
|
constructor({ events, wrapper }) {
|
||||||
this.wrapper = wrapper;
|
this.wrapper = wrapper;
|
||||||
@ -153,13 +151,12 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
me.$payment_modes.find(`.${mode}-amount`).css('display', 'none');
|
me.$payment_modes.find(`.${mode}-amount`).css('display', 'none');
|
||||||
me.$payment_modes.find(`.${mode}-name`).css('display', 'inline');
|
me.$payment_modes.find(`.${mode}-name`).css('display', 'inline');
|
||||||
|
|
||||||
me.selected_mode = me[`${mode}_control`];
|
|
||||||
const doc = me.events.get_frm().doc;
|
const doc = me.events.get_frm().doc;
|
||||||
me.selected_mode?.$input?.get(0).focus();
|
me.selected_mode = me[`${mode}_control`];
|
||||||
const current_value = me.selected_mode?.get_value()
|
me.selected_mode && me.selected_mode.$input.get(0).focus();
|
||||||
!current_value && doc.grand_total > doc.paid_amount ? me.selected_mode?.set_value(doc.grand_total - doc.paid_amount) : '';
|
const current_value = me.selected_mode ? me.selected_mode.get_value() : undefined;
|
||||||
|
!current_value && doc.grand_total > doc.paid_amount && me.selected_mode ?
|
||||||
me.numpad_value = '';
|
me.selected_mode.set_value(doc.grand_total - doc.paid_amount) : '';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"snyk": "^1.290.1"
|
"snyk": "^1.290.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"onscan.js": "^1.5.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"snyk-protect": "snyk protect",
|
"snyk-protect": "snyk protect",
|
||||||
|
@ -1217,6 +1217,11 @@ onetime@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
mimic-fn "^1.0.0"
|
mimic-fn "^1.0.0"
|
||||||
|
|
||||||
|
onscan.js@^1.5.2:
|
||||||
|
version "1.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/onscan.js/-/onscan.js-1.5.2.tgz#14ed636e5f4c3f0a78bacbf9a505dad3140ee341"
|
||||||
|
integrity sha512-9oGYy2gXYRjvXO9GYqqVca0VuCTAmWhbmX3egBSBP13rXiMNb+dKPJzKFEeECGqPBpf0m40Zoo+GUQ7eCackdw==
|
||||||
|
|
||||||
opn@^5.5.0:
|
opn@^5.5.0:
|
||||||
version "5.5.0"
|
version "5.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/opn/-/opn-5.5.0.tgz#fc7164fab56d235904c51c3b27da6758ca3b9bfc"
|
resolved "https://registry.yarnpkg.com/opn/-/opn-5.5.0.tgz#fc7164fab56d235904c51c3b27da6758ca3b9bfc"
|
||||||
|
Loading…
Reference in New Issue
Block a user