def get_customer_outstanding_amount(self): outstanding_amt = get_customer_outstanding('_Test Customer', '_Test Company') # If outstanding is negative make a transaction to get positive outstanding amount if outstanding_amt > 0.0: return outstanding_amt item_qty = int((abs(outstanding_amt) + 200)/100) make_sales_order({'qty':item_qty}) return get_customer_outstanding('_Test Customer', '_Test Company')
def get_customer_outstanding_amount(self): from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order outstanding_amt = get_customer_outstanding('_Test Customer', '_Test Company') # If outstanding is negative make a transaction to get positive outstanding amount if outstanding_amt > 0.0: return outstanding_amt item_qty = int((abs(outstanding_amt) + 200)/100) make_sales_order(qty=item_qty) return get_customer_outstanding('_Test Customer', '_Test Company')
def get_customer_outstanding_amount(self): from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order outstanding_amt = get_customer_outstanding('_Test Customer', '_Test Company') # If outstanding is negative make a transaction to get positive outstanding amount if outstanding_amt > 0.0: return outstanding_amt item_qty = int((abs(outstanding_amt) + 200)/100) make_sales_order(qty=item_qty) return get_customer_outstanding('_Test Customer', '_Test Company')
def execute(filters=None): if not filters: filters = {} #Check if customer id is according to naming series or customer name customer_naming_type = frappe.db.get_value("Selling Settings", None, "cust_master_name") columns = get_columns(customer_naming_type) data = [] customer_list = get_details(filters) for d in customer_list: row = [] outstanding_amt = get_customer_outstanding(d.name, filters.get("company")) credit_limit = get_credit_limit(d.name, filters.get("company")) bal = flt(credit_limit) - flt(outstanding_amt) if customer_naming_type == "Naming Series": row = [d.name, d.customer_name, credit_limit, outstanding_amt, bal] else: row = [d.name, credit_limit, outstanding_amt, bal] if credit_limit: data.append(row) return columns, data
def execute(filters=None): if not filters: filters = {} #Check if customer id is according to naming series or customer name customer_naming_type = frappe.db.get_value("Selling Settings", None, "cust_master_name") columns = get_columns(customer_naming_type) data = [] customer_list = get_details(filters) for d in customer_list: row = [] outstanding_amt = get_customer_outstanding(d.name, filters.get("company"), ignore_outstanding_sales_order=d.bypass_credit_limit_check_at_sales_order, cost_center=filters.get("cost_center")) credit_limit = get_credit_limit(d.name, filters.get("company")) bal = flt(credit_limit) - flt(outstanding_amt) if customer_naming_type == "Naming Series": row = [d.name, d.customer_name, credit_limit, outstanding_amt, bal, d.bypass_credit_limit_check_at_sales_order, d.is_frozen, d.disabled] else: row = [d.name, credit_limit, outstanding_amt, bal, d.bypass_credit_limit_check_at_sales_order, d.is_frozen, d.disabled] if credit_limit: data.append(row) return columns, data
def execute(filters=None): if not filters: filters = {} #Check if customer id is according to naming series or customer name customer_naming_type = frappe.db.get_value("Selling Settings", None, "cust_master_name") columns = get_columns(customer_naming_type) data = [] customer_list = get_details(filters) frappe.msgprint(str(customer_list)) for d in customer_list: row = [] outstanding_amt = get_customer_outstanding(d.name, filters.get("company")) credit_limit = get_credit_limit(d.name, filters.get("company")) bal = flt(credit_limit) - flt(outstanding_amt) if customer_naming_type == "Naming Series": row = [d.name, d.customer_name, credit_limit, outstanding_amt, bal] else: row = [d.name, credit_limit, outstanding_amt, bal] if credit_limit: data.append(row) frappe.msgprint(str(data)) return columns, data
def _get_party_details(party=None, account=None, party_type="Customer", letter_of_credit=None, company=None, posting_date=None, bill_date=None, price_list=None, currency=None, doctype=None, ignore_permissions=False, fetch_payment_terms_template=True, transaction_type=None, cost_center=None, tax_id=None, tax_cnic=None, tax_strn=None, has_stin=None, party_address=None, shipping_address=None, pos_profile=None): out = frappe._dict(set_due_date(party, party_type, company, posting_date, bill_date, doctype)) party = out[scrub(party_type)] if not ignore_permissions and not frappe.has_permission(party_type, "read", party): frappe.throw(_("Not permitted for {0}").format(party), frappe.PermissionError) if party or letter_of_credit: account = get_party_account("Letter of Credit" if letter_of_credit else party_type, letter_of_credit if letter_of_credit else party, company) account_fieldname = "debit_to" if party_type=="Customer" else "credit_to" out[account_fieldname] = account party = frappe.get_doc(party_type, party) currency = party.default_currency if party.get("default_currency") else get_company_currency(company) party_address, shipping_address = set_address_details(out, party, party_type, doctype, company, party_address, shipping_address) set_contact_details(out, party, party_type) set_other_values(out, party, party_type) set_price_list(out, party, party_type, price_list, pos_profile) out["tax_category"] = get_address_tax_category(party.get("tax_category"), party_address, shipping_address if party_type != "Supplier" else party_address) out["taxes_and_charges"] = set_taxes(party.name, party_type, posting_date, company, customer_group=out.customer_group, supplier_group=out.supplier_group, tax_category=out.tax_category, transaction_type=transaction_type, cost_center=cost_center, tax_id=tax_id, tax_cnic=tax_cnic, tax_strn=tax_strn, has_stin=has_stin, billing_address=party_address, shipping_address=shipping_address) if fetch_payment_terms_template: out["payment_terms_template"] = get_pyt_term_template(party.name, party_type, company) if not out.get("currency"): out["currency"] = currency # sales team if party_type=="Customer": out["sales_team"] = [{ "sales_person": d.sales_person, "allocated_percentage": d.allocated_percentage or None } for d in party.get("sales_team")] if doctype == "Sales Order": from erpnext.selling.doctype.customer.customer import get_credit_limit, get_customer_outstanding out["customer_credit_limit"] = get_credit_limit(party.name, company) out["customer_outstanding_amount"] = get_customer_outstanding(party.name, company) out["customer_credit_balance"] = out["customer_credit_limit"] - out["customer_outstanding_amount"] # supplier tax withholding category if party_type == "Supplier" and party: out["supplier_tds"] = frappe.get_value(party_type, party.name, "tax_withholding_category") return out
def get_credit_details(customer, company): outstanding = get_customer_outstanding(customer, company) credit_limit = get_credit_limit(customer, company) bal = credit_limit - outstanding if bal < 0: bal = 0 return { "outstanding": outstanding, "credit_limit": credit_limit, "bal": bal }