add new function convert to convert a value to another currency

This commit is contained in:
tundebabzy
2018-01-22 17:41:13 +01:00
parent d93f2ddd4e
commit 9c36baaac4

View File

@@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
from erpnext import get_company_currency, get_default_company
from erpnext.setup.utils import get_exchange_rate
from frappe.utils import getdate, cstr, flt
from frappe import _, _dict
from erpnext.accounts.utils import get_account_currency
@@ -146,6 +147,12 @@ def get_currency(filters):
return currency_map
def convert(value, from_, to, date):
rate = get_exchange_rate(from_, to, date)
converted_value = value / rate
return converted_value
def get_gl_entries(filters):
currency = get_currency(filters)
select_fields = """, sum(debit_in_account_currency) as debit_in_account_currency,