Skip to content

Commit

Permalink
test: update test cases to validate company-based accounting dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavan23 committed Feb 28, 2025
1 parent 4f8e13c commit 7bdf786
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion erpnext/accounts/doctype/journal_entry/test_journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,14 @@ def make_journal_entry(
save=True,
submit=False,
project=None,
company=None,
):
if not cost_center:
cost_center = "_Test Cost Center - _TC"

jv = frappe.new_doc("Journal Entry")
jv.posting_date = posting_date or nowdate()
jv.company = "_Test Company"
jv.company = company or "_Test Company"
jv.user_remark = "test"
jv.multi_currency = 1
jv.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_closing_entry(self):
account1="Cash - TPC",
account2="Sales - TPC",
cost_center=cost_center,
company=company,
save=False,
)
jv1.company = company
Expand All @@ -38,6 +39,7 @@ def test_closing_entry(self):
account1="Cost of Goods Sold - TPC",
account2="Cash - TPC",
cost_center=cost_center,
company=company,
save=False,
)
jv2.company = company
Expand Down Expand Up @@ -155,6 +157,7 @@ def test_period_closing_with_finance_book_entries(self):
amount=400,
cost_center=cost_center,
posting_date="2021-03-15",
company=company,
)
jv.company = company
jv.finance_book = create_finance_book().name
Expand Down Expand Up @@ -197,6 +200,7 @@ def test_gl_entries_restrictions(self):
account1="Cash - TPC",
account2="Sales - TPC",
cost_center=cost_center,
company=company,
save=False,
)
jv1.company = company
Expand All @@ -219,6 +223,7 @@ def test_closing_balance_with_dimensions_and_test_reposting_entry(self):
account1="Cash - TPC",
account2="Sales - TPC",
cost_center=cost_center1,
company=company,
save=False,
)
jv1.company = company
Expand All @@ -231,6 +236,7 @@ def test_closing_balance_with_dimensions_and_test_reposting_entry(self):
account1="Cash - TPC",
account2="Sales - TPC",
cost_center=cost_center2,
company=company,
save=False,
)
jv2.company = company
Expand Down Expand Up @@ -260,6 +266,7 @@ def test_closing_balance_with_dimensions_and_test_reposting_entry(self):
account1="Cash - TPC",
account2="Sales - TPC",
cost_center=cost_center2,
company=company,
save=False,
)

Expand Down
11 changes: 10 additions & 1 deletion erpnext/buying/doctype/purchase_order/test_purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ def test_payment_terms_are_fetched_when_creating_purchase_invoice(self):
automatically_fetch_payment_terms(enable=0)

def test_internal_transfer_flow(self):
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
from erpnext.accounts.doctype.sales_invoice.sales_invoice import (
make_inter_company_purchase_invoice,
)
Expand All @@ -956,8 +957,16 @@ def test_internal_transfer_flow(self):
prepare_data_for_internal_transfer()
supplier = "_Test Internal Supplier 2"

create_cost_center(
cost_center_name="_Test Cost Center for perpetual inventory Account",
company="_Test Company with perpetual inventory",
)

mr = make_material_request(
qty=2, company="_Test Company with perpetual inventory", warehouse="Stores - TCP1"
qty=2,
company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1",
cost_center="_Test Cost Center for perpetual inventory Account - TCP1",
)

po = create_purchase_order(
Expand Down
3 changes: 3 additions & 0 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from frappe.utils import add_days, cstr, flt, getdate, nowdate, nowtime, today

from erpnext.accounts.doctype.account.test_account import get_inventory_account
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
from erpnext.accounts.utils import get_balance_on
from erpnext.controllers.accounts_controller import InvalidQtyError
from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
Expand Down Expand Up @@ -1436,6 +1437,7 @@ def test_internal_transfer_precision_gle(self):
warehouse = "Stores - TCP1"
target = "Finished Goods - TCP1"
customer = create_internal_customer(represents_company=company)
create_cost_center(cost_center_name="_Test Cost Center", company=company)

# average rate = 128.015
rates = [101.45, 150.46, 138.25, 121.9]
Expand All @@ -1450,6 +1452,7 @@ def test_internal_transfer_precision_gle(self):
qty=4,
warehouse=warehouse,
target_warehouse=target,
cost_center="_Test Cost Center - TCP1",
)
self.assertFalse(frappe.db.exists("GL Entry", {"voucher_no": dn.name, "voucher_type": dn.doctype}))

Expand Down
13 changes: 13 additions & 0 deletions erpnext/stock/doctype/serial_no/test_serial_no.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class UnitTestSerialNo(UnitTestCase):


class TestSerialNo(IntegrationTestCase):
def setUp(self):
self.create_currency_exchange()

def create_currency_exchange(self):
c_doc = frappe.new_doc("Currency Exchange")
c_doc.from_currency = "INR"
c_doc.to_currency = "USD"
c_doc.exchange_rate = 87.33
c_doc.insert()

def tearDown(self):
frappe.db.rollback()

Expand Down Expand Up @@ -127,6 +137,7 @@ def test_inter_company_transfer_intermediate_cancellation(self):
serial_no=[serial_nos[0]],
company="_Test Company 1",
warehouse=wh,
cost_center="_Test Company 1 - _TC1",
)
sn_doc.reload()

Expand Down Expand Up @@ -162,6 +173,7 @@ def test_inter_company_transfer_fallback_on_cancel(self):
serial_no=[serial_nos[0]],
company="_Test Company 1",
warehouse=wh,
cost_center="_Test Company 1 - _TC1",
)

# Delivery from second company
Expand All @@ -171,6 +183,7 @@ def test_inter_company_transfer_fallback_on_cancel(self):
serial_no=[serial_nos[0]],
company="_Test Company 1",
warehouse=wh,
cost_center="_Test Company 1 - _TC1",
)
sn_doc.reload()

Expand Down

0 comments on commit 7bdf786

Please sign in to comment.