feat: init CES default values
diff --git a/erpnext/setup/doctype/currency_exchange_settings/currency_exchange_settings.py b/erpnext/setup/doctype/currency_exchange_settings/currency_exchange_settings.py
index 1993c9b..92828e6 100644
--- a/erpnext/setup/doctype/currency_exchange_settings/currency_exchange_settings.py
+++ b/erpnext/setup/doctype/currency_exchange_settings/currency_exchange_settings.py
@@ -7,8 +7,8 @@
class CurrencyExchangeSettings(Document):
def validate(self):
- if len(self.req_params) != 3:
- frappe.throw(_("Make sure all the three mandatory parameters are filled."))
+ if len(self.req_params) > 3:
+ frappe.throw(_("Make sure no mandatory parameters are repeated."))
transaction_date = '2021-08-01'
from_currency = 'USD'
to_currency = 'INR'
@@ -23,7 +23,7 @@
params[row.key] = req_params[row.value]
req_params.pop(row.value)
except:
- frappe.throw(_("Make sure all the three mandatory parameters are filled."))
+ frappe.throw(_("Make sure no mandatory parameters are repeated."))
for eparam in self.extra_params:
params[eparam.key] = eparam.value
import requests
@@ -42,7 +42,7 @@
for key in self.result_key:
value = value[str(key.key).format(
transaction_date=transaction_date,
- to_currency=to_currency,
+ to_currency=to_currency,
from_currency=from_currency
)]
except KeyError:
diff --git a/erpnext/setup/doctype/currency_exchange_settings_result/currency_exchange_settings_result.json b/erpnext/setup/doctype/currency_exchange_settings_result/currency_exchange_settings_result.json
index 4203b80..1b2c623 100644
--- a/erpnext/setup/doctype/currency_exchange_settings_result/currency_exchange_settings_result.json
+++ b/erpnext/setup/doctype/currency_exchange_settings_result/currency_exchange_settings_result.json
@@ -13,13 +13,14 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Key",
- "reqd": 1
+ "reqd": 1,
+ "unique": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2021-09-03 13:17:22.088259",
+ "modified": "2021-09-03 15:41:09.997576",
"modified_by": "Administrator",
"module": "Setup",
"name": "Currency Exchange Settings Result",
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index bbee74c..239733a4 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -57,7 +57,13 @@
pass
except frappe.ValidationError:
pass
-
+ ces = frappe.get_single('Currency Exchange Settings')
+ ces.api_endpoint = "https://api.exchangerate.host/convert"
+ ces.append('result_key', {'key': 'result'})
+ ces.append('req_params', {'key': 'date', 'value': 'transaction_date'})
+ ces.append('req_params', {'key': 'from', 'value': 'from_currency'})
+ ces.append('req_params', {'key': 'to', 'value': 'to_currency'})
+ ces.save()
frappe.db.set_default("date_format", "dd-mm-yyyy")