diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js new file mode 100644 index 0000000000..6e33e1d7f2 --- /dev/null +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js @@ -0,0 +1,43 @@ +QUnit.module('Purchaes Invoice'); + +QUnit.test("test purchase invoice", function(assert) { + assert.expect(4); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Purchase Invoice', [ + {supplier: 'Test Supplier'}, + {items: [ + [ + {'qty': 5}, + {'item_code': 'Test Product 1'}, + {'rate':100}, + ] + ]}, + {update_stock:1}, + {supplier_address: 'Test1-Billing'}, + {contact_person: 'Contact 3-Test Supplier'}, + {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 1', "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"); + // grand_total Calculated + assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct"); + + }, + () => frappe.tests.click_button('Submit'), + () => frappe.tests.click_button('Yes'), + () => frappe.timeout(0.3), + () => done() + ]); +}); + diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js new file mode 100644 index 0000000000..5e357ca2ad --- /dev/null +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js @@ -0,0 +1,26 @@ +QUnit.module('Sales Taxes and Charges Template'); + +QUnit.test("test sales taxes and charges template", function(assert) { + assert.expect(1); + let done = assert.async(); + frappe.run_serially([ + () => { + return frappe.tests.make('Purchase Taxes and Charges Template', [ + {title: "TEST In State GST"}, + {taxes:[ + [ + {charge_type:"On Net Total"}, + {account_head:"CGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) } + ], + [ + {charge_type:"On Net Total"}, + {account_head:"SGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) } + ] + ]} + ]); + }, + () => {assert.ok(cur_frm.doc.title=='TEST In State GST');}, + () => done() + ]); +}); + diff --git a/erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js b/erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js index e1e393b67c..c4b341952c 100644 --- a/erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js +++ b/erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js @@ -14,38 +14,13 @@ QUnit.test("test: supplier quotation with taxes and charges", function(assert) { {"item_code": 'Test Product 4'}, {"qty": 5}, {"rate": 100}, - {"warehouse": 'Stores - WP'}, + {"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default('Company'))}, ] ]}, + {taxes_and_charges:'TEST In State GST'}, ]); }, () => {supplier_quotation_name = cur_frm.doc.name;}, - () => frappe.set_route('Form', 'Purchase Taxes and Charges Template', 'New Purchase Taxes and Charges Template'), - () => frappe.timeout(1), - () => { - return frappe.tests.set_form_values(cur_frm, [ - {title:'TEST In State GST'}, - {taxes: [ - [ - {"charge_type": 'On Net Total'}, - {"account_head": 'CGST - WP'} - ], - [ - {"charge_type": 'On Net Total'}, - {"account_head": 'SGST - WP'} - ] - ]}, - ]); - }, - () => cur_frm.save(), - () => frappe.set_route('Form', 'Supplier Quotation', supplier_quotation_name), - () => frappe.timeout(1), - () => { - return frappe.tests.set_form_values(cur_frm, [ - {taxes_and_charges:'TEST In State GST'} - ]); - }, - () => { assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct"); assert.ok(cur_frm.doc.total_taxes_and_charges == 45, "Taxes and charges correct"); diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index 5d60ad1bf1..eac65a6947 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -4,6 +4,7 @@ erpnext/accounts/doctype/account/test_account.js erpnext/accounts/doctype/account/test_make_tax_account.js erpnext/accounts/doctype/pricing_rule/test_pricing_rule.js erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js +erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js erpnext/accounts/doctype/shipping_rule/test_shipping_rule.js erpnext/crm/doctype/lead/test_lead.js erpnext/crm/doctype/opportunity/test_opportunity.js @@ -86,6 +87,7 @@ erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.js erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js erpnext/accounts/doctype/sales_invoice/test_sales_invoice.js +erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_item_wise_discount.js erpnext/buying/doctype/purchase_order/tests/test_purchase_order.js erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_multi_uom.js