Add buying or selling to filters in get_exchange_rate

This commit is contained in:
Shreya
2018-05-15 16:58:45 +05:30
parent 0db85067b2
commit b547cdd8fa

View File

@@ -59,13 +59,11 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
if not (from_currency and to_currency): if not (from_currency and to_currency):
# manqala 19/09/2016: Should this be an empty return or should it throw and exception? # manqala 19/09/2016: Should this be an empty return or should it throw and exception?
return return
if from_currency == to_currency: if from_currency == to_currency:
return 1 return 1
if not transaction_date: if not transaction_date:
transaction_date = nowdate() transaction_date = nowdate()
currency_settings = frappe.get_doc("Accounts Settings").as_dict() currency_settings = frappe.get_doc("Accounts Settings").as_dict()
allow_stale_rates = currency_settings.get("allow_stale") allow_stale_rates = currency_settings.get("allow_stale")
@@ -74,12 +72,12 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
["from_currency", "=", from_currency], ["from_currency", "=", from_currency],
["to_currency", "=", to_currency] ["to_currency", "=", to_currency]
] ]
frappe.errprint(args)
if args == "for_buying": if args == "for_buying":
filters.append(["for_buying", "=", "1"]) filters.append(["for_buying", "=", "1"])
elif args == "for_selling": elif args == "for_selling":
filters.append(["for_selling", "=", 1]) filters.append(["for_selling", "=", "1"])
frappe.errprint(filters)
if not allow_stale_rates: if not allow_stale_rates:
stale_days = currency_settings.get("stale_days") stale_days = currency_settings.get("stale_days")
checkpoint_date = add_days(transaction_date, -stale_days) checkpoint_date = add_days(transaction_date, -stale_days)