Merge pull request #36889 from GursheenK/discount-accounting-multi-currency-gle
fix: fetch currency in discount accounting SI
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index f131be2..4e1c23d 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -535,12 +535,16 @@
},
source_exchange_rate: function(frm) {
+ let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
if (frm.doc.paid_amount) {
frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate));
// target exchange rate should always be same as source if both account currencies is same
if(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate);
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
+ } else if (company_currency == frm.doc.paid_to_account_currency) {
+ frm.set_value("received_amount", frm.doc.base_paid_amount);
+ frm.set_value("base_received_amount", frm.doc.base_paid_amount);
}
frm.events.set_unallocated_amount(frm);
@@ -552,6 +556,7 @@
target_exchange_rate: function(frm) {
frm.set_paid_amount_based_on_received_amount = true;
+ let company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
if (frm.doc.received_amount) {
frm.set_value("base_received_amount",
@@ -561,6 +566,9 @@
(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency)) {
frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate);
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
+ } else if (company_currency == frm.doc.paid_from_account_currency) {
+ frm.set_value("paid_amount", frm.doc.base_received_amount);
+ frm.set_value("base_paid_amount", frm.doc.base_received_amount);
}
frm.events.set_unallocated_amount(frm);
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 9ed3d32..98a3c36 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -2300,7 +2300,7 @@
if bank_amount:
received_amount = bank_amount
else:
- if company_currency != bank.account_currency:
+ if bank and company_currency != bank.account_currency:
received_amount = paid_amount / doc.get("conversion_rate", 1)
else:
received_amount = paid_amount * doc.get("conversion_rate", 1)
@@ -2309,7 +2309,7 @@
if bank_amount:
paid_amount = bank_amount
else:
- if company_currency != bank.account_currency:
+ if bank and company_currency != bank.account_currency:
paid_amount = received_amount / doc.get("conversion_rate", 1)
else:
# if party account currency and bank currency is different then populate paid amount as well
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index 8b929bf..5d3d4d7 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -287,7 +287,7 @@
conditions = ""
for opts in (
- ("company", " and company=%(company)s"),
+ ("company", " and `tabPurchase Invoice`.company=%(company)s"),
("supplier", " and `tabPurchase Invoice`.supplier = %(supplier)s"),
("item_code", " and `tabPurchase Invoice Item`.item_code = %(item_code)s"),
("from_date", " and `tabPurchase Invoice`.posting_date>=%(from_date)s"),
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index 1e7ac33..ce22d75 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -332,7 +332,7 @@
conditions = ""
for opts in (
- ("company", " and company=%(company)s"),
+ ("company", " and `tabSales Invoice`.company=%(company)s"),
("customer", " and `tabSales Invoice`.customer = %(customer)s"),
("item_code", " and `tabSales Invoice Item`.item_code = %(item_code)s"),
("from_date", " and `tabSales Invoice`.posting_date>=%(from_date)s"),
diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py
index ca8b9f0..162e5b5 100644
--- a/erpnext/accounts/report/purchase_register/purchase_register.py
+++ b/erpnext/accounts/report/purchase_register/purchase_register.py
@@ -393,6 +393,7 @@
pi.remarks,
pi.base_net_total,
pi.base_grand_total,
+ pi.base_rounded_total,
pi.outstanding_amount,
pi.mode_of_payment,
)
diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index d3fc373..0ba7186 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -38,7 +38,7 @@
if filters.get("include_payments"):
invoice_list += get_payments(filters)
- columns, income_accounts, tax_accounts, unrealized_profit_loss_accounts = get_columns(
+ columns, income_accounts, unrealized_profit_loss_accounts, tax_accounts = get_columns(
invoice_list, additional_table_columns, include_payments
)