[UI Test] Multiple UI Test for Quotation (#10330)
diff --git a/erpnext/selling/doctype/quotation/test_quotation.js b/erpnext/selling/doctype/quotation/tests/test_quotation.js
similarity index 100%
rename from erpnext/selling/doctype/quotation/test_quotation.js
rename to erpnext/selling/doctype/quotation/tests/test_quotation.js
diff --git a/erpnext/selling/doctype/quotation/tests/test_quotation_with_discount_on_grand_total.js b/erpnext/selling/doctype/quotation/tests/test_quotation_with_discount_on_grand_total.js
new file mode 100644
index 0000000..b7b5a47
--- /dev/null
+++ b/erpnext/selling/doctype/quotation/tests/test_quotation_with_discount_on_grand_total.js
@@ -0,0 +1,42 @@
+QUnit.module('Quotation');
+
+QUnit.test("test quotation with additional discount in grand total", function(assert) {
+ assert.expect(2);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Quotation', [
+ {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/quotation/tests/test_quotation_with_item_wise_discount.js b/erpnext/selling/doctype/quotation/tests/test_quotation_with_item_wise_discount.js
new file mode 100644
index 0000000..e7349e3
--- /dev/null
+++ b/erpnext/selling/doctype/quotation/tests/test_quotation_with_item_wise_discount.js
@@ -0,0 +1,38 @@
+QUnit.module('Quotation');
+
+QUnit.test("test quotation with item wise discount", function(assert) {
+ assert.expect(2);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Quotation', [
+ {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'},
+ {'discount_percentage': 10},
+ {'margin_type': 'Percentage'}
+ ]
+ ]},
+ {customer_address: 'Test1-Billing'},
+ {shipping_address_name: 'Test1-Shipping'},
+ {contact_person: 'Contact 1-Test Customer 1'}
+ ]);
+ },
+ () => 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/quotation/tests/test_quotation_with_multi_uom.js b/erpnext/selling/doctype/quotation/tests/test_quotation_with_multi_uom.js
new file mode 100644
index 0000000..50b8a83
--- /dev/null
+++ b/erpnext/selling/doctype/quotation/tests/test_quotation_with_multi_uom.js
@@ -0,0 +1,39 @@
+QUnit.module('Quotation');
+
+QUnit.test("test quotation with multi uom", function(assert) {
+ assert.expect(3);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Quotation', [
+ {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'},
+ {'uom': 'unit'},
+ ]
+ ]},
+ {customer_address: 'Test1-Billing'},
+ {shipping_address_name: 'Test1-Shipping'},
+ {contact_person: 'Contact 1-Test Customer 1'}
+ ]);
+ },
+ () => cur_frm.save(),
+ () => {
+ // get_item_details
+ assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct");
+ // get uom details
+ assert.ok(cur_frm.doc.items[0].uom=='Unit', "Multi Uom correct");
+ // get grand_total details
+ assert.ok(cur_frm.doc.grand_total== 5000, "Grand total correct ");
+
+ },
+ () => frappe.tests.click_button('Submit'),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.3),
+ () => done()
+ ]);
+});
+
diff --git a/erpnext/selling/doctype/quotation/tests/test_quotation_with_shipping_rule.js b/erpnext/selling/doctype/quotation/tests/test_quotation_with_shipping_rule.js
new file mode 100644
index 0000000..17c5dd2
--- /dev/null
+++ b/erpnext/selling/doctype/quotation/tests/test_quotation_with_shipping_rule.js
@@ -0,0 +1,35 @@
+QUnit.module('Quotation');
+
+QUnit.test("test quotation with shipping rule", function(assert) {
+ assert.expect(2);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Quotation', [
+ {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'},
+ {shipping_rule:'Next Day Shipping'}
+ ]);
+ },
+ () => 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== 550, "Grand total correct ");
+ },
+ () => frappe.tests.click_button('Submit'),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.3),
+ () => done()
+ ]);
+});
diff --git a/erpnext/selling/doctype/quotation/tests/test_quotation_with_taxes_and_charges.js b/erpnext/selling/doctype/quotation/tests/test_quotation_with_taxes_and_charges.js
new file mode 100644
index 0000000..6cc3604
--- /dev/null
+++ b/erpnext/selling/doctype/quotation/tests/test_quotation_with_taxes_and_charges.js
@@ -0,0 +1,41 @@
+QUnit.module('Quotation');
+
+QUnit.test("test quotation with taxes and charges", function(assert) {
+ assert.expect(3);
+ let done = assert.async();
+ frappe.run_serially([
+ () => {
+ return frappe.tests.make('Quotation', [
+ {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 4ce1675..1a539c3 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -7,9 +7,14 @@
erpnext/accounts/doctype/shipping_rule/test_shipping_rule.js
erpnext/crm/doctype/lead/test_lead.js
erpnext/crm/doctype/opportunity/test_opportunity.js
-erpnext/selling/doctype/quotation/test_quotation.js
erpnext/setup/doctype/company/tests/test_company_production.js
erpnext/crm/doctype/item/test_item.js
+erpnext/selling/doctype/quotation/tests/test_quotation_with_discount_on_grand_total.js
+erpnext/selling/doctype/quotation/tests/test_quotation_with_item_wise_discount.js
+erpnext/selling/doctype/quotation/tests/test_quotation_with_multi_uom.js
+erpnext/selling/doctype/quotation/tests/test_quotation_with_taxes_and_charges.js
+erpnext/selling/doctype/quotation/tests/test_quotation_with_shipping_rule.js
+erpnext/selling/doctype/quotation/tests/test_quotation.js
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