feat: init CES default values
This commit is contained in:
parent
e093863c9e
commit
d8b8032de1
@ -7,8 +7,8 @@ from frappe.model.document import Document
|
||||
|
||||
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 @@ class CurrencyExchangeSettings(Document):
|
||||
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 @@ class CurrencyExchangeSettings(Document):
|
||||
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:
|
||||
|
@ -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",
|
||||
|
@ -57,7 +57,13 @@ def set_single_defaults():
|
||||
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")
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user