Skip to content

Commit

Permalink
fix: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarvora committed Oct 2, 2024
1 parent 848bf19 commit 50b83c0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
36 changes: 0 additions & 36 deletions erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,6 @@ def save_new_records(test_records):
curr_exchange.insert()


<<<<<<< HEAD
=======
test_exchange_values = {"2015-12-15": "66.999", "2016-01-15": "65.1"}


# Removing API call from get_exchange_rate
def patched_requests_get(*args, **kwargs):
class PatchResponse:
def __init__(self, json_data, status_code):
self.json_data = json_data
self.status_code = status_code

def raise_for_status(self):
if self.status_code != 200:
raise frappe.DoesNotExistError

def json(self):
return self.json_data

if args[0] == "https://api.exchangerate.host/convert" and kwargs.get("params"):
if kwargs["params"].get("date") and kwargs["params"].get("from") and kwargs["params"].get("to"):
if test_exchange_values.get(kwargs["params"]["date"]):
return PatchResponse({"result": test_exchange_values[kwargs["params"]["date"]]}, 200)
elif args[0].startswith("https://api.frankfurter.app") and kwargs.get("params"):
if kwargs["params"].get("base") and kwargs["params"].get("symbols"):
date = args[0].replace("https://api.frankfurter.app/", "")
if test_exchange_values.get(date):
return PatchResponse(
{"rates": {kwargs["params"].get("symbols"): test_exchange_values.get(date)}}, 200
)

return PatchResponse({"rates": None}, 404)


@mock.patch("requests.get", side_effect=patched_requests_get)
>>>>>>> c444de017a (test: update test for API change)
class TestCurrencyExchange(unittest.TestCase):
def clear_cache(self):
cache = frappe.cache()
Expand Down
21 changes: 0 additions & 21 deletions erpnext/setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,9 @@ def set_single_defaults():
frappe.db.set_default("date_format", "dd-mm-yyyy")


<<<<<<< HEAD
def create_compact_item_print_custom_field():
create_custom_field(
"Print Settings",
=======
def setup_currency_exchange():
ces = frappe.get_single("Currency Exchange Settings")
try:
ces.set("result_key", [])
ces.set("req_params", [])

ces.api_endpoint = "https://api.frankfurter.app/{transaction_date}"
ces.append("result_key", {"key": "rates"})
ces.append("result_key", {"key": "{to_currency}"})
ces.append("req_params", {"key": "base", "value": "{from_currency}"})
ces.append("req_params", {"key": "symbols", "value": "{to_currency}"})
ces.save()
except frappe.ValidationError:
pass


def create_print_setting_custom_fields():
create_custom_fields(
>>>>>>> 33e72111c7 (fix: Fix API endpoint for Frankfurter)
{
"label": _("Compact Item Print"),
"fieldname": "compact_item_print",
Expand Down

0 comments on commit 50b83c0

Please sign in to comment.