From f1f1b60a626177a52c61fc095ae507d2ce0c2701 Mon Sep 17 00:00:00 2001 From: Vishal Dhayagude Date: Wed, 2 Aug 2017 17:15:47 +0530 Subject: [PATCH] [UI Test ] Sales Order with tax and discount (#10225) * [new] UI Test for Sales Order * [fix] Codacy fixed * Update test_sales_order_with_discount_on_grand_total.js * Update test_sales_order_with_taxes_and_charges.js --- ...ales_order_with_discount_on_grand_total.js | 41 +++++++++++++++++++ ...test_sales_order_with_taxes_and_charges.js | 40 ++++++++++++++++++ erpnext/tests/ui/tests.txt | 2 + 3 files changed, 83 insertions(+) create mode 100644 erpnext/selling/doctype/sales_order/tests/test_sales_order_with_discount_on_grand_total.js create mode 100644 erpnext/selling/doctype/sales_order/tests/test_sales_order_with_taxes_and_charges.js diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_discount_on_grand_total.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_discount_on_grand_total.js new file mode 100644 index 00000000000..3247c85d971 --- /dev/null +++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_discount_on_grand_total.js @@ -0,0 +1,41 @@ +QUnit.module('Sales Order'); + +QUnit.test("test sales order with additional discount in grand total", function(assert) { + assert.expect(2); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Sales Order', [ + {customer: 'Test Customer 1'}, + {items: [ + [ + {'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)}, + {'qty': 5}, + {'item_code': 'Test Product 4'}, + ] + ]}, + {customer_address: 'Test1-Billing'}, + {shipping_address_name: 'Test1-Shipping'}, + {contact_person: 'Contact 1-Test Customer 1'} + ]); + }, + () => { + return frappe.tests.set_form_values(cur_frm, [ + {apply_discount_on:'Grand Total'}, + {additional_discount_percentage:10} + ]); + }, + () => cur_frm.save(), + () => { + // get_item_details + assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct"); + // get grand_total details + assert.ok(cur_frm.doc.grand_total== 450, "Grand total correct "); + + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => frappe.timeout(0.3), + () => done() + ]); +}); diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_taxes_and_charges.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_taxes_and_charges.js new file mode 100644 index 00000000000..c9464435ab1 --- /dev/null +++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_taxes_and_charges.js @@ -0,0 +1,40 @@ +QUnit.module('Sales Order'); + +QUnit.test("test sales order with taxes and charges", function(assert) { + assert.expect(3); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Sales Order', [ + {customer: 'Test Customer 1'}, + {items: [ + [ + {'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)}, + {'qty': 5}, + {'item_code': 'Test Product 4'}, + ] + ]}, + {customer_address: 'Test1-Billing'}, + {shipping_address_name: 'Test1-Shipping'}, + {contact_person: 'Contact 1-Test Customer 1'}, + {taxes_and_charges: 'TEST In State GST'}, + {tc_name: 'Test Term 1'}, + {terms: 'This is Test'} + ]); + }, + () => cur_frm.save(), + () => { + // get_item_details + assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct"); + // get tax details + assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST', "Tax details correct"); + // get tax account head details + assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct"); + + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => frappe.timeout(0.3), + () => done() + ]); +}); diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index 88b6ca7047c..c21c6717637 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -12,6 +12,8 @@ erpnext/selling/doctype/sales_order/tests/test_sales_order.js erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multiple_delivery_date.js erpnext/selling/doctype/sales_order/tests/test_sales_order_with_item_wise_discount.js erpnext/selling/doctype/sales_order/tests/test_sales_order_with_multi_uom.js +erpnext/selling/doctype/sales_order/tests/test_sales_order_with_discount_on_grand_total.js +erpnext/selling/doctype/sales_order/tests/test_sales_order_with_taxes_and_charges.js erpnext/manufacturing/doctype/workstation/test_workstation.js erpnext/manufacturing/doctype/operation/test_operation.js erpnext/manufacturing/doctype/bom/test_bom.js