From 3e292ef2cbed31afed297e005e04f021944542fd Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 28 Feb 2025 17:26:19 +0530 Subject: [PATCH] refactor: set transaction currency dr/cr in sales invoice --- .../doctype/sales_invoice/sales_invoice.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index e326a165d31..b7e6ead7653 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1271,6 +1271,7 @@ class SalesInvoice(SellingController): "debit_in_account_currency": base_grand_total if self.party_account_currency == self.company_currency else grand_total, + "debit_in_transaction_currency": grand_total, "against_voucher": against_voucher, "against_voucher_type": self.doctype, "cost_center": self.cost_center, @@ -1302,6 +1303,9 @@ class SalesInvoice(SellingController): if account_currency == self.company_currency else flt(amount, tax.precision("tax_amount_after_discount_amount")) ), + "credit_in_transaction_currency": flt( + amount, tax.precision("tax_amount_after_discount_amount") + ), "cost_center": tax.cost_center, }, account_currency, @@ -1319,6 +1323,7 @@ class SalesInvoice(SellingController): "against": self.customer, "debit": flt(self.total_taxes_and_charges), "debit_in_account_currency": flt(self.base_total_taxes_and_charges), + "debit_in_transaction_currency": flt(self.total_taxes_and_charges), "cost_center": self.cost_center, }, account_currency, @@ -1417,6 +1422,7 @@ class SalesInvoice(SellingController): if account_currency == self.company_currency else flt(amount, item.precision("net_amount")) ), + "credit_in_transaction_currency": flt(amount, item.precision("net_amount")), "cost_center": item.cost_center, "project": item.project or self.project, }, @@ -1468,6 +1474,7 @@ class SalesInvoice(SellingController): + cstr(self.loyalty_redemption_account) + " for the Loyalty Program", "credit": self.loyalty_amount, + "credit_in_transaction_currency": self.loyalty_amount, "against_voucher": self.return_against if cint(self.is_return) else self.name, "against_voucher_type": self.doctype, "cost_center": self.cost_center, @@ -1482,6 +1489,7 @@ class SalesInvoice(SellingController): "cost_center": self.cost_center or self.loyalty_redemption_cost_center, "against": self.customer, "debit": self.loyalty_amount, + "debit_in_transaction_currency": self.loyalty_amount, "remark": "Loyalty Points redeemed by the customer", }, item=self, @@ -1515,6 +1523,7 @@ class SalesInvoice(SellingController): "credit_in_account_currency": payment_mode.base_amount if self.party_account_currency == self.company_currency else payment_mode.amount, + "credit_in_transaction_currency": payment_mode.amount, "against_voucher": against_voucher, "against_voucher_type": self.doctype, "cost_center": self.cost_center, @@ -1534,6 +1543,7 @@ class SalesInvoice(SellingController): "debit_in_account_currency": payment_mode.base_amount if payment_mode_account_currency == self.company_currency else payment_mode.amount, + "debit_in_transaction_currency": payment_mode.amount, "cost_center": self.cost_center, }, payment_mode_account_currency, @@ -1562,6 +1572,7 @@ class SalesInvoice(SellingController): "debit_in_account_currency": flt(self.base_change_amount) if self.party_account_currency == self.company_currency else flt(self.change_amount), + "debit_in_transaction_currency": flt(self.change_amount), "against_voucher": self.return_against if cint(self.is_return) and self.return_against else self.name, @@ -1577,6 +1588,7 @@ class SalesInvoice(SellingController): "account": self.account_for_change_amount, "against": self.customer, "credit": self.base_change_amount, + "credit_in_transaction_currency": self.change_amount, "cost_center": self.cost_center, }, item=self, @@ -1606,6 +1618,9 @@ class SalesInvoice(SellingController): if self.party_account_currency == self.company_currency else flt(self.write_off_amount, self.precision("write_off_amount")) ), + "credit_in_transaction_currency": flt( + self.write_off_amount, self.precision("write_off_amount") + ), "against_voucher": self.return_against if cint(self.is_return) else self.name, "against_voucher_type": self.doctype, "cost_center": self.cost_center, @@ -1626,6 +1641,9 @@ class SalesInvoice(SellingController): if write_off_account_currency == self.company_currency else flt(self.write_off_amount, self.precision("write_off_amount")) ), + "debit_in_transaction_currency": flt( + self.write_off_amount, self.precision("write_off_amount") + ), "cost_center": self.cost_center or self.write_off_cost_center or default_cost_center, }, write_off_account_currency, @@ -1670,6 +1688,9 @@ class SalesInvoice(SellingController): "credit_in_account_currency": flt( self.rounding_adjustment, self.precision("rounding_adjustment") ), + "credit_in_transaction_currency": flt( + self.rounding_adjustment, self.precision("rounding_adjustment") + ), "credit": flt( self.base_rounding_adjustment, self.precision("base_rounding_adjustment") ),