Beispiel #1
0
    def test_make_supplier_quotation(self):
        rfq = make_request_for_quotation()

        sq = make_supplier_quotation_from_rfq(
            rfq.name, for_supplier=rfq.get('suppliers')[0].supplier)
        sq.submit()

        sq1 = make_supplier_quotation_from_rfq(
            rfq.name, for_supplier=rfq.get('suppliers')[1].supplier)
        sq1.submit()

        self.assertEqual(sq.supplier, rfq.get('suppliers')[0].supplier)
        self.assertEqual(sq.get('items')[0].request_for_quotation, rfq.name)
        self.assertEqual(sq.get('items')[0].item_code, "_Test Item")
        self.assertEqual(sq.get('items')[0].qty, 5)

        self.assertEqual(sq1.supplier, rfq.get('suppliers')[1].supplier)
        self.assertEqual(sq1.get('items')[0].request_for_quotation, rfq.name)
        self.assertEqual(sq1.get('items')[0].item_code, "_Test Item")
        self.assertEqual(sq1.get('items')[0].qty, 5)
Beispiel #2
0
    def test_quote_status(self):
        rfq = make_request_for_quotation()

        self.assertEqual(rfq.get('suppliers')[0].quote_status, 'Pending')
        self.assertEqual(rfq.get('suppliers')[1].quote_status, 'Pending')

        # Submit the first supplier quotation
        sq = make_supplier_quotation_from_rfq(
            rfq.name, for_supplier=rfq.get('suppliers')[0].supplier)
        sq.submit()

        rfq.update_rfq_supplier_status()  #rfq.get('suppliers')[1].supplier)

        self.assertEqual(rfq.get('suppliers')[0].quote_status, 'Received')
        self.assertEqual(rfq.get('suppliers')[1].quote_status, 'Pending')
    def test_make_supplier_quotation_with_special_characters(self):
        frappe.delete_doc_if_exists("Supplier", "_Test Supplier '1", force=1)
        supplier = frappe.new_doc("Supplier")
        supplier.supplier_name = "_Test Supplier '1"
        supplier.supplier_group = "_Test Supplier Group"
        supplier.insert()

        rfq = make_request_for_quotation(supplier_data=supplier_wt_appos)

        sq = make_supplier_quotation_from_rfq(
            rfq.name, for_supplier=supplier_wt_appos[0].get("supplier"))
        sq.submit()

        frappe.form_dict.name = rfq.name

        self.assertEqual(
            check_supplier_has_docname_access(
                supplier_wt_appos[0].get("supplier")), True)

        # reset form_dict
        frappe.form_dict.name = None
Beispiel #4
0
def work():
    frappe.set_user(frappe.db.get_global('demo_purchase_user'))

    if random.random() < 0.6:
        report = "Items To Be Requested"
        for row in query_report.run(report)["result"][:random.randint(1, 5)]:
            item_code, qty = row[0], abs(row[-1])

            mr = make_material_request(item_code, qty)

    if random.random() < 0.6:
        for mr in frappe.get_all('Material Request',
                                 filters={
                                     'material_request_type': 'Purchase',
                                     'status': 'Open'
                                 },
                                 limit=random.randint(1, 6)):
            if not frappe.get_all('Request for Quotation',
                                  filters={'material_request': mr.name},
                                  limit=1):
                rfq = make_request_for_quotation(mr.name)
                rfq.transaction_date = frappe.flags.current_date
                add_suppliers(rfq)
                rfq.save()
                rfq.submit()

    # Make suppier quotation from RFQ against each supplier.
    if random.random() < 0.6:
        for rfq in frappe.get_all('Request for Quotation',
                                  filters={'status': 'Open'},
                                  limit=random.randint(1, 6)):
            if not frappe.get_all('Supplier Quotation',
                                  filters={'request_for_quotation': rfq.name},
                                  limit=1):
                rfq = frappe.get_doc('Request for Quotation', rfq.name)

                for supplier in rfq.suppliers:
                    supplier_quotation = make_supplier_quotation_from_rfq(
                        rfq.name, for_supplier=supplier.supplier)
                    supplier_quotation.save()
                    supplier_quotation.submit()

    # get supplier details
    supplier = get_random("Supplier")

    company_currency = frappe.get_cached_value('Company',
                                               erpnext.get_default_company(),
                                               "default_currency")
    party_account_currency = get_party_account_currency(
        "Supplier", supplier, erpnext.get_default_company())
    if company_currency == party_account_currency:
        exchange_rate = 1
    else:
        exchange_rate = get_exchange_rate(party_account_currency,
                                          company_currency,
                                          args="for_buying")

    # make supplier quotations
    if random.random() < 0.5:
        from erpnext.stock.doctype.material_request.material_request import make_supplier_quotation

        report = "Material Requests for which Supplier Quotations are not created"
        for row in query_report.run(report)["result"][:random.randint(1, 3)]:
            if row[0] != "Total":
                sq = frappe.get_doc(make_supplier_quotation(row[0]))
                sq.transaction_date = frappe.flags.current_date
                sq.supplier = supplier
                sq.currency = party_account_currency or company_currency
                sq.conversion_rate = exchange_rate
                sq.insert()
                sq.submit()
                frappe.db.commit()

    # make purchase orders
    if random.random() < 0.5:
        from erpnext.stock.doctype.material_request.material_request import make_purchase_order
        report = "Requested Items To Be Ordered"
        for row in query_report.run(
                report)["result"][:how_many("Purchase Order")]:
            if row[0] != "Total":
                try:
                    po = frappe.get_doc(make_purchase_order(row[0]))
                    po.supplier = supplier
                    po.currency = party_account_currency or company_currency
                    po.conversion_rate = exchange_rate
                    po.transaction_date = frappe.flags.current_date
                    po.insert()
                    po.submit()
                except Exception:
                    pass
                else:
                    frappe.db.commit()

    if random.random() < 0.5:
        make_subcontract()