Exemplo n.º 1
0
    def set_missing_values(source, target):
        from erpnext.controllers.accounts_controller import get_default_taxes_and_charges
        quotation = frappe.get_doc(target)

        company_currency = frappe.db.get_value("Company", quotation.company,
                                               "default_currency")
        party_account_currency = get_party_account_currency(
            "Customer", quotation.customer,
            quotation.company) if quotation.customer else company_currency

        quotation.currency = party_account_currency or company_currency

        if company_currency == quotation.currency:
            exchange_rate = 1
        else:
            exchange_rate = get_exchange_rate(quotation.currency,
                                              company_currency,
                                              quotation.transaction_date)

        quotation.conversion_rate = exchange_rate

        # get default taxes
        taxes = get_default_taxes_and_charges(
            "Sales Taxes and Charges Template")
        if taxes:
            quotation.extend("taxes", taxes)

        quotation.run_method("set_missing_values")
        quotation.run_method("calculate_taxes_and_totals")
        if not source.with_items:
            quotation.opportunity = source.name
Exemplo n.º 2
0
	def set_missing_values(source, target):
		from erpnext.controllers.accounts_controller import get_default_taxes_and_charges
		quotation = frappe.get_doc(target)

		company_currency = frappe.get_cached_value('Company',  quotation.company,  "default_currency")

		if quotation.quotation_to == 'Customer' and quotation.party_name:
			party_account_currency = get_party_account_currency("Customer", quotation.party_name, quotation.company)
		else:
			party_account_currency = company_currency

		quotation.currency = party_account_currency or company_currency

		if company_currency == quotation.currency:
			exchange_rate = 1
		else:
			exchange_rate = get_exchange_rate(quotation.currency, company_currency,
				quotation.transaction_date, args="for_selling")

		quotation.conversion_rate = exchange_rate

		# get default taxes
		taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template", company=quotation.company)
		if taxes.get('taxes'):
			quotation.update(taxes)

		quotation.run_method("set_missing_values")
		quotation.run_method("calculate_taxes_and_totals")
		if not source.with_items:
			quotation.opportunity = source.name
Exemplo n.º 3
0
	def set_missing_values(source, target):
		from erpnext.controllers.accounts_controller import get_default_taxes_and_charges
		quotation = frappe.get_doc(target)

		company_currency = frappe.db.get_value("Company", quotation.company, "default_currency")
		party_account_currency = get_party_account_currency("Customer", quotation.customer,
			quotation.company) if quotation.customer else company_currency

		quotation.currency = party_account_currency or company_currency

		if company_currency == quotation.currency:
			exchange_rate = 1
		else:
			exchange_rate = get_exchange_rate(quotation.currency, company_currency,
				quotation.transaction_date)

		quotation.conversion_rate = exchange_rate

		# get default taxes
		taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template")
		if taxes:
			quotation.extend("taxes", taxes)

		quotation.run_method("set_missing_values")
		quotation.run_method("calculate_taxes_and_totals")
		if not source.with_items:
			quotation.opportunity = source.name
Exemplo n.º 4
0
    def set_missing_values(source, target):
        target.supplier = supplier
        target.apply_discount_on = ""
        target.additional_discount_percentage = 0.0
        target.discount_amount = 0.0
        target.update_stock = 1

        target.tax_id, target.tax_cnic, target.tax_strn = frappe.get_value(
            "Supplier", supplier, ['tax_id', 'tax_cnic', 'tax_strn'])

        if target.get('taxes_and_charges'): target.taxes_and_charges = ""
        if target.get('taxes'): target.taxes = []
        default_tax = get_default_taxes_and_charges(
            "Purchase Taxes and Charges Template", company=target.company)
        target.update(default_tax)

        default_price_list = frappe.get_value("Supplier", supplier,
                                              "default_price_list")
        if default_price_list:
            target.buying_price_list = default_price_list

        if target.get('payment_terms_template'):
            target.payment_terms_template = ""
        if target.get('address_display'): target.address_display = ""
        if target.get('shipping_address'): target.shipping_address = ""

        target.run_method("set_missing_values")
        target.run_method("calculate_taxes_and_totals")
Exemplo n.º 5
0
def make_sales_order(sale_factor):
	qty_factor = random.randint(1,(random.randint(1, sale_factor)))
	no_of_items_sold= random.randint(1, 10)
	customer = random.choice(CUSTOMERS)
	sales_order_items = []
	for item in xrange(no_of_items_sold):
		sales_order_items.append({
			"item_code": random.choice(ITEMS),
			"qty": random.randint(1, qty_factor),
			"warehouse": WAREHOUSE
		})
	sales_order = frappe.get_doc({
		"doctype": "Sales Order",
		"creation": frappe.flags.current_date,
		"customer": customer,
		"transaction_date": frappe.flags.current_date,
		"order_type": "Shopping Cart",
		"items": sales_order_items
	})
	taxes = get_default_taxes_and_charges("Sales Taxes and Charges Template", company=COMPANY)
	if taxes.get('taxes'):
		sales_order.update(taxes)
	
	sales_order.save()
	sales_order.submit()
	so = sales_order

	for item in so.items:
		if item.projected_qty<10:
			reorder_stock(item.item_code)

	if flt(so.per_billed) != 100:
		payment_request = make_payment_request(dt="Sales Order", dn=so.name, recipient_id=so.contact_email,
			submit_doc=True, mute_email=True, use_dummy_message=True)

		payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
		payment_entry.posting_date = frappe.flags.current_date
		payment_entry.submit()
	si = frappe.get_doc(make_sales_invoice(so.name))
	si.set_posting_time=True
	si.posting_date = frappe.flags.current_date
	for d in si.get("items"):
		if not d.income_account:
			d.income_account = "Sales - {}".format(frappe.db.get_value('Company', si.company, 'abbr'))
	si.set_missing_values()
	make_payment_entries_for_pos_invoice(si)
	si.insert()
	si.submit()

	dn = make_delivery_note(so.name)
	dn.set_posting_time=True
	dn.posting_date = frappe.flags.current_date
	dn.insert()
	dn.submit()
Exemplo n.º 6
0
    def set_missing_values(source, target):
        from erpnext.controllers.accounts_controller import get_default_taxes_and_charges
        quotation = frappe.get_doc(target)
        quotation.order_type = "Maintenance"
        company_currency = frappe.get_cached_value('Company',
                                                   quotation.company,
                                                   "default_currency")

        if quotation.quotation_to == 'Customer' and quotation.party_name:
            party_account_currency = get_party_account_currency(
                "Customer", quotation.party_name, quotation.company)
        else:
            party_account_currency = company_currency

        quotation.currency = party_account_currency or company_currency

        if company_currency == quotation.currency:
            exchange_rate = 1
        else:
            exchange_rate = get_exchange_rate(quotation.currency,
                                              company_currency,
                                              quotation.transaction_date,
                                              args="for_selling")

        quotation.conversion_rate = exchange_rate

        # add item
        quotation.append(
            'items', {
                'item_code': source.item,
                'qty': source.billing_qty,
                'uom': source.sales_uom,
                'item_booking': source.name
            })

        # get default taxes
        taxes = get_default_taxes_and_charges(
            "Sales Taxes and Charges Template", company=quotation.company)
        if taxes.get('taxes'):
            quotation.update(taxes)

        quotation.run_method("set_missing_values")
        quotation.run_method("calculate_taxes_and_totals")