def apply_cart_settings(party=None, quotation=None): if not party: party = get_party() if not quotation: quotation = _get_cart_quotation(party) cart_settings = frappe.get_doc("Shopping Cart Settings") set_price_list_and_rate(quotation, cart_settings) quotation.run_method("calculate_taxes_and_totals") set_taxes(quotation, cart_settings) _apply_shipping_rule(party, quotation, cart_settings)
def get_lead_details(lead, posting_date=None, company=None): if not lead: return {} from erpnext.accounts.party import set_address_details out = frappe._dict() lead_doc = frappe.get_doc("Lead", lead) lead = lead_doc out.update({ "territory": lead.territory, "customer_name": lead.company_name or lead.lead_name, "contact_display": lead.lead_name, "contact_email": lead.email_id, "contact_mobile": lead.mobile_no, "contact_phone": lead.phone, }) set_address_details(out, lead, "Lead") taxes_and_charges = set_taxes( None, 'Lead', posting_date, company, billing_address=out.get('customer_address'), shipping_address=out.get('shipping_address_name')) if taxes_and_charges: out['taxes_and_charges'] = taxes_and_charges return out
def get_lead_details(lead, posting_date=None, company=None): if not lead: return {} from erpnext.accounts.party import set_address_details out = frappe._dict() lead_doc = frappe.get_doc("Lead", lead) lead = lead_doc out.update({ "territory": lead.territory, "customer_name": lead.company_name or lead.lead_name, "contact_display": lead.lead_name, "contact_email": lead.email_id, "contact_mobile": lead.mobile_no, "contact_phone": lead.phone, }) set_address_details(out, lead, "Lead") taxes_and_charges = set_taxes(None, 'Lead', posting_date, company, billing_address=out.get('customer_address'), shipping_address=out.get('shipping_address_name')) if taxes_and_charges: out['taxes_and_charges'] = taxes_and_charges return out
def set_taxes(quotation, cart_settings): """set taxes based on billing territory""" from erpnext.accounts.party import set_taxes customer_group = frappe.db.get_value("Customer", quotation.party_name, "customer_group") quotation.taxes_and_charges = set_taxes( quotation.party_name, "Customer", quotation.transaction_date, quotation.company, customer_group=customer_group, supplier_group=None, tax_category=quotation.tax_category, billing_address=quotation.customer_address, shipping_address=quotation.shipping_address_name, use_for_shopping_cart=1, ) # # # clear table quotation.set("taxes", []) # # # append taxes quotation.append_taxes_from_master()
def test_tax_rule(self): self.login_as_customer() quotation = self.create_quotation() if not frappe.db.count("Tax Rule"): frappe.set_user("Administrator") from erpnext.accounts.doctype.tax_rule.test_tax_rule import make_tax_rule make_tax_rule(customer=quotation.party_name, company=quotation.company, use_for_shopping_cart=1, save=True, sales_tax_template="_Test Tax 1 - _TC") from erpnext.accounts.party import set_taxes tax_rule_master = set_taxes( quotation.party_name, "Customer", quotation.transaction_date, quotation.company, customer_group=None, supplier_group=None, tax_category=quotation.tax_category, billing_address=quotation.customer_address, shipping_address=quotation.shipping_address_name, use_for_shopping_cart=1) self.assertEqual(quotation.taxes_and_charges, tax_rule_master) self.assertEqual(quotation.total_taxes_and_charges, 1000.0) self.remove_test_quotation(quotation)
def test_tax_rule(self): self.login_as_customer() quotation = self.create_quotation() from erpnext.accounts.party import set_taxes tax_rule_master = set_taxes(quotation.party_name, "Customer", \ quotation.transaction_date, quotation.company, None, None, \ quotation.customer_address, quotation.shipping_address_name, 1) self.assertEqual(quotation.taxes_and_charges, tax_rule_master) self.assertEqual(quotation.total_taxes_and_charges, 1000.0) self.remove_test_quotation(quotation)
def test_tax_rule(self): self.login_as_customer() quotation = self.create_quotation() from erpnext.accounts.party import set_taxes tax_rule_master = set_taxes(quotation.party_name, "Customer", quotation.transaction_date, quotation.company, customer_group=None, supplier_group=None, tax_category=quotation.tax_category, billing_address=quotation.customer_address, shipping_address=quotation.shipping_address_name, use_for_shopping_cart=1) self.assertEqual(quotation.taxes_and_charges, tax_rule_master) self.assertEqual(quotation.total_taxes_and_charges, 1000.0) self.remove_test_quotation(quotation)
def set_taxes(quotation, cart_settings): """set taxes based on billing territory""" from erpnext.accounts.party import set_taxes customer_group = frappe.db.get_value("Customer", quotation.customer, "customer_group") quotation.taxes_and_charges = set_taxes(quotation.customer, "Customer", \ quotation.transaction_date, quotation.company, customer_group, None, \ quotation.customer_address, quotation.shipping_address_name, 1) # # # clear table quotation.set("taxes", []) # # # append taxes quotation.append_taxes_from_master()
def get_lead_details(lead, posting_date=None, company=None): if not lead: return {} # 2017-03-10 - renmai - copié la fonction get_lead_details au lieu de l'appel du module erpnext. # Partait en boucle. from erpnext.accounts.party import set_address_details out = frappe._dict() frappe.msgprint("get_lead_details RADPP") lead_doc = frappe.get_doc("Lead", lead) lead = lead_doc out.update({ "territory": lead.territory, "customer_name": lead.company_name or lead.lead_name, "contact_display": lead.lead_name, "contact_email": lead.email_id, "contact_mobile": lead.mobile_no, "contact_phone": lead.phone, }) set_address_details(out, lead, "Lead") taxes_and_charges = set_taxes( None, 'Lead', posting_date, company, billing_address=out.get('customer_address'), shipping_address=out.get('shipping_address_name')) if taxes_and_charges: out['taxes_and_charges'] = taxes_and_charges # 2017-01-18 - RM - Ajout de balise pour mettre le lead name en gras. out.update({"contact_display": "<b>" + lead.lead_name + "</b>"}) # 2017-01-18 - RM - permet d afficher le telephone et le courriel dans contact_display. Pour les rapports Jasper. if lead.phone: out['contact_display'] = out['contact_display'] + "<br>" + lead.phone if lead.email_id: out['contact_display'] = out['contact_display'] + "<br>" + lead.email_id return out
def set_subscription_invoicing_details(self, document, prorate=0): document.customer = self.customer document.customer_group, document.territory = frappe.db.get_value( "Customer", self.customer, ["customer_group", "territory"]) document.set_missing_lead_customer_details() document.subscription = self.name document.ignore_pricing_rule = 1 if self.get_plans_pricing_rules( ) and self.get_plans_pricing_rules().pop() == "Fixed rate" else 0 # Subscription is better suited for service items. It won't update `update_stock` # for that reason items_list = self.get_items_from_plans([p for p in self.plans if p.status == "Active"],\ document.posting_date if document.doctype == "Sales Invoice" else document.transaction_date, prorate) for item in items_list: document.append('items', item) # Shipping if self.shipping_rule: document.shipping_rule = self.shipping_rule document.apply_shipping_rule() # Taxes if self.tax_template: document.taxes_and_charges = self.tax_template else: from erpnext.accounts.party import set_taxes document.taxes_and_charges = set_taxes( party=self.customer, party_type="Customer", posting_date=document.posting_date if document.doctype == "Sales Invoice" else document.transaction_date, company=self.company, customer_group=frappe.db.get_value("Customer", self.customer, "customer_group"), tax_category=document.tax_category, billing_address=document.customer_address, shipping_address=document.shipping_address_name) document.set_taxes() self.add_due_date(document) # Discounts if self.additional_discount_percentage: document.additional_discount_percentage = self.additional_discount_percentage if self.additional_discount_amount: document.discount_amount = self.additional_discount_amount if self.additional_discount_percentage or self.additional_discount_amount: discount_on = self.apply_additional_discount document.apply_discount_on = discount_on if discount_on else 'Grand Total' self.add_subscription_dates(document) # Terms and conditions if self.terms_and_conditions: from erpnext.setup.doctype.terms_and_conditions.terms_and_conditions import get_terms_and_conditions document.tc_name = self.terms_and_conditions document.terms = get_terms_and_conditions( self.terms_and_conditions, document.__dict__) return document