mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
Merge pull request #54452 from frappe/mergify/bp/version-15-hotfix/pr-54307
fix(accounts): fetch project name from payment entry to journal entry (backport #54307)
This commit is contained in:
@@ -1937,6 +1937,37 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, pe.doctype, pe.name)
|
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, pe.doctype, pe.name)
|
||||||
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, "Journal Entry", jv[0])
|
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, "Journal Entry", jv[0])
|
||||||
|
|
||||||
|
def test_project_name_in_exchange_gain_loss_entry(self):
|
||||||
|
si = create_sales_invoice(
|
||||||
|
customer="_Test Customer USD",
|
||||||
|
debit_to="_Test Receivable USD - _TC",
|
||||||
|
currency="USD",
|
||||||
|
conversion_rate=50,
|
||||||
|
do_not_submit=True,
|
||||||
|
)
|
||||||
|
from erpnext.projects.doctype.project.test_project import make_project
|
||||||
|
|
||||||
|
si.project = make_project({"project_name": "_Test Project for Exchange Gain Loss Entry"}).name
|
||||||
|
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
pe = get_payment_entry("Sales Invoice", si.name)
|
||||||
|
|
||||||
|
pe.source_exchange_rate = 100
|
||||||
|
|
||||||
|
pe.insert()
|
||||||
|
pe.submit()
|
||||||
|
|
||||||
|
rows = frappe.get_all(
|
||||||
|
"Journal Entry Account",
|
||||||
|
or_filters=[{"reference_name": pe.name}, {"reference_name": si.name}],
|
||||||
|
fields=["project"],
|
||||||
|
)
|
||||||
|
self.assertEqual(len(rows), 2)
|
||||||
|
|
||||||
|
self.assertEqual(rows[0].project, si.project)
|
||||||
|
self.assertEqual(rows[1].project, si.project)
|
||||||
|
|
||||||
|
|
||||||
def create_payment_entry(**args):
|
def create_payment_entry(**args):
|
||||||
payment_entry = frappe.new_doc("Payment Entry")
|
payment_entry = frappe.new_doc("Payment Entry")
|
||||||
|
|||||||
@@ -2320,6 +2320,7 @@ def create_gain_loss_journal(
|
|||||||
ref2_detail_no,
|
ref2_detail_no,
|
||||||
cost_center,
|
cost_center,
|
||||||
dimensions,
|
dimensions,
|
||||||
|
project=None,
|
||||||
) -> str:
|
) -> str:
|
||||||
journal_entry = frappe.new_doc("Journal Entry")
|
journal_entry = frappe.new_doc("Journal Entry")
|
||||||
journal_entry.voucher_type = "Exchange Gain Or Loss"
|
journal_entry.voucher_type = "Exchange Gain Or Loss"
|
||||||
@@ -2346,6 +2347,7 @@ def create_gain_loss_journal(
|
|||||||
"account_currency": party_account_currency,
|
"account_currency": party_account_currency,
|
||||||
"exchange_rate": 0,
|
"exchange_rate": 0,
|
||||||
"cost_center": cost_center or erpnext.get_default_cost_center(company),
|
"cost_center": cost_center or erpnext.get_default_cost_center(company),
|
||||||
|
"project": project,
|
||||||
"reference_type": ref1_dt,
|
"reference_type": ref1_dt,
|
||||||
"reference_name": ref1_dn,
|
"reference_name": ref1_dn,
|
||||||
"reference_detail_no": ref1_detail_no,
|
"reference_detail_no": ref1_detail_no,
|
||||||
@@ -2363,6 +2365,7 @@ def create_gain_loss_journal(
|
|||||||
"account_currency": gain_loss_account_currency,
|
"account_currency": gain_loss_account_currency,
|
||||||
"exchange_rate": 1,
|
"exchange_rate": 1,
|
||||||
"cost_center": cost_center or erpnext.get_default_cost_center(company),
|
"cost_center": cost_center or erpnext.get_default_cost_center(company),
|
||||||
|
"project": project,
|
||||||
"reference_type": ref2_dt,
|
"reference_type": ref2_dt,
|
||||||
"reference_name": ref2_dn,
|
"reference_name": ref2_dn,
|
||||||
"reference_detail_no": ref2_detail_no,
|
"reference_detail_no": ref2_detail_no,
|
||||||
|
|||||||
@@ -1751,6 +1751,7 @@ class AccountsController(TransactionBase):
|
|||||||
arg.get("referenced_row"),
|
arg.get("referenced_row"),
|
||||||
arg.get("cost_center"),
|
arg.get("cost_center"),
|
||||||
dimensions_dict,
|
dimensions_dict,
|
||||||
|
arg.get("project"),
|
||||||
)
|
)
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
_("Exchange Gain/Loss amount has been booked through {0}").format(
|
_("Exchange Gain/Loss amount has been booked through {0}").format(
|
||||||
@@ -1835,6 +1836,7 @@ class AccountsController(TransactionBase):
|
|||||||
d.idx,
|
d.idx,
|
||||||
self.cost_center,
|
self.cost_center,
|
||||||
dimensions_dict,
|
dimensions_dict,
|
||||||
|
self.project,
|
||||||
)
|
)
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
_("Exchange Gain/Loss amount has been booked through {0}").format(
|
_("Exchange Gain/Loss amount has been booked through {0}").format(
|
||||||
|
|||||||
Reference in New Issue
Block a user