Пример #1
0
def _set_price_list(cart_settings, quotation=None):
    """Set price list based on customer or shopping cart default"""
    from erpnext.accounts.party import get_default_price_list

    # check if customer price list exists
    selling_price_list = None

    #if quotation.party_name:
    #	selling_price_list = frappe.db.get_value('Customer', quotation.party_name, 'default_price_list')
    if quotation and quotation.get("party_name"):
        selling_price_list = frappe.db.get_value('Customer',
                                                 quotation.get("party_name"),
                                                 'default_price_list')

    # else check for territory based price list
    if not selling_price_list:
        selling_price_list = cart_settings.price_list

    #if not selling_price_list and quotation.party_name:
    #	selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
    party_name = quotation.get("party_name") if quotation else get_party().get(
        "name")

    #quotation.selling_price_list = selling_price_list
    if not selling_price_list and party_name:
        selling_price_list = get_default_price_list(
            frappe.get_doc("Customer", party_name))

    if quotation:
        quotation.selling_price_list = selling_price_list

    return selling_price_list
Пример #2
0
 def test_get_default_price_list_should_return_none_for_invalid_group(self):
     customer = frappe.get_doc({
         "doctype": "Customer",
         "customer_name": "test customer",
     }).insert(ignore_permissions=True, ignore_mandatory=True)
     customer.customer_group = None
     customer.save()
     price_list = get_default_price_list(customer)
     assert price_list is None
Пример #3
0
    def get_plan_rate(self, plan, quantity=1, date=nowdate()):
        if plan.price_determination == "Fixed rate":
            return plan.fixed_rate

        elif plan.price_determination == "Based on price list":
            customer_doc = frappe.get_doc("Customer", self.customer)
            price_list = get_default_price_list(customer_doc)
            if not price_list:
                price_list = frappe.db.get_value("Price List", {"selling": 1})

            price_list_rate = get_price_list_rate_for(
                {
                    "company": self.company,
                    "uom": plan.uom,
                    "customer": self.customer,
                    "price_list": price_list,
                    "currency": self.currency,
                    "min_qty": quantity,
                    "transaction_date": date
                }, plan.item)

            rule = get_pricing_rule_for_item(
                frappe._dict({
                    "company":
                    self.company,
                    "uom":
                    plan.uom,
                    "item_code":
                    plan.item,
                    "stock_qty":
                    quantity,
                    "transaction_type":
                    "selling",
                    "price_list_rate":
                    price_list_rate,
                    "price_list_currency":
                    frappe.db.get_value("Price List", price_list, "currency"),
                    "price_list":
                    price_list,
                    "customer":
                    self.customer,
                    "currency":
                    self.currency,
                    "transaction_date":
                    date,
                    "warehouse":
                    frappe.db.get_value("Warehouse",
                                        dict(is_group=1, parent_warehouse=''))
                }))

            if rule.get("price_list_rate"):
                price_list_rate = rule.get("price_list_rate")

            return price_list_rate or 0
Пример #4
0
def _set_price_list(quotation, cart_settings):
	"""Set price list based on customer or shopping cart default"""
	if quotation.selling_price_list:
		return

	# check if customer price list exists
	selling_price_list = None
	if quotation.customer:
		from erpnext.accounts.party import get_default_price_list
		selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.customer))

	# else check for territory based price list
	if not selling_price_list:
		selling_price_list = cart_settings.price_list

	quotation.selling_price_list = selling_price_list
Пример #5
0
def _set_price_list(quotation, cart_settings):
	"""Set price list based on customer or shopping cart default"""
	if quotation.selling_price_list:
		return

	# check if customer price list exists
	selling_price_list = None
	if quotation.customer:
		from erpnext.accounts.party import get_default_price_list
		selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.customer))

	# else check for territory based price list
	if not selling_price_list:
		selling_price_list = cart_settings.price_list

	quotation.selling_price_list = selling_price_list
Пример #6
0
def _set_price_list(quotation, cart_settings):
	"""Set price list based on customer or shopping cart default"""
	from erpnext.accounts.party import get_default_price_list

	# check if customer price list exists
	selling_price_list = None
	if quotation.party_name:
		selling_price_list = frappe.db.get_value('Customer', quotation.party_name, 'default_price_list')

	# else check for territory based price list
	if not selling_price_list:
		selling_price_list = cart_settings.price_list

	if not selling_price_list and quotation.party_name:
		selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))

	quotation.selling_price_list = selling_price_list
Пример #7
0
def _set_price_list(cart_settings, quotation=None):
	"""Set price list based on customer or shopping cart default"""
	from erpnext.accounts.party import get_default_price_list
	party_name = quotation.get("party_name") if quotation else get_party().get("name")
	selling_price_list = None

	# check if default customer price list exists
	if party_name and frappe.db.exists("Customer", party_name):
		selling_price_list = get_default_price_list(frappe.get_doc("Customer", party_name))

	# check default price list in shopping cart
	if not selling_price_list:
		selling_price_list = cart_settings.price_list

	if quotation:
		quotation.selling_price_list = selling_price_list

	return selling_price_list