Merge pull request #42578 from ljain112/fix-dimensions
fix: dimensions in common party journal entry
This commit is contained in:
@@ -3096,6 +3096,84 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
party_link.delete()
|
party_link.delete()
|
||||||
frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 0)
|
frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 0)
|
||||||
|
|
||||||
|
def test_sales_invoice_against_supplier_usd_with_dimensions(self):
|
||||||
|
from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import (
|
||||||
|
make_customer,
|
||||||
|
)
|
||||||
|
from erpnext.accounts.doctype.party_link.party_link import create_party_link
|
||||||
|
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
|
||||||
|
|
||||||
|
# create a customer
|
||||||
|
customer = make_customer(customer="_Test Common Supplier USD")
|
||||||
|
cust_doc = frappe.get_doc("Customer", customer)
|
||||||
|
cust_doc.default_currency = "USD"
|
||||||
|
cust_doc.save()
|
||||||
|
# create a supplier
|
||||||
|
supplier = create_supplier(supplier_name="_Test Common Supplier USD").name
|
||||||
|
supp_doc = frappe.get_doc("Supplier", supplier)
|
||||||
|
supp_doc.default_currency = "USD"
|
||||||
|
supp_doc.save()
|
||||||
|
|
||||||
|
# create a party link between customer & supplier
|
||||||
|
party_link = create_party_link("Supplier", supplier, customer)
|
||||||
|
|
||||||
|
# enable common party accounting
|
||||||
|
frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 1)
|
||||||
|
|
||||||
|
# create a dimension and make it mandatory
|
||||||
|
if not frappe.get_all("Accounting Dimension", filters={"document_type": "Department"}):
|
||||||
|
dim = frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Accounting Dimension",
|
||||||
|
"document_type": "Department",
|
||||||
|
"dimension_defaults": [{"company": "_Test Company", "mandatory_for_bs": True}],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
dim.save()
|
||||||
|
else:
|
||||||
|
dim = frappe.get_doc(
|
||||||
|
"Accounting Dimension",
|
||||||
|
frappe.get_all("Accounting Dimension", filters={"document_type": "Department"})[0],
|
||||||
|
)
|
||||||
|
dim.disabled = False
|
||||||
|
dim.dimension_defaults = []
|
||||||
|
dim.append("dimension_defaults", {"company": "_Test Company", "mandatory_for_bs": True})
|
||||||
|
dim.save()
|
||||||
|
|
||||||
|
# create a sales invoice
|
||||||
|
si = create_sales_invoice(
|
||||||
|
customer=customer, parent_cost_center="_Test Cost Center - _TC", do_not_submit=True
|
||||||
|
)
|
||||||
|
si.department = "All Departments"
|
||||||
|
si.save().submit()
|
||||||
|
|
||||||
|
# check outstanding of sales invoice
|
||||||
|
si.reload()
|
||||||
|
self.assertEqual(si.status, "Paid")
|
||||||
|
self.assertEqual(flt(si.outstanding_amount), 0.0)
|
||||||
|
|
||||||
|
# check creation of journal entry
|
||||||
|
jv = frappe.get_all(
|
||||||
|
"Journal Entry Account",
|
||||||
|
{
|
||||||
|
"account": si.debit_to,
|
||||||
|
"party_type": "Customer",
|
||||||
|
"party": si.customer,
|
||||||
|
"reference_type": si.doctype,
|
||||||
|
"reference_name": si.name,
|
||||||
|
"department": "All Departments",
|
||||||
|
},
|
||||||
|
pluck="credit_in_account_currency",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(jv)
|
||||||
|
self.assertEqual(jv[0], si.grand_total)
|
||||||
|
|
||||||
|
dim.disabled = True
|
||||||
|
dim.save()
|
||||||
|
party_link.delete()
|
||||||
|
frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 0)
|
||||||
|
|
||||||
def test_payment_statuses(self):
|
def test_payment_statuses(self):
|
||||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||||
|
|
||||||
|
|||||||
@@ -2461,6 +2461,15 @@ class AccountsController(TransactionBase):
|
|||||||
advance_entry.cost_center = self.cost_center or erpnext.get_default_cost_center(self.company)
|
advance_entry.cost_center = self.cost_center or erpnext.get_default_cost_center(self.company)
|
||||||
advance_entry.is_advance = "Yes"
|
advance_entry.is_advance = "Yes"
|
||||||
|
|
||||||
|
# update dimesions
|
||||||
|
dimensions_dict = frappe._dict()
|
||||||
|
active_dimensions = get_dimensions()[0]
|
||||||
|
for dim in active_dimensions:
|
||||||
|
dimensions_dict[dim.fieldname] = self.get(dim.fieldname)
|
||||||
|
|
||||||
|
reconcilation_entry.update(dimensions_dict)
|
||||||
|
advance_entry.update(dimensions_dict)
|
||||||
|
|
||||||
if self.doctype == "Sales Invoice":
|
if self.doctype == "Sales Invoice":
|
||||||
reconcilation_entry.credit_in_account_currency = self.outstanding_amount
|
reconcilation_entry.credit_in_account_currency = self.outstanding_amount
|
||||||
advance_entry.debit_in_account_currency = self.outstanding_amount
|
advance_entry.debit_in_account_currency = self.outstanding_amount
|
||||||
|
|||||||
Reference in New Issue
Block a user