fix: get latest exchange rate
This commit is contained in:
parent
d53b503805
commit
5bfcaf4809
@ -177,7 +177,7 @@ class CRMDeal(Document):
|
||||
system_currency = frappe.db.get_single_value("FCRM Settings", "currency") or "USD"
|
||||
exchange_rate = 1
|
||||
if self.currency and self.currency != system_currency:
|
||||
exchange_rate = get_exchange_rate(self.currency, system_currency, frappe.utils.nowdate())
|
||||
exchange_rate = get_exchange_rate(self.currency, system_currency)
|
||||
|
||||
self.db_set("exchange_rate", exchange_rate)
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ class CRMOrganization(Document):
|
||||
system_currency = frappe.db.get_single_value("FCRM Settings", "currency") or "USD"
|
||||
exchange_rate = 1
|
||||
if self.currency and self.currency != system_currency:
|
||||
exchange_rate = get_exchange_rate(self.currency, system_currency, frappe.utils.nowdate())
|
||||
exchange_rate = get_exchange_rate(self.currency, system_currency)
|
||||
|
||||
self.db_set("exchange_rate", exchange_rate)
|
||||
|
||||
|
||||
@ -284,7 +284,7 @@ def get_exchange_rate(from_currency, to_currency, date=None):
|
||||
return rate
|
||||
|
||||
frappe.log_error(
|
||||
f"Failed to fetch exchange rate from {from_currency} to {to_currency} on {date}",
|
||||
title="Exchange Rate Fetch Error",
|
||||
message=f"Failed to fetch exchange rate from {from_currency} to {to_currency} on {date}",
|
||||
)
|
||||
return 1.0 # Default exchange rate if API call fails or no rate found
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user