fix: validating party currency with doc currency (#24318)

* fix: validating supplier currency

* fix: compare current currency with company currency as well.

* fix: replaced or with add in condition

* fix: conditioning to get proper payment terms values

Co-authored-by: Saqib <nextchamp.saqib@gmail.com>
This commit is contained in:
Afshan
2021-03-23 20:53:56 +05:30
committed by GitHub
parent f114da2f67
commit 02142c41bb

View File

@@ -829,10 +829,10 @@ class AccountsController(TransactionBase):
party_account_currency = get_party_account_currency(party_type, party, self.company) party_account_currency = get_party_account_currency(party_type, party, self.company)
if (party_account_currency if (party_account_currency
and party_account_currency != self.company_currency and (self.currency != party_account_currency
and self.currency != party_account_currency): and self.currency != self.company_currency)):
frappe.throw(_("Accounting Entry for {0}: {1} can only be made in currency: {2}") frappe.throw(_("Accounting Entry for {0}: {1} can only be made in currency: {2}")
.format(party_type, party, party_account_currency), InvalidCurrency) .format(party_type, party, frappe.bold(party_account_currency), InvalidCurrency))
# Note: not validating with gle account because we don't have the account # Note: not validating with gle account because we don't have the account
# at quotation / sales order level and we shouldn't stop someone # at quotation / sales order level and we shouldn't stop someone
@@ -898,7 +898,7 @@ class AccountsController(TransactionBase):
date = self.get("due_date") date = self.get("due_date")
due_date = date or posting_date due_date = date or posting_date
if party_account_currency == self.company_currency: if self.company_currency == self.currency:
grand_total = self.get("base_rounded_total") or self.base_grand_total grand_total = self.get("base_rounded_total") or self.base_grand_total
else: else:
grand_total = self.get("rounded_total") or self.grand_total grand_total = self.get("rounded_total") or self.grand_total
@@ -959,7 +959,7 @@ class AccountsController(TransactionBase):
for d in self.get("payment_schedule"): for d in self.get("payment_schedule"):
total += flt(d.payment_amount) total += flt(d.payment_amount)
if party_account_currency == self.company_currency: if self.company_currency == self.currency:
total = flt(total, self.precision("base_grand_total")) total = flt(total, self.precision("base_grand_total"))
grand_total = flt(self.get("base_rounded_total") or self.base_grand_total, self.precision('base_grand_total')) grand_total = flt(self.get("base_rounded_total") or self.base_grand_total, self.precision('base_grand_total'))
else: else: