Skip to content

Commit

Permalink
test: naming series variable parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
GursheenK committed Jan 10, 2024
1 parent d96a777 commit bbdf98a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions erpnext/accounts/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def setUpClass(cls):
super(TestUtils, cls).setUpClass()
make_test_objects("Address", ADDRESS_RECORDS)

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

def test_get_party_shipping_address(self):
address = get_party_shipping_address("Customer", "_Test Customer 1")
self.assertEqual(address, "_Test Billing Address 2 Title-Billing")
Expand Down Expand Up @@ -126,6 +129,38 @@ def test_update_reference_in_payment_entry(self):
self.assertEqual(len(payment_entry.references), 1)
self.assertEqual(payment_entry.difference_amount, 0)

def test_naming_series_variable_parsing(self):
"""
Tests parsing utility used by Naming Series Variable hook for FY
"""
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
from frappe.utils import nowdate

from erpnext.accounts.utils import get_fiscal_year
from erpnext.buying.doctype.supplier.test_supplier import create_supplier

# Configure Supplier Naming in Buying Settings
frappe.db.set_default("supp_master_name", "Auto Name")

# Configure Autoname in Supplier DocType
make_property_setter(
"Supplier", None, "naming_rule", "Expression", "Data", for_doctype="Doctype"
)
make_property_setter(
"Supplier", None, "autoname", "SUP-.FY.-.#####", "Data", for_doctype="Doctype"
)

# Create Fiscal Year for Current Year
fiscal_year = get_fiscal_year(nowdate())[0]

# Create Supplier
supplier = create_supplier()

# Check Naming Series in generated Supplier ID
doc_name = supplier.name.split("-")
self.assertEqual(len(doc_name), 3)
self.assertSequenceEqual(doc_name[0:2], ("SUP", fiscal_year))


ADDRESS_RECORDS = [
{
Expand Down

0 comments on commit bbdf98a

Please sign in to comment.