fix: set exchange rate
This commit is contained in:
parent
f904ac599e
commit
d8163f3e47
@ -232,4 +232,4 @@ frappe.ui.form.on("Lead", {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
@ -47,6 +47,7 @@ class Opportunity(TransactionBase, CRMNote):
|
|||||||
self.validate_uom_is_integer("uom", "qty")
|
self.validate_uom_is_integer("uom", "qty")
|
||||||
self.validate_cust_name()
|
self.validate_cust_name()
|
||||||
self.map_fields()
|
self.map_fields()
|
||||||
|
self.set_exchange_rate()
|
||||||
|
|
||||||
if not self.title:
|
if not self.title:
|
||||||
self.title = self.customer_name
|
self.title = self.customer_name
|
||||||
@ -63,12 +64,21 @@ class Opportunity(TransactionBase, CRMNote):
|
|||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
def set_exchange_rate(self):
|
||||||
|
company_currency = frappe.get_cached_value("Company", self.company, "default_currency")
|
||||||
|
if self.currency == company_currency:
|
||||||
|
self.conversion_rate = 1.0
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.conversion_rate or self.conversion_rate == 1.0:
|
||||||
|
self.conversion_rate = get_exchange_rate(self.currency, company_currency, self.transaction_date)
|
||||||
|
|
||||||
def calculate_totals(self):
|
def calculate_totals(self):
|
||||||
total = base_total = 0
|
total = base_total = 0
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
item.amount = flt(item.rate) * flt(item.qty)
|
item.amount = flt(item.rate) * flt(item.qty)
|
||||||
item.base_rate = flt(self.conversion_rate * item.rate)
|
item.base_rate = flt(self.conversion_rate) * flt(item.rate)
|
||||||
item.base_amount = flt(self.conversion_rate * item.amount)
|
item.base_amount = flt(self.conversion_rate) * flt(item.amount)
|
||||||
total += item.amount
|
total += item.amount
|
||||||
base_total += item.base_amount
|
base_total += item.base_amount
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,14 @@ def execute():
|
|||||||
try:
|
try:
|
||||||
rename_field("Lead", "designation", "job_title")
|
rename_field("Lead", "designation", "job_title")
|
||||||
rename_field("Opportunity", "converted_by", "opportunity_owner")
|
rename_field("Opportunity", "converted_by", "opportunity_owner")
|
||||||
rename_field("Prospect", "prospect_lead", "leads")
|
|
||||||
|
frappe.db.sql(
|
||||||
|
"""
|
||||||
|
update `tabProspect Lead`
|
||||||
|
set parentfield='leads'
|
||||||
|
where parentfield='partner_lead'
|
||||||
|
"""
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e.args[0] != 1054:
|
if e.args[0] != 1054:
|
||||||
raise
|
raise
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user