New test case files added.(a)test_sales_order_with_bypass_credit_limit_check.js -- New feature: i.e. bypass credit limit check at sales order.(b)test_sales_order_without_bypass_credit_limit_check.js --Regression test case : the existing default flow is checked i.e. credit limit check happens at sales order level
diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js
new file mode 100644
index 0000000..3ffb825
--- /dev/null
+++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_with_bypass_credit_limit_check.js
@@ -0,0 +1,54 @@
+QUnit.module('Sales Order');
+
+QUnit.test("test_sales_order_with_bypass_credit_limit_check", function(assert) {
+//#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com
+ assert.expect(2);
+ let done = assert.async();
+ frappe.run_serially([
+ () => frappe.new_doc('Customer'),
+ () => frappe.timeout(1),
+ () => frappe.click_link('Edit in full page'),
+ () => cur_frm.set_value("customer_name", "Test Customer 10"),
+ () => cur_frm.set_value("credit_limit", 100.00),
+ () => cur_frm.set_value("bypass_credit_limit_check_at_sales_order", 1),
+ // save form
+ () => cur_frm.save(),
+ () => frappe.timeout(1),
+
+ () => frappe.new_doc('Item'),
+ () => frappe.timeout(1),
+ () => frappe.click_link('Edit in full page'),
+ () => cur_frm.set_value("item_code", "Test Product 10"),
+ () => cur_frm.set_value("item_group", "Products"),
+ () => cur_frm.set_value("standard_rate", 100),
+ // save form
+ () => cur_frm.save(),
+ () => frappe.timeout(1),
+
+ () => {
+ return frappe.tests.make('Sales Order', [
+ {customer: 'Test Customer 5'},
+ {items: [
+ [
+ {'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
+ {'qty': 5},
+ {'item_code': 'Test Product 10'},
+ ]
+ ]}
+
+ ]);
+ },
+ () => cur_frm.save(),
+ () => frappe.tests.click_button('Submit'),
+ () => assert.equal("Confirm", cur_dialog.title,'confirmation for submit'),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(3),
+ () => {
+
+ assert.ok(cur_frm.doc.status=="To Deliver and Bill", "It is submited. Credit limit is NOT checked for sales order");
+
+
+ },
+ () => done()
+ ]);
+});
diff --git a/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js b/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js
new file mode 100644
index 0000000..ea15edc
--- /dev/null
+++ b/erpnext/selling/doctype/sales_order/tests/test_sales_order_without_bypass_credit_limit_check.js
@@ -0,0 +1,59 @@
+QUnit.module('Sales Order');
+
+QUnit.test("test_sales_order_without_bypass_credit_limit_check", function(assert) {
+//#PR : 10861, Author : ashish-greycube & jigneshpshah, Email:mr.ashish.shah@gmail.com
+ assert.expect(2);
+ let done = assert.async();
+ frappe.run_serially([
+ () => frappe.new_doc('Customer'),
+ () => frappe.timeout(1),
+ () => frappe.click_link('Edit in full page'),
+ () => cur_frm.set_value("customer_name", "Test Customer 11"),
+ () => cur_frm.set_value("credit_limit", 100.00),
+ () => cur_frm.set_value("bypass_credit_limit_check_at_sales_order", 0),
+ // save form
+ () => cur_frm.save(),
+ () => frappe.timeout(1),
+
+ () => frappe.new_doc('Item'),
+ () => frappe.timeout(1),
+ () => frappe.click_link('Edit in full page'),
+ () => cur_frm.set_value("item_code", "Test Product 11"),
+ () => cur_frm.set_value("item_group", "Products"),
+ () => cur_frm.set_value("standard_rate", 100),
+ // save form
+ () => cur_frm.save(),
+ () => frappe.timeout(1),
+
+ () => {
+ return frappe.tests.make('Sales Order', [
+ {customer: 'Test Customer 11'},
+ {items: [
+ [
+ {'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
+ {'qty': 5},
+ {'item_code': 'Test Product 11'},
+ ]
+ ]}
+
+ ]);
+ },
+ () => cur_frm.save(),
+ () => frappe.tests.click_button('Submit'),
+ () => assert.equal("Confirm", cur_dialog.title,'confirmation for submit'),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(3),
+ () => {
+
+ if (cur_dialog.body.innerText.match(/^Credit limit has been crossed for customer.*$/))
+ {
+ /*Match found */
+ assert.ok(true, "Credit Limit crossed message received");
+ }
+
+
+ },
+ () => cur_dialog.cancel(),
+ () => done()
+ ]);
+});