mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
refactor: set transaction currency dr/cr in sales invoice
(cherry picked from commit 3e292ef2cb)
# Conflicts:
# erpnext/accounts/doctype/sales_invoice/sales_invoice.py
This commit is contained in:
@@ -1274,6 +1274,7 @@ class SalesInvoice(SellingController):
|
|||||||
"debit_in_account_currency": base_grand_total
|
"debit_in_account_currency": base_grand_total
|
||||||
if self.party_account_currency == self.company_currency
|
if self.party_account_currency == self.company_currency
|
||||||
else grand_total,
|
else grand_total,
|
||||||
|
"debit_in_transaction_currency": grand_total,
|
||||||
"against_voucher": against_voucher,
|
"against_voucher": against_voucher,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
@@ -1305,6 +1306,9 @@ class SalesInvoice(SellingController):
|
|||||||
if account_currency == self.company_currency
|
if account_currency == self.company_currency
|
||||||
else flt(amount, tax.precision("tax_amount_after_discount_amount"))
|
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,
|
"cost_center": tax.cost_center,
|
||||||
},
|
},
|
||||||
account_currency,
|
account_currency,
|
||||||
@@ -1322,6 +1326,7 @@ class SalesInvoice(SellingController):
|
|||||||
"against": self.customer,
|
"against": self.customer,
|
||||||
"debit": flt(self.total_taxes_and_charges),
|
"debit": flt(self.total_taxes_and_charges),
|
||||||
"debit_in_account_currency": flt(self.base_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,
|
"cost_center": self.cost_center,
|
||||||
},
|
},
|
||||||
account_currency,
|
account_currency,
|
||||||
@@ -1420,6 +1425,7 @@ class SalesInvoice(SellingController):
|
|||||||
if account_currency == self.company_currency
|
if account_currency == self.company_currency
|
||||||
else flt(amount, item.precision("net_amount"))
|
else flt(amount, item.precision("net_amount"))
|
||||||
),
|
),
|
||||||
|
"credit_in_transaction_currency": flt(amount, item.precision("net_amount")),
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"project": item.project or self.project,
|
"project": item.project or self.project,
|
||||||
},
|
},
|
||||||
@@ -1471,6 +1477,7 @@ class SalesInvoice(SellingController):
|
|||||||
+ cstr(self.loyalty_redemption_account)
|
+ cstr(self.loyalty_redemption_account)
|
||||||
+ " for the Loyalty Program",
|
+ " for the Loyalty Program",
|
||||||
"credit": self.loyalty_amount,
|
"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": self.return_against if cint(self.is_return) else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
@@ -1485,6 +1492,7 @@ class SalesInvoice(SellingController):
|
|||||||
"cost_center": self.cost_center or self.loyalty_redemption_cost_center,
|
"cost_center": self.cost_center or self.loyalty_redemption_cost_center,
|
||||||
"against": self.customer,
|
"against": self.customer,
|
||||||
"debit": self.loyalty_amount,
|
"debit": self.loyalty_amount,
|
||||||
|
"debit_in_transaction_currency": self.loyalty_amount,
|
||||||
"remark": "Loyalty Points redeemed by the customer",
|
"remark": "Loyalty Points redeemed by the customer",
|
||||||
},
|
},
|
||||||
item=self,
|
item=self,
|
||||||
@@ -1518,6 +1526,7 @@ class SalesInvoice(SellingController):
|
|||||||
"credit_in_account_currency": payment_mode.base_amount
|
"credit_in_account_currency": payment_mode.base_amount
|
||||||
if self.party_account_currency == self.company_currency
|
if self.party_account_currency == self.company_currency
|
||||||
else payment_mode.amount,
|
else payment_mode.amount,
|
||||||
|
"credit_in_transaction_currency": payment_mode.amount,
|
||||||
"against_voucher": against_voucher,
|
"against_voucher": against_voucher,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
@@ -1537,6 +1546,7 @@ class SalesInvoice(SellingController):
|
|||||||
"debit_in_account_currency": payment_mode.base_amount
|
"debit_in_account_currency": payment_mode.base_amount
|
||||||
if payment_mode_account_currency == self.company_currency
|
if payment_mode_account_currency == self.company_currency
|
||||||
else payment_mode.amount,
|
else payment_mode.amount,
|
||||||
|
"debit_in_transaction_currency": payment_mode.amount,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
},
|
},
|
||||||
payment_mode_account_currency,
|
payment_mode_account_currency,
|
||||||
@@ -1573,6 +1583,7 @@ class SalesInvoice(SellingController):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict(
|
self.get_gl_dict(
|
||||||
{
|
{
|
||||||
@@ -1586,6 +1597,44 @@ class SalesInvoice(SellingController):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
frappe.throw(_("Select change amount account"), title=_("Mandatory Field"))
|
frappe.throw(_("Select change amount account"), title=_("Mandatory Field"))
|
||||||
|
=======
|
||||||
|
if not self.account_for_change_amount:
|
||||||
|
frappe.throw(_("Please set Account for Change Amount"), title=_("Mandatory Field"))
|
||||||
|
|
||||||
|
return [
|
||||||
|
self.get_gl_dict(
|
||||||
|
{
|
||||||
|
"account": self.debit_to,
|
||||||
|
"party_type": "Customer",
|
||||||
|
"party": self.customer,
|
||||||
|
"against": self.account_for_change_amount,
|
||||||
|
"debit": flt(self.base_change_amount),
|
||||||
|
"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,
|
||||||
|
"against_voucher_type": self.doctype,
|
||||||
|
"cost_center": self.cost_center,
|
||||||
|
"project": self.project,
|
||||||
|
},
|
||||||
|
self.party_account_currency,
|
||||||
|
item=self,
|
||||||
|
),
|
||||||
|
self.get_gl_dict(
|
||||||
|
{
|
||||||
|
"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,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
>>>>>>> 3e292ef2cb (refactor: set transaction currency dr/cr in sales invoice)
|
||||||
|
|
||||||
def make_write_off_gl_entry(self, gl_entries):
|
def make_write_off_gl_entry(self, gl_entries):
|
||||||
# write off entries, applicable if only pos
|
# write off entries, applicable if only pos
|
||||||
@@ -1610,6 +1659,9 @@ class SalesInvoice(SellingController):
|
|||||||
if self.party_account_currency == self.company_currency
|
if self.party_account_currency == self.company_currency
|
||||||
else flt(self.write_off_amount, self.precision("write_off_amount"))
|
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": self.return_against if cint(self.is_return) else self.name,
|
||||||
"against_voucher_type": self.doctype,
|
"against_voucher_type": self.doctype,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
@@ -1630,6 +1682,9 @@ class SalesInvoice(SellingController):
|
|||||||
if write_off_account_currency == self.company_currency
|
if write_off_account_currency == self.company_currency
|
||||||
else flt(self.write_off_amount, self.precision("write_off_amount"))
|
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,
|
"cost_center": self.cost_center or self.write_off_cost_center or default_cost_center,
|
||||||
},
|
},
|
||||||
write_off_account_currency,
|
write_off_account_currency,
|
||||||
@@ -1674,6 +1729,9 @@ class SalesInvoice(SellingController):
|
|||||||
"credit_in_account_currency": flt(
|
"credit_in_account_currency": flt(
|
||||||
self.rounding_adjustment, self.precision("rounding_adjustment")
|
self.rounding_adjustment, self.precision("rounding_adjustment")
|
||||||
),
|
),
|
||||||
|
"credit_in_transaction_currency": flt(
|
||||||
|
self.rounding_adjustment, self.precision("rounding_adjustment")
|
||||||
|
),
|
||||||
"credit": flt(
|
"credit": flt(
|
||||||
self.base_rounding_adjustment, self.precision("base_rounding_adjustment")
|
self.base_rounding_adjustment, self.precision("base_rounding_adjustment")
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user