예제 #1
0
def make_quotation(current_date):
	# get open opportunites
	opportunity = get_random("Opportunity", {"status": "Open"})

	if opportunity:
		from erpnext.crm.doctype.opportunity.opportunity import make_quotation
		qtn = frappe.get_doc(make_quotation(opportunity))
		qtn.insert()
		frappe.db.commit()
		qtn.submit()
		frappe.db.commit()
	else:
		# make new directly
		qtn = frappe.get_doc({
			"creation": current_date,
			"doctype": "Quotation",
			"quotation_to": "Customer",
			"customer": get_random("Customer"),
			"order_type": "Sales",
			"transaction_date": current_date,
			"fiscal_year": cstr(current_date.year)
		})

		add_random_children(qtn, "items", rows=3, randomize = {
			"qty": (1, 5),
			"item_code": ("Item", {"is_sales_item": 1, "ifnull(has_variants,0)": "0"})
		}, unique="item_code")

		qtn.insert()
		frappe.db.commit()
		qtn.submit()
		frappe.db.commit()
예제 #2
0
def setup_budget():
    fiscal_years = frappe.get_all("Fiscal Year",
                                  order_by="year_start_date")[-2:]

    for fy in fiscal_years:
        budget = frappe.new_doc("Budget")
        budget.cost_center = get_random("Cost Center")
        budget.fiscal_year = fy.name
        budget.action_if_annual_budget_exceeded = "Warn"
        expense_ledger_count = frappe.db.count("Account", {
            "is_group": "0",
            "root_type": "Expense"
        })

        add_random_children(budget,
                            "accounts",
                            rows=random.randint(10, expense_ledger_count),
                            randomize={
                                "account": ("Account", {
                                    "is_group": "0",
                                    "root_type": "Expense"
                                })
                            },
                            unique="account")

        for d in budget.accounts:
            d.budget_amount = random.randint(5, 100) * 10000

        budget.save()
        budget.submit()
예제 #3
0
def make_opportunity(domain):
    b = frappe.get_doc({
        "doctype": "Opportunity",
        "opportunity_from": "Customer",
        "customer": get_random("Customer"),
        "opportunity_type": "Sales",
        "with_items": 1,
        "transaction_date": frappe.flags.current_date,
    })

    add_random_children(b,
                        "items",
                        rows=4,
                        randomize={
                            "qty": (1, 5),
                            "item_code": ("Item", {
                                "has_variants": 0,
                                "is_fixed_asset": 0,
                                "domain": domain
                            })
                        },
                        unique="item_code")

    b.insert()
    frappe.db.commit()
예제 #4
0
def make_opportunity():
    b = frappe.get_doc({
        "doctype":
        "Opportunity",
        "opportunity_from":
        "Customer",
        "party_name":
        frappe.get_value(
            "Customer",
            get_random("Customer", filters={"name": ("!=", "Guest")}), 'name'),
        "opportunity_type":
        _("Sales"),
        "with_items":
        1,
        "transaction_date":
        frappe.flags.current_date,
    })

    add_random_children(b,
                        "items",
                        rows=2,
                        randomize={
                            "qty": (1, 5),
                            "item_code": ("Item", {
                                "has_variants": 0,
                                "is_fixed_asset": 0,
                                "is_down_payment_item": 0,
                                "is_sales_item": 1
                            })
                        },
                        unique="item_code")

    b.insert(ignore_permissions=True)
    frappe.db.commit()
예제 #5
0
def make_quotation(domain):
    # get open opportunites
    opportunity = get_random("Opportunity", {
        "status": "Open",
        "with_items": 1
    })

    if opportunity:
        from erpnext.crm.doctype.opportunity.opportunity import make_quotation
        qtn = frappe.get_doc(make_quotation(opportunity))
        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
    else:
        # make new directly

        # get customer, currency and exchange_rate
        customer = get_random("Customer")

        company_currency = frappe.get_cached_value(
            'Company', erpnext.get_default_company(), "default_currency")
        party_account_currency = get_party_account_currency(
            "Customer", customer, 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_selling")

        qtn = frappe.get_doc({
            "creation": frappe.flags.current_date,
            "doctype": "Quotation",
            "quotation_to": "Customer",
            "party_name": customer,
            "currency": party_account_currency or company_currency,
            "conversion_rate": exchange_rate,
            "order_type": "Sales",
            "transaction_date": frappe.flags.current_date,
        })

        add_random_children(qtn,
                            "items",
                            rows=3,
                            randomize={
                                "qty": (1, 5),
                                "item_code": ("Item", {
                                    "has_variants": "0",
                                    "is_fixed_asset": 0,
                                    "domain": domain
                                })
                            },
                            unique="item_code")

        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
예제 #6
0
def make_quotation(current_date):
    # get open opportunites
    opportunity = get_random("Opportunity", {"status": "Open"})

    if opportunity:
        from erpnext.crm.doctype.opportunity.opportunity import make_quotation
        qtn = frappe.get_doc(make_quotation(opportunity))
        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
    else:
        # make new directly

        # get customer, currency and exchange_rate
        customer = get_random("Customer")

        company_currency = frappe.db.get_value("Company", "Wind Power LLC",
                                               "default_currency")
        party_account_currency = get_party_account_currency(
            "Customer", customer, "Wind Power LLC")
        if company_currency == party_account_currency:
            exchange_rate = 1
        else:
            exchange_rate = get_exchange_rate(party_account_currency,
                                              company_currency)

        qtn = frappe.get_doc({
            "creation": current_date,
            "doctype": "Quotation",
            "quotation_to": "Customer",
            "customer": customer,
            "currency": party_account_currency or company_currency,
            "conversion_rate": exchange_rate,
            "order_type": "Sales",
            "transaction_date": current_date,
        })

        add_random_children(qtn,
                            "items",
                            rows=3,
                            randomize={
                                "qty": (1, 5),
                                "item_code": ("Item", {
                                    "is_sales_item": 1,
                                    "has_variants": "0"
                                })
                            },
                            unique="item_code")

        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
예제 #7
0
파일: sales.py 프로젝트: frappe/erpnext
def make_quotation():
    # get open opportunites
    opportunity = get_random("Opportunity", {"status": "Open", "with_items": 1})

    if opportunity:
        from erpnext.crm.doctype.opportunity.opportunity import make_quotation

        qtn = frappe.get_doc(make_quotation(opportunity))
        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
    else:
        # make new directly

        # get customer, currency and exchange_rate
        customer = get_random("Customer")

        company_currency = frappe.db.get_value("Company", "Wind Power LLC", "default_currency")
        party_account_currency = get_party_account_currency("Customer", customer, "Wind Power LLC")
        if company_currency == party_account_currency:
            exchange_rate = 1
        else:
            exchange_rate = get_exchange_rate(party_account_currency, company_currency)

        qtn = frappe.get_doc(
            {
                "creation": frappe.flags.current_date,
                "doctype": "Quotation",
                "quotation_to": "Customer",
                "customer": customer,
                "currency": party_account_currency or company_currency,
                "conversion_rate": exchange_rate,
                "order_type": "Sales",
                "transaction_date": frappe.flags.current_date,
            }
        )

        add_random_children(
            qtn,
            "items",
            rows=3,
            randomize={"qty": (1, 5), "item_code": ("Item", {"has_variants": "0", "is_fixed_asset": 0})},
            unique="item_code",
        )

        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
예제 #8
0
def make_quote(items, customer):
	qtn = frappe.get_doc({
		"doctype": "Quotation",
		"quotation_to": "Customer",
		"customer": customer,
		"order_type": "Sales"
	})

	add_random_children(qtn, "items", rows=len(items), randomize = {
		"qty": (1, 5),
		"item_code": ["Item"]
	}, unique="item_code")

	qtn.insert(ignore_permissions=True)

	qtn.add_comment('Comment', text="This is a dummy record")
예제 #9
0
def make_quote(selling_items, customer):
	qtn = frappe.get_doc({
		"doctype": "Quotation",
		"quotation_to": "Customer",
		"customer": customer,
		"order_type": "Sales"
	})

	add_random_children(qtn, "items", rows=len(selling_items), randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"is_sales_item": 1})
	}, unique="item_code")

	qtn.insert(ignore_permissions=True)

	qtn.add_comment("This is a dummy record")
예제 #10
0
def make_quote(selling_items):
	qtn = frappe.get_doc({
		"doctype": "Quotation",
		"quotation_to": "Customer",
		"customer": get_random("Customer"),
		"order_type": "Sales"
	})

	add_random_children(qtn, "items", rows=len(selling_items), randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"is_sales_item": 1})
	}, unique="item_code")

	qtn.insert(ignore_permissions=True)

	qtn.add_comment("This is a dummy record")
예제 #11
0
파일: sales.py 프로젝트: Aravinthu/erpnext
def make_opportunity():
	b = frappe.get_doc({
		"doctype": "Opportunity",
		"enquiry_from": "Customer",
		"customer": get_random("Customer"),
		"enquiry_type": "Sales",
		"transaction_date": frappe.flags.current_date,
	})

	add_random_children(b, "items", rows=4, randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"has_variants": "0", "is_fixed_asset": 0})
	}, unique="item_code")

	b.insert()
	frappe.db.commit()
예제 #12
0
def make_opportunity(current_date):
	b = frappe.get_doc({
		"creation": current_date,
		"doctype": "Opportunity",
		"enquiry_from": "Customer",
		"customer": get_random("Customer"),
		"enquiry_type": "Sales",
		"transaction_date": current_date,
	})

	add_random_children(b, "items", rows=4, randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"is_sales_item": 1, "has_variants": "0"})
	}, unique="item_code")

	b.insert()
	frappe.db.commit()
예제 #13
0
def make_opportunity(current_date):
	b = frappe.get_doc({
		"creation": current_date,
		"doctype": "Opportunity",
		"enquiry_from": "Customer",
		"customer": get_random("Customer"),
		"enquiry_type": "Sales",
		"transaction_date": current_date,
	})

	add_random_children(b, "items", rows=4, randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"has_variants": "0"})
	}, unique="item_code")

	b.insert()
	frappe.db.commit()
예제 #14
0
def make_opportunity(items, customer):
	b = frappe.get_doc({
		"doctype": "Opportunity",
		"enquiry_from": "Customer",
		"customer": customer,
		"opportunity_type": _("Sales"),
		"with_items": 1
	})

	add_random_children(b, "items", rows=len(items), randomize = {
		"qty": (1, 5),
		"item_code": ["Item"]
	}, unique="item_code")

	b.insert(ignore_permissions=True)

	b.add_comment('Comment', text="This is a dummy record")
예제 #15
0
def make_opportunity(selling_items):
	b = frappe.get_doc({
		"doctype": "Opportunity",
		"enquiry_from": "Customer",
		"customer": get_random("Customer"),
		"enquiry_type": "Sales",
		"with_items": 1
	})

	add_random_children(b, "items", rows=len(selling_items), randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"is_sales_item": 1})
	}, unique="item_code")

	b.insert(ignore_permissions=True)

	b.add_comment("This is a dummy record")
예제 #16
0
def make_opportunity(items, customer):
	b = frappe.get_doc({
		"doctype": "Opportunity",
		"opportunity_from": "Customer",
		"customer": customer,
		"opportunity_type": _("Sales"),
		"with_items": 1
	})

	add_random_children(b, "items", rows=len(items), randomize = {
		"qty": (1, 5),
		"item_code": ["Item"]
	}, unique="item_code")

	b.insert(ignore_permissions=True)

	b.add_comment('Comment', text="This is a dummy record")
예제 #17
0
def make_opportunity(selling_items, customer):
	b = frappe.get_doc({
		"doctype": "Opportunity",
		"enquiry_from": "Customer",
		"customer": customer,
		"enquiry_type": "Sales",
		"with_items": 1
	})

	add_random_children(b, "items", rows=len(selling_items), randomize = {
		"qty": (1, 5),
		"item_code": ("Item", {"is_sales_item": 1})
	}, unique="item_code")

	b.insert(ignore_permissions=True)

	b.add_comment("This is a dummy record")
예제 #18
0
def setup_budget():
	fiscal_years = frappe.get_all("Fiscal Year", order_by="year_start_date")[-2:]

	for fy in fiscal_years:
		budget = frappe.new_doc("Budget")
		budget.cost_center = get_random("Cost Center")
		budget.fiscal_year = fy.name
		budget.action_if_annual_budget_exceeded = "Warn"
		expense_ledger_count = frappe.db.count("Account", {"is_group": "0", "root_type": "Expense"})

		add_random_children(budget, "accounts", rows=random.randint(10, expense_ledger_count), randomize = { 			"account": ("Account", {"is_group": "0", "root_type": "Expense"})
		}, unique="account")

		for d in budget.accounts:
			d.budget_amount = random.randint(5, 100) * 10000

		budget.save()
		budget.submit()
예제 #19
0
def make_quotation(current_date):
    # get open opportunites
    opportunity = get_random("Opportunity", {"status": "Open"})

    if opportunity:
        from erpnext.crm.doctype.opportunity.opportunity import make_quotation

        qtn = frappe.get_doc(make_quotation(opportunity))
        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()
    else:
        # make new directly
        qtn = frappe.get_doc(
            {
                "creation": current_date,
                "doctype": "Quotation",
                "quotation_to": "Customer",
                "customer": get_random("Customer"),
                "order_type": "Sales",
                "transaction_date": current_date,
                "fiscal_year": cstr(current_date.year),
            }
        )

        add_random_children(
            qtn,
            "items",
            rows=3,
            randomize={"qty": (1, 5), "item_code": ("Item", {"is_sales_item": 1, "ifnull(has_variants,0)": "0"})},
            unique="item_code",
        )

        qtn.insert()
        frappe.db.commit()
        qtn.submit()
        frappe.db.commit()