mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
minor fixes in multi-currency
This commit is contained in:
@@ -199,26 +199,26 @@ class JournalEntry(AccountsController):
|
|||||||
party_type, party = self.reference_parties.get(reference_name)
|
party_type, party = self.reference_parties.get(reference_name)
|
||||||
|
|
||||||
if reference_type in ("Sales Order", "Purchase Order"):
|
if reference_type in ("Sales Order", "Purchase Order"):
|
||||||
voucher_properties = frappe.db.get_value(reference_type, reference_name,
|
order = frappe.db.get_value(reference_type, reference_name,
|
||||||
["docstatus", "per_billed", "status", "advance_paid",
|
["docstatus", "per_billed", "status", "advance_paid",
|
||||||
"base_grand_total", "grand_total", "currency"], as_dict=1)
|
"base_grand_total", "grand_total", "currency"], as_dict=1)
|
||||||
|
|
||||||
if voucher_properties.docstatus != 1:
|
if order.docstatus != 1:
|
||||||
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
|
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
|
||||||
|
|
||||||
if flt(voucher_properties.per_billed) >= 100:
|
if flt(order.per_billed) >= 100:
|
||||||
frappe.throw(_("{0} {1} is fully billed").format(reference_type, reference_name))
|
frappe.throw(_("{0} {1} is fully billed").format(reference_type, reference_name))
|
||||||
|
|
||||||
if cstr(voucher_properties.status) == "Stopped":
|
if cstr(order.status) == "Stopped":
|
||||||
frappe.throw(_("{0} {1} is stopped").format(reference_type, reference_name))
|
frappe.throw(_("{0} {1} is stopped").format(reference_type, reference_name))
|
||||||
|
|
||||||
party_account_currency = frappe.db.get_value(party_type, party, "party_account_currency")
|
party_account_currency = frappe.db.get_value(party_type, party, "party_account_currency")
|
||||||
if party_account_currency == self.company_currency:
|
if party_account_currency == self.company_currency:
|
||||||
voucher_total = voucher_properties.base_grand_total
|
voucher_total = order.base_grand_total
|
||||||
else:
|
else:
|
||||||
voucher_total = voucher_properties.grand_total
|
voucher_total = order.grand_total
|
||||||
|
|
||||||
if flt(voucher_total) < (flt(voucher_properties.advance_paid) + total):
|
if flt(voucher_total) < (flt(order.advance_paid) + total):
|
||||||
frappe.throw(_("Advance paid against {0} {1} cannot be greater \
|
frappe.throw(_("Advance paid against {0} {1} cannot be greater \
|
||||||
than Grand Total {2}").format(reference_type, reference_name, voucher_total))
|
than Grand Total {2}").format(reference_type, reference_name, voucher_total))
|
||||||
|
|
||||||
@@ -228,15 +228,15 @@ class JournalEntry(AccountsController):
|
|||||||
reference_type = self.reference_types[reference_name]
|
reference_type = self.reference_types[reference_name]
|
||||||
|
|
||||||
if reference_type in ("Sales Invoice", "Purchase Invoice"):
|
if reference_type in ("Sales Invoice", "Purchase Invoice"):
|
||||||
voucher_properties = frappe.db.get_value(reference_type, reference_name,
|
invoice = frappe.db.get_value(reference_type, reference_name,
|
||||||
["docstatus", "outstanding_amount"], as_dict=1)
|
["docstatus", "outstanding_amount"], as_dict=1)
|
||||||
|
|
||||||
if voucher_properties.docstatus != 1:
|
if invoice.docstatus != 1:
|
||||||
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
|
frappe.throw(_("{0} {1} is not submitted").format(reference_type, reference_name))
|
||||||
|
|
||||||
if total and flt(voucher_properties.outstanding_amount) < total:
|
if total and flt(invoice.outstanding_amount) < total:
|
||||||
frappe.throw(_("Payment against {0} {1} cannot be greater than Outstanding Amount {2}")
|
frappe.throw(_("Payment against {0} {1} cannot be greater than Outstanding Amount {2}")
|
||||||
.format(reference_type, reference_name, voucher_properties.outstanding_amount))
|
.format(reference_type, reference_name, invoice.outstanding_amount))
|
||||||
|
|
||||||
def set_against_account(self):
|
def set_against_account(self):
|
||||||
accounts_debited, accounts_credited = [], []
|
accounts_debited, accounts_credited = [], []
|
||||||
@@ -836,4 +836,3 @@ def get_average_exchange_rate(account):
|
|||||||
exchange_rate = bank_balance_in_company_currency / bank_balance_in_account_currency
|
exchange_rate = bank_balance_in_company_currency / bank_balance_in_account_currency
|
||||||
|
|
||||||
return exchange_rate
|
return exchange_rate
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from frappe.utils import getdate, nowdate, flt, cint, cstr
|
from frappe.utils import getdate, nowdate, flt, cint
|
||||||
|
|
||||||
class ReceivablePayableReport(object):
|
class ReceivablePayableReport(object):
|
||||||
def __init__(self, filters=None):
|
def __init__(self, filters=None):
|
||||||
@@ -40,10 +40,10 @@ class ReceivablePayableReport(object):
|
|||||||
|
|
||||||
columns += [_("Age (Days)") + "::80"]
|
columns += [_("Age (Days)") + "::80"]
|
||||||
|
|
||||||
for label in ("0-" + cstr(self.filters.range1),
|
for label in ("0-{range1}".format(**self.filters),
|
||||||
cstr(self.filters.range1) + "-" + cstr(self.filters.range2),
|
"{range1}-{range2}".format(**self.filters),
|
||||||
cstr(self.filters.range2) + "-" +cstr(self.filters.range3),
|
"{range2}-{range3}".format(**self.filters),
|
||||||
cstr(self.filters.range3) + _("-Above")):
|
"{range3}-{above}".format(range3=self.filters.range3, above=_("Above"))):
|
||||||
columns.append({
|
columns.append({
|
||||||
"label": label,
|
"label": label,
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
@@ -55,12 +55,15 @@ class ReceivablePayableReport(object):
|
|||||||
columns += [_("Territory") + ":Link/Territory:80"]
|
columns += [_("Territory") + ":Link/Territory:80"]
|
||||||
if args.get("party_type") == "Supplier":
|
if args.get("party_type") == "Supplier":
|
||||||
columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
|
columns += [_("Supplier Type") + ":Link/Supplier Type:80"]
|
||||||
columns += [{
|
columns += [
|
||||||
"fieldname": "currency",
|
{
|
||||||
"label": _("Currency"),
|
"fieldname": "currency",
|
||||||
"fieldtype": "Data",
|
"label": _("Currency"),
|
||||||
"width": 100,
|
"fieldtype": "Data",
|
||||||
}, _("Remarks") + "::200"]
|
"width": 100,
|
||||||
|
},
|
||||||
|
_("Remarks") + "::200"
|
||||||
|
]
|
||||||
|
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
@@ -192,12 +195,12 @@ class ReceivablePayableReport(object):
|
|||||||
conditions, values = self.prepare_conditions(party_type)
|
conditions, values = self.prepare_conditions(party_type)
|
||||||
|
|
||||||
if self.filters.get(scrub(party_type)):
|
if self.filters.get(scrub(party_type)):
|
||||||
select_fields = ", debit_in_account_currency as debit, credit_in_account_currency as credit"
|
select_fields = "debit_in_account_currency as debit, credit_in_account_currency as credit"
|
||||||
else:
|
else:
|
||||||
select_fields = ", debit, credit"
|
select_fields = "debit, credit"
|
||||||
|
|
||||||
self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
|
self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
|
||||||
voucher_type, voucher_no, against_voucher_type, against_voucher, account_currency, remarks {0}
|
voucher_type, voucher_no, against_voucher_type, against_voucher, account_currency, remarks, {0}
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
where docstatus < 2 and party_type=%s {1} order by posting_date, party"""
|
where docstatus < 2 and party_type=%s {1} order by posting_date, party"""
|
||||||
.format(select_fields, conditions), values, as_dict=True)
|
.format(select_fields, conditions), values, as_dict=True)
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
if account_currency not in valid_currency:
|
if account_currency not in valid_currency:
|
||||||
frappe.throw(_("Account {0} is invalid. Account Currency must be {1}")
|
frappe.throw(_("Account {0} is invalid. Account Currency must be {1}")
|
||||||
.format(account, " or ".join(valid_currency)))
|
.format(account, _(" or ").join(valid_currency)))
|
||||||
|
|
||||||
def set_balance_in_account_currency(self, gl_dict, account_currency=None):
|
def set_balance_in_account_currency(self, gl_dict, account_currency=None):
|
||||||
if (not self.get("conversion_rate") and self.doctype!="Journal Entry"
|
if (not self.get("conversion_rate") and self.doctype!="Journal Entry"
|
||||||
|
|||||||
Reference in New Issue
Block a user