From 1ccb0cfa2fab1bbc5bfe00d60f53a5429243c304 Mon Sep 17 00:00:00 2001 From: deepak-mnt Date: Sat, 6 Jan 2018 15:38:39 +0530 Subject: [PATCH] [Mod] point_of_sale.js: Allowed print before pay and saved the invoice before print [New] test_point_of_sale.js: Test Cases to check the print before pay functionality in Online POS --- .../page/point_of_sale/point_of_sale.js | 19 +++++++++++++------ .../page/point_of_sale/point_of_sale.py | 7 +++---- .../point_of_sale/tests/test_point_of_sale.js | 3 +++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index b142a06ada..2991b0e2a4 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -519,13 +519,20 @@ erpnext.pos.PointOfSale = class PointOfSale { if(this.frm.doc.docstatus == 1 || this.frm.doc.allow_print_before_pay == 1){ this.page.set_secondary_action(__("Print"), () => { - this.frm.print_preview.printit(true); + if(this.frm.doc.docstatus != 1 ){ + this.frm.save(); + setTimeout(() => {this.frm.print_preview.printit(true);}, 1700); + }else{ + this.frm.print_preview.printit(true); + } }); - - this.page.set_primary_action(__("New"), () => { - this.make_new_invoice(); - }); - + } + + this.page.set_primary_action(__("New"), () => { + this.make_new_invoice(); + }); + + if (this.frm.doc.docstatus == 1) { this.page.add_menu_item(__("Email"), () => { this.frm.email_doc(); }); diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index 054c8af73b..d15b05fc2e 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -127,7 +127,6 @@ def item_group_query(doctype, txt, searchfield, start, page_len, filters): @frappe.whitelist() def fetch_pos_profile_detail(pos_profile): - doc_detail=frappe.get_doc("POS Profile",pos_profile) - print_check=doc_detail.allow_print_before_pay - return print_check - + pos_profile_doc = frappe.get_doc("POS Profile",pos_profile) + allow_print_before_pay_check = pos_profile_doc.allow_print_before_pay + return allow_print_before_pay_check \ No newline at end of file diff --git a/erpnext/selling/page/point_of_sale/tests/test_point_of_sale.js b/erpnext/selling/page/point_of_sale/tests/test_point_of_sale.js index 79d1700b4e..3514e9715f 100644 --- a/erpnext/selling/page/point_of_sale/tests/test_point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/tests/test_point_of_sale.js @@ -13,6 +13,9 @@ QUnit.test("test:Point of Sales", function(assert) { () => frappe.timeout(0.2), () => frappe.click_element(`.cart-items [data-item-code="Test Product 2"]`), () => frappe.timeout(0.2), + () => frappe.click_element(`.btn-secondary`), + () => frappe.timeout(0.4), + () => assert.ok(!cur_frm.doc.__islocal, "Sales invoice saved"), () => frappe.click_element(`.number-pad [data-value="Rate"]`), () => frappe.timeout(0.2), () => frappe.click_element(`.number-pad [data-value="2"]`),