Added tests
This commit is contained in:
parent
1b43515160
commit
bea7d9f919
@ -160,7 +160,7 @@ class RequestforQuotation(BuyingController):
|
||||
|
||||
def update_rfq_supplier_status(self, sup_name=None):
|
||||
for supplier in self.suppliers:
|
||||
if sup_name != None and supplier.supplier == sup_name:
|
||||
if sup_name == None or supplier.supplier == sup_name:
|
||||
if supplier.quote_status != _('No Quote'):
|
||||
quote_status = _('Received')
|
||||
for item in self.items:
|
||||
|
@ -10,21 +10,41 @@ from erpnext.templates.pages.rfq import check_supplier_has_docname_access
|
||||
from frappe.utils import nowdate
|
||||
|
||||
class TestRequestforQuotation(unittest.TestCase):
|
||||
def test_quote_status(self):
|
||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation
|
||||
rfq = make_request_for_quotation()
|
||||
|
||||
self.assertEquals(rfq.get('suppliers')[0].quote_status, 'Pending')
|
||||
self.assertEquals(rfq.get('suppliers')[1].quote_status, 'Pending')
|
||||
|
||||
# Submit the first supplier quotation
|
||||
sq = make_supplier_quotation(rfq.name, rfq.get('suppliers')[0].supplier)
|
||||
sq.submit()
|
||||
|
||||
# No Quote first supplier quotation
|
||||
rfq.get('suppliers')[1].no_quote = 1
|
||||
rfq.get('suppliers')[1].quote_status = 'No Quote'
|
||||
|
||||
rfq.update_rfq_supplier_status() #rfq.get('suppliers')[1].supplier)
|
||||
|
||||
self.assertEquals(rfq.get('suppliers')[0].quote_status, 'Received')
|
||||
self.assertEquals(rfq.get('suppliers')[1].quote_status, 'No Quote')
|
||||
|
||||
def test_make_supplier_quotation(self):
|
||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation
|
||||
rfq = make_request_for_quotation()
|
||||
|
||||
|
||||
sq = make_supplier_quotation(rfq.name, rfq.get('suppliers')[0].supplier)
|
||||
sq.submit()
|
||||
|
||||
|
||||
sq1 = make_supplier_quotation(rfq.name, rfq.get('suppliers')[1].supplier)
|
||||
sq1.submit()
|
||||
|
||||
|
||||
self.assertEquals(sq.supplier, rfq.get('suppliers')[0].supplier)
|
||||
self.assertEquals(sq.get('items')[0].request_for_quotation, rfq.name)
|
||||
self.assertEquals(sq.get('items')[0].item_code, "_Test Item")
|
||||
self.assertEquals(sq.get('items')[0].qty, 5)
|
||||
|
||||
|
||||
self.assertEquals(sq1.supplier, rfq.get('suppliers')[1].supplier)
|
||||
self.assertEquals(sq1.get('items')[0].request_for_quotation, rfq.name)
|
||||
self.assertEquals(sq1.get('items')[0].item_code, "_Test Item")
|
||||
@ -61,15 +81,15 @@ class TestRequestforQuotation(unittest.TestCase):
|
||||
rfq.get('items')[0].rate = 100
|
||||
rfq.supplier = rfq.suppliers[0].supplier
|
||||
supplier_quotation_name = create_supplier_quotation(rfq)
|
||||
|
||||
|
||||
supplier_quotation_doc = frappe.get_doc('Supplier Quotation', supplier_quotation_name)
|
||||
|
||||
|
||||
self.assertEquals(supplier_quotation_doc.supplier, rfq.get('suppliers')[0].supplier)
|
||||
self.assertEquals(supplier_quotation_doc.get('items')[0].request_for_quotation, rfq.name)
|
||||
self.assertEquals(supplier_quotation_doc.get('items')[0].item_code, "_Test Item")
|
||||
self.assertEquals(supplier_quotation_doc.get('items')[0].qty, 5)
|
||||
self.assertEquals(supplier_quotation_doc.get('items')[0].amount, 500)
|
||||
|
||||
|
||||
|
||||
def make_request_for_quotation(supplier_data=None):
|
||||
"""
|
||||
@ -81,10 +101,10 @@ def make_request_for_quotation(supplier_data=None):
|
||||
rfq.status = 'Draft'
|
||||
rfq.company = '_Test Company'
|
||||
rfq.message_for_supplier = 'Please supply the specified items at the best possible rates.'
|
||||
|
||||
|
||||
for data in supplier_data:
|
||||
rfq.append('suppliers', data)
|
||||
|
||||
|
||||
rfq.append("items", {
|
||||
"item_code": "_Test Item",
|
||||
"description": "_Test Item",
|
||||
@ -93,11 +113,11 @@ def make_request_for_quotation(supplier_data=None):
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"schedule_date": nowdate()
|
||||
})
|
||||
|
||||
|
||||
rfq.submit()
|
||||
|
||||
|
||||
return rfq
|
||||
|
||||
|
||||
def get_supplier_data():
|
||||
return [{
|
||||
"supplier": "_Test Supplier",
|
||||
|
@ -0,0 +1,133 @@
|
||||
QUnit.module('buying');
|
||||
|
||||
QUnit.test("Test: Request for Quotation", function (assert) {
|
||||
assert.expect(5);
|
||||
let done = assert.async();
|
||||
let rfq_name = "";
|
||||
|
||||
frappe.run_serially([
|
||||
// Go to RFQ list
|
||||
() => frappe.set_route("List", "Request for Quotation"),
|
||||
// Create a new RFQ
|
||||
() => frappe.new_doc("Request for Quotation"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("transaction_date", "04-04-2017"),
|
||||
() => cur_frm.set_value("company", "_Test Company"),
|
||||
// Add Suppliers
|
||||
() => {
|
||||
cur_frm.fields_dict.suppliers.grid.grid_rows[0].toggle_view();
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.fields_dict.suppliers.grid.grid_rows[0].doc.supplier = "_Test Supplier";
|
||||
frappe.click_check('Send Email');
|
||||
cur_frm.cur_grid.frm.script_manager.trigger('supplier');
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.cur_grid.toggle_view();
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Add Row',0),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.fields_dict.suppliers.grid.grid_rows[1].toggle_view();
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc.supplier = "_Test Supplier 1";
|
||||
frappe.click_check('Send Email');
|
||||
cur_frm.cur_grid.frm.script_manager.trigger('supplier');
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.cur_grid.toggle_view();
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
//Add Item
|
||||
() => {
|
||||
cur_frm.fields_dict.items.grid.grid_rows[0].toggle_view();
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.fields_dict.items.grid.grid_rows[0].doc.item_code = "_Test Item";
|
||||
frappe.set_control('item_code',"_Test Item");
|
||||
frappe.set_control('qty',5);
|
||||
frappe.set_control('schedule_date', "05-05-2017");
|
||||
cur_frm.cur_grid.frm.script_manager.trigger('supplier');
|
||||
},
|
||||
() => frappe.timeout(2),
|
||||
() => {
|
||||
cur_frm.cur_grid.toggle_view();
|
||||
},
|
||||
() => frappe.timeout(2),
|
||||
() => {
|
||||
cur_frm.fields_dict.items.grid.grid_rows[0].doc.warehouse = "_Test Warehouse - _TC";
|
||||
},
|
||||
() => frappe.click_button('Save'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Submit'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Yes'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Menu'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_link('Reload'),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.docstatus, 1);
|
||||
rfq_name = cur_frm.doc.name;
|
||||
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[0].doc.quote_status == "Pending");
|
||||
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc.quote_status == "Pending");
|
||||
},
|
||||
() => {
|
||||
cur_frm.fields_dict.suppliers.grid.grid_rows[0].toggle_view();
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
frappe.click_check('No Quote');
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
cur_frm.cur_grid.toggle_view();
|
||||
},
|
||||
() => frappe.click_button('Update'),
|
||||
() => frappe.timeout(1),
|
||||
|
||||
() => frappe.click_button('Supplier Quotation'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_link('Make'),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
frappe.set_control('supplier',"_Test Supplier 1");
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Make Supplier Quotation'),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("company", "_Test Company"),
|
||||
() => cur_frm.fields_dict.items.grid.grid_rows[0].doc.rate = 4.99,
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Save'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Submit'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Yes'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.set_route("List", "Request for Quotation"),
|
||||
() => frappe.timeout(2),
|
||||
() => frappe.set_route("List", "Request for Quotation"),
|
||||
() => frappe.timeout(2),
|
||||
() => frappe.click_link(rfq_name),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Menu'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_link('Reload'),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc.quote_status == "Received");
|
||||
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[0].doc.no_quote == 1);
|
||||
console.log(cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc);
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user