diff --git a/posnext/fixtures/custom_field.json b/posnext/fixtures/custom_field.json index a700aea..6b3c9e1 100644 --- a/posnext/fixtures/custom_field.json +++ b/posnext/fixtures/custom_field.json @@ -296,11 +296,11 @@ "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "POS Profile", + "dt": "Sales Order", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_mobile_number_based_customer", - "fieldtype": "Check", + "fieldname": "pos_profile", + "fieldtype": "Link", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -311,19 +311,19 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_show_held_button", + "insert_after": "delivery_date", "is_system_generated": 0, "is_virtual": 0, - "label": "Mobile Number Based Customer", + "label": "POS Profile", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-08-16 07:44:20.324682", + "modified": "2025-02-18 21:01:56.657675", "module": "Posnext", - "name": "POS Profile-custom_mobile_number_based_customer", + "name": "Sales Order-custom_pos_profile", "no_copy": 0, "non_negative": 0, - "options": null, + "options": "POS Profile", "permlevel": 0, "placeholder": null, "precision": "", @@ -353,11 +353,11 @@ "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Sales Order", + "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "pos_profile", - "fieldtype": "Link", + "fieldname": "custom_mobile_number_based_customer", + "fieldtype": "Check", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -368,19 +368,19 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "delivery_date", + "insert_after": "custom_show_held_button", "is_system_generated": 0, "is_virtual": 0, - "label": "POS Profile", + "label": "Mobile Number Based Customer", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2025-02-18 21:01:56.657675", + "modified": "2024-08-16 07:44:20.324682", "module": "Posnext", - "name": "Sales Order-custom_pos_profile", + "name": "POS Profile-custom_mobile_number_based_customer", "no_copy": 0, "non_negative": 0, - "options": "POS Profile", + "options": null, "permlevel": 0, "placeholder": null, "precision": "", @@ -1147,15 +1147,15 @@ "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": "eval: doc.custom_edit_rate_and_uom", + "depends_on": null, "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "POS Profile", + "dt": "Item", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_use_discount_percentage", - "fieldtype": "Check", + "fieldname": "custom_alternative_items", + "fieldtype": "Section Break", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -1166,16 +1166,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_show_logical_rack_in_cart", + "insert_after": "image", "is_system_generated": 0, "is_virtual": 0, - "label": "Use Discount Percentage", + "label": "Alternative Items", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-11-15 06:30:05.707381", + "modified": "2024-11-01 10:29:14.635688", "module": "Posnext", - "name": "POS Profile-custom_use_discount_percentage", + "name": "Item-custom_alternative_items", "no_copy": 0, "non_negative": 0, "options": null, @@ -1204,15 +1204,15 @@ "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": null, + "depends_on": "eval: doc.custom_edit_rate_and_uom", "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Item", + "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_alternative_items", - "fieldtype": "Section Break", + "fieldname": "custom_use_discount_percentage", + "fieldtype": "Check", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -1223,16 +1223,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "image", + "insert_after": "custom_show_logical_rack_in_cart", "is_system_generated": 0, "is_virtual": 0, - "label": "Alternative Items", + "label": "Use Discount Percentage", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-11-01 10:29:14.635688", + "modified": "2024-11-15 06:30:05.707381", "module": "Posnext", - "name": "Item-custom_alternative_items", + "name": "POS Profile-custom_use_discount_percentage", "no_copy": 0, "non_negative": 0, "options": null, @@ -1261,15 +1261,15 @@ "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": "eval: doc.custom_edit_rate_and_uom", + "depends_on": null, "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "POS Profile", + "dt": "Item", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_use_discount_amount", - "fieldtype": "Check", + "fieldname": "custom_items", + "fieldtype": "Table", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -1280,19 +1280,19 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_use_discount_percentage", + "insert_after": "custom_alternative_items", "is_system_generated": 0, "is_virtual": 0, - "label": "Use Discount Amount", + "label": "Items", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-11-15 06:30:05.558116", + "modified": "2024-11-01 10:29:14.533231", "module": "Posnext", - "name": "POS Profile-custom_use_discount_amount", + "name": "Item-custom_items", "no_copy": 0, "non_negative": 0, - "options": null, + "options": "Alternative Items", "permlevel": 0, "placeholder": null, "precision": "", @@ -1318,15 +1318,15 @@ "collapsible_depends_on": null, "columns": 0, "default": null, - "depends_on": null, + "depends_on": "eval: doc.custom_edit_rate_and_uom", "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Item", + "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_items", - "fieldtype": "Table", + "fieldname": "custom_use_discount_amount", + "fieldtype": "Check", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -1337,19 +1337,19 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_alternative_items", + "insert_after": "custom_use_discount_percentage", "is_system_generated": 0, "is_virtual": 0, - "label": "Items", + "label": "Use Discount Amount", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-11-01 10:29:14.533231", + "modified": "2024-11-15 06:30:05.558116", "module": "Posnext", - "name": "Item-custom_items", + "name": "POS Profile-custom_use_discount_amount", "no_copy": 0, "non_negative": 0, - "options": "Alternative Items", + "options": null, "permlevel": 0, "placeholder": null, "precision": "", @@ -1937,6 +1937,63 @@ "unique": 0, "width": null }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Sales Invoice Item", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_valuation_rate", + "fieldtype": "Currency", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "item_tax_template", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Valuation Rate", + "length": 0, + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2024-12-04 23:51:32.067475", + "module": "Posnext", + "name": "Sales Invoice Item-custom_valuation_rate", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "placeholder": null, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 1, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, { "allow_in_quick_entry": 0, "allow_on_submit": 0, @@ -2009,8 +2066,8 @@ "dt": "Sales Invoice Item", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_valuation_rate", - "fieldtype": "Currency", + "fieldname": "custom_item_uoms", + "fieldtype": "Data", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -2021,16 +2078,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "item_tax_template", + "insert_after": "custom_valuation_rate", "is_system_generated": 0, "is_virtual": 0, - "label": "Valuation Rate", + "label": "Item UOMs", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-12-04 23:51:32.067475", + "modified": "2024-12-05 21:30:02.846405", "module": "Posnext", - "name": "Sales Invoice Item-custom_valuation_rate", + "name": "Sales Invoice Item-custom_item_uoms", "no_copy": 0, "non_negative": 0, "options": null, @@ -2123,7 +2180,7 @@ "dt": "Sales Invoice Item", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_item_uoms", + "fieldname": "custom_logical_rack", "fieldtype": "Data", "hidden": 0, "hide_border": 0, @@ -2135,16 +2192,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_valuation_rate", + "insert_after": "custom_item_uoms", "is_system_generated": 0, "is_virtual": 0, - "label": "Item UOMs", + "label": "Logical Rack", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-12-05 21:30:02.846405", + "modified": "2024-12-07 00:03:31.531532", "module": "Posnext", - "name": "Sales Invoice Item-custom_item_uoms", + "name": "Sales Invoice Item-custom_logical_rack", "no_copy": 0, "non_negative": 0, "options": null, @@ -2154,7 +2211,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "print_width": null, - "read_only": 1, + "read_only": 0, "read_only_depends_on": null, "report_hide": 0, "reqd": 0, @@ -2234,11 +2291,11 @@ "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Sales Invoice Item", + "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_logical_rack", - "fieldtype": "Data", + "fieldname": "custom_show_only_list_view", + "fieldtype": "Check", "hidden": 0, "hide_border": 0, "hide_days": 0, @@ -2249,16 +2306,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_item_uoms", + "insert_after": "custom_show_open_form_view", "is_system_generated": 0, "is_virtual": 0, - "label": "Logical Rack", + "label": "Show only List View", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-12-07 00:03:31.531532", + "modified": "2024-08-16 07:44:19.914911", "module": "Posnext", - "name": "Sales Invoice Item-custom_logical_rack", + "name": "POS Profile-custom_show_only_list_view", "no_copy": 0, "non_negative": 0, "options": null, @@ -2294,7 +2351,7 @@ "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_show_only_list_view", + "fieldname": "custom_use_additional_discount_amount", "fieldtype": "Check", "hidden": 0, "hide_border": 0, @@ -2306,16 +2363,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_show_open_form_view", + "insert_after": "custom_show_only_list_view", "is_system_generated": 0, "is_virtual": 0, - "label": "Show only List View", + "label": "Use Additional Discount Amount", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-08-16 07:44:19.914911", + "modified": "2024-12-02 21:09:47.521699", "module": "Posnext", - "name": "POS Profile-custom_show_only_list_view", + "name": "POS Profile-custom_use_additional_discount_amount", "no_copy": 0, "non_negative": 0, "options": null, @@ -2351,7 +2408,7 @@ "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_use_additional_discount_amount", + "fieldname": "custom_show_last_customer_rate", "fieldtype": "Check", "hidden": 0, "hide_border": 0, @@ -2363,16 +2420,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_show_only_list_view", + "insert_after": "custom_use_additional_discount_amount", "is_system_generated": 0, "is_virtual": 0, - "label": "Use Additional Discount Amount", + "label": "Show Last Customer Rate", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-12-02 21:09:47.521699", + "modified": "2024-12-04 00:05:12.513921", "module": "Posnext", - "name": "POS Profile-custom_use_additional_discount_amount", + "name": "POS Profile-custom_show_last_customer_rate", "no_copy": 0, "non_negative": 0, "options": null, @@ -2408,7 +2465,7 @@ "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_show_last_customer_rate", + "fieldname": "custom_product_bundle", "fieldtype": "Check", "hidden": 0, "hide_border": 0, @@ -2420,16 +2477,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_use_additional_discount_amount", + "insert_after": "custom_show_last_customer_rate", "is_system_generated": 0, "is_virtual": 0, - "label": "Show Last Customer Rate", + "label": "Product Bundle", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2024-12-04 00:05:12.513921", + "modified": "2025-03-14 10:38:39.117168", "module": "Posnext", - "name": "POS Profile-custom_show_last_customer_rate", + "name": "POS Profile-custom_product_bundle", "no_copy": 0, "non_negative": 0, "options": null, @@ -2465,7 +2522,7 @@ "dt": "POS Profile", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "custom_product_bundle", + "fieldname": "custom_add_reference_details", "fieldtype": "Check", "hidden": 0, "hide_border": 0, @@ -2477,16 +2534,16 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_show_last_customer_rate", + "insert_after": "custom_product_bundle", "is_system_generated": 0, "is_virtual": 0, - "label": "Product Bundle", + "label": "Add Reference Details", "length": 0, "link_filters": null, "mandatory_depends_on": null, - "modified": "2025-03-14 10:38:39.117168", + "modified": "2025-03-14 22:29:05.863641", "module": "Posnext", - "name": "POS Profile-custom_product_bundle", + "name": "POS Profile-custom_add_reference_details", "no_copy": 0, "non_negative": 0, "options": null, @@ -2534,7 +2591,7 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "custom_show_last_customer_rate", + "insert_after": "custom_add_reference_details", "is_system_generated": 0, "is_virtual": 0, "label": "Mobile Number Length", @@ -2677,5 +2734,119 @@ "translatable": 0, "unique": 0, "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Sales Invoice", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_reference_no", + "fieldtype": "Data", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "remarks", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Reference No", + "length": 0, + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2025-03-14 22:29:37.799589", + "module": "Posnext", + "name": "Sales Invoice-custom_reference_no", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "placeholder": null, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 1, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Sales Invoice", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_reference_name", + "fieldtype": "Data", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_reference_no", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Reference Name", + "length": 0, + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2025-03-14 22:29:19.555839", + "module": "Posnext", + "name": "Sales Invoice-custom_reference_name", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "placeholder": null, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 1, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null } ] \ No newline at end of file diff --git a/posnext/public/js/pos_controller.js b/posnext/public/js/pos_controller.js index 2499f62..b057780 100644 --- a/posnext/public/js/pos_controller.js +++ b/posnext/public/js/pos_controller.js @@ -647,23 +647,26 @@ posnext.PointOfSale.Controller = class { if (!item_code) return; - // Check if the custom_product_bundle setting is enabled if (this.settings.custom_product_bundle) { - // Check if the item is part of a product bundle const product_bundle = await this.get_product_bundle(item_code); if (product_bundle && Array.isArray(product_bundle.items)) { - for (const bundle_item of product_bundle.items) { - const bundle_item_row = this.frm.add_child('items', { - item_code: bundle_item.item_code, - qty: bundle_item.qty * value, - rate: bundle_item.rate, - uom: bundle_item.uom - }); + const bundle_items = product_bundle.items.map(bundle_item => ({ + item_code: bundle_item.item_code, + qty: bundle_item.qty * value, + rate: bundle_item.rate, + uom: bundle_item.uom + })); + + for (const bundle_item of bundle_items) { + const bundle_item_row = this.frm.add_child('items', bundle_item); await this.trigger_new_item_events(bundle_item_row); } - return; // Exit the function as we don't want to add the parent item + + this.update_cart_html(); + return; } } + const new_item = { item_code, batch_no, rate, uom, [field]: value }; if(value){ new_item['qty'] = value @@ -894,6 +897,70 @@ posnext.PointOfSale.Controller = class { save_error && setTimeout(() => { this.cart.toggle_checkout_btn(true); }, 300); // wait for save to finish + } else { + this.payment.checkout(); + } + } + async save_and_checkout() { + if (this.frm.is_dirty()) { + if(this.settings.custom_add_reference_details){ + const dialog = new frappe.ui.Dialog({ + title: __('Enter Reference Details'), + fields: [ + { + fieldtype: 'Data', + label: __('Reference Number'), + fieldname: 'reference_no', + reqd: 1 + }, + { + fieldtype: 'Data', + label: __('Reference Name'), + fieldname: 'reference_name', + reqd: 1 + } + ], + primary_action_label: __('Proceed to Payment'), + primary_action: async (values) => { + this.frm.doc.custom_reference_no = values.reference_no; + this.frm.doc.custom_reference_name = values.reference_name; + + const div = document.getElementById("customer-cart-container2"); + div.style.gridColumn = ""; + + let save_error = false; + await this.frm.save(null, null, null, () => save_error = true); + + dialog.hide(); + + if (!save_error) { + this.payment.checkout(); + } else { + setTimeout(() => { + this.cart.toggle_checkout_btn(true); + }, 300); // wait for save to finish + } + } + }); + + + dialog.show(); + }else{ + + const div = document.getElementById("customer-cart-container2"); + div.style.gridColumn = ""; + let save_error = false; + await this.frm.save(null, null, null, () => save_error = true); + // only move to payment section if save is successful + !save_error && this.payment.checkout(); + // show checkout button on error + save_error && setTimeout(() => { + this.cart.toggle_checkout_btn(true); + }, 300); // wait for save to finish + } + + + } else { this.payment.checkout(); }