mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
fix: Travis (#25078)
* fix(test): set default accounts in mode of payment * fix(test): import_doc params in shopify settings test * fix: syntax error in salary slip test * fix(test): use Temporary Opening account for Stock Reco opening entry * fix(test): skip GST doc naming validations for tests * fix(test): Salary Structure Assignment date edge case * fix(test): GST doc naming validations * fix: sider * revert: skip GST doc naming validations for tests
This commit is contained in:
@@ -62,14 +62,15 @@ class POSProfile(Document):
|
|||||||
|
|
||||||
if len(default_mode) > 1:
|
if len(default_mode) > 1:
|
||||||
frappe.throw(_("You can only select one mode of payment as default"))
|
frappe.throw(_("You can only select one mode of payment as default"))
|
||||||
|
|
||||||
invalid_modes = []
|
invalid_modes = []
|
||||||
for d in self.payments:
|
for d in self.payments:
|
||||||
account = frappe.db.get_value(
|
account = frappe.db.get_value(
|
||||||
"Mode of Payment Account",
|
"Mode of Payment Account",
|
||||||
{"parent": d.mode_of_payment, "company": self.company},
|
{"parent": d.mode_of_payment, "company": self.company},
|
||||||
"default_account"
|
"default_account"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not account:
|
if not account:
|
||||||
invalid_modes.append(get_link_to_form("Mode of Payment", d.mode_of_payment))
|
invalid_modes.append(get_link_to_form("Mode of Payment", d.mode_of_payment))
|
||||||
|
|
||||||
|
|||||||
@@ -92,11 +92,21 @@ def make_pos_profile(**args):
|
|||||||
"write_off_cost_center": args.write_off_cost_center or "_Test Write Off Cost Center - _TC"
|
"write_off_cost_center": args.write_off_cost_center or "_Test Write Off Cost Center - _TC"
|
||||||
})
|
})
|
||||||
|
|
||||||
payments = [{
|
mode_of_payment = frappe.get_doc("Mode of Payment", "Cash")
|
||||||
|
company = args.company or "_Test Company"
|
||||||
|
default_account = args.income_account or "Sales - _TC"
|
||||||
|
|
||||||
|
if not frappe.db.get_value("Mode of Payment Account", {"company": company, "parent": "Cash"}):
|
||||||
|
mode_of_payment.append("accounts", {
|
||||||
|
"company": company,
|
||||||
|
"default_account": default_account
|
||||||
|
})
|
||||||
|
mode_of_payment.save()
|
||||||
|
|
||||||
|
pos_profile.append("payments", {
|
||||||
'mode_of_payment': 'Cash',
|
'mode_of_payment': 'Cash',
|
||||||
'default': 1
|
'default': 1
|
||||||
}]
|
})
|
||||||
pos_profile.set("payments", payments)
|
|
||||||
|
|
||||||
if not frappe.db.exists("POS Profile", args.name or "_Test POS Profile"):
|
if not frappe.db.exists("POS Profile", args.name or "_Test POS Profile"):
|
||||||
pos_profile.insert()
|
pos_profile.insert()
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ class ShopifySettings(unittest.TestCase):
|
|||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
|
|
||||||
# use the fixture data
|
# use the fixture data
|
||||||
import_doc(path=frappe.get_app_path("erpnext", "erpnext_integrations/doctype/shopify_settings/test_data/custom_field.json"),
|
import_doc(path=frappe.get_app_path("erpnext", "erpnext_integrations/doctype/shopify_settings/test_data/custom_field.json"))
|
||||||
ignore_links=True, overwrite=True)
|
|
||||||
|
|
||||||
frappe.reload_doctype("Customer")
|
frappe.reload_doctype("Customer")
|
||||||
frappe.reload_doctype("Sales Order")
|
frappe.reload_doctype("Sales Order")
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
frappe.db.sql("DELETE FROM `tabSalary Slip` where employee_name = 'test_ytd@salary.com'")
|
frappe.db.sql("DELETE FROM `tabSalary Slip` where employee_name = 'test_ytd@salary.com'")
|
||||||
|
|
||||||
create_salary_slips_for_payroll_period(applicant, salary_structure.name,
|
create_salary_slips_for_payroll_period(applicant, salary_structure.name,
|
||||||
payroll_period, deduct_random=False)
|
payroll_period, deduct_random=False, num=6)
|
||||||
|
|
||||||
salary_slips = frappe.get_all('Salary Slip', fields=['year_to_date', 'net_pay'], filters={'employee_name':
|
salary_slips = frappe.get_all('Salary Slip', fields=['year_to_date', 'net_pay'], filters={'employee_name':
|
||||||
'test_ytd@salary.com'}, order_by = 'posting_date')
|
'test_ytd@salary.com'}, order_by = 'posting_date')
|
||||||
|
|||||||
@@ -164,7 +164,13 @@ def create_salary_structure_assignment(employee, salary_structure, from_date=Non
|
|||||||
salary_structure_assignment.employee = employee
|
salary_structure_assignment.employee = employee
|
||||||
salary_structure_assignment.base = 50000
|
salary_structure_assignment.base = 50000
|
||||||
salary_structure_assignment.variable = 5000
|
salary_structure_assignment.variable = 5000
|
||||||
salary_structure_assignment.from_date = from_date or add_days(nowdate(), -1)
|
|
||||||
|
if getdate(nowdate()).day == 1:
|
||||||
|
date = from_date or nowdate()
|
||||||
|
else:
|
||||||
|
date = from_date or add_days(nowdate(), -1)
|
||||||
|
|
||||||
|
salary_structure_assignment.from_date = date
|
||||||
salary_structure_assignment.salary_structure = salary_structure
|
salary_structure_assignment.salary_structure = salary_structure
|
||||||
salary_structure_assignment.currency = currency
|
salary_structure_assignment.currency = currency
|
||||||
salary_structure_assignment.payroll_payable_account = get_payable_account(company)
|
salary_structure_assignment.payroll_payable_account = get_payable_account(company)
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ class TestIndiaUtils(unittest.TestCase):
|
|||||||
mock_get_cached.return_value = "India" # mock country
|
mock_get_cached.return_value = "India" # mock country
|
||||||
posting_date = "2021-05-01"
|
posting_date = "2021-05-01"
|
||||||
|
|
||||||
invalid_names = [ "SI$1231", "012345678901234567", "SI 2020 05",
|
invalid_names = ["SI$1231", "012345678901234567", "SI 2020 05",
|
||||||
"SI.2020.0001", "PI2021 - 001" ]
|
"SI.2020.0001", "PI2021 - 001"]
|
||||||
for name in invalid_names:
|
for name in invalid_names:
|
||||||
doc = frappe._dict(name=name, posting_date=posting_date)
|
doc = frappe._dict(name=name, posting_date=posting_date)
|
||||||
self.assertRaises(frappe.ValidationError, validate_document_name, doc)
|
self.assertRaises(frappe.ValidationError, validate_document_name, doc)
|
||||||
|
|
||||||
valid_names = [ "012345678901236", "SI/2020/0001", "SI/2020-0001",
|
valid_names = ["012345678901236", "SI/2020/0001", "SI/2020-0001",
|
||||||
"2020-PI-0001", "PI2020-0001" ]
|
"2020-PI-0001", "PI2020-0001"]
|
||||||
for name in valid_names:
|
for name in valid_names:
|
||||||
doc = frappe._dict(name=name, posting_date=posting_date)
|
doc = frappe._dict(name=name, posting_date=posting_date)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ def set_place_of_supply(doc, method=None):
|
|||||||
|
|
||||||
def validate_document_name(doc, method=None):
|
def validate_document_name(doc, method=None):
|
||||||
"""Validate GST invoice number requirements."""
|
"""Validate GST invoice number requirements."""
|
||||||
|
|
||||||
country = frappe.get_cached_value("Company", doc.company, "country")
|
country = frappe.get_cached_value("Company", doc.company, "country")
|
||||||
|
|
||||||
# Date was chosen as start of next FY to avoid irritating current users.
|
# Date was chosen as start of next FY to avoid irritating current users.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
qty=50,
|
qty=50,
|
||||||
rate=100,
|
rate=100,
|
||||||
company=company,
|
company=company,
|
||||||
expense_account = "Stock Adjustment - _TC",
|
expense_account = "Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC",
|
||||||
posting_date='2020-04-10',
|
posting_date='2020-04-10',
|
||||||
posting_time='14:00'
|
posting_time='14:00'
|
||||||
)
|
)
|
||||||
@@ -46,7 +46,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
qty=10,
|
qty=10,
|
||||||
rate=200,
|
rate=200,
|
||||||
company=company,
|
company=company,
|
||||||
expense_account = "Stock Adjustment - _TC",
|
expense_account="Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC",
|
||||||
posting_date='2020-04-20',
|
posting_date='2020-04-20',
|
||||||
posting_time='14:00'
|
posting_time='14:00'
|
||||||
)
|
)
|
||||||
@@ -58,7 +58,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
target="Finished Goods - _TC",
|
target="Finished Goods - _TC",
|
||||||
company=company,
|
company=company,
|
||||||
qty=10,
|
qty=10,
|
||||||
expense_account="Stock Adjustment - _TC",
|
expense_account="Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC",
|
||||||
posting_date='2020-04-30',
|
posting_date='2020-04-30',
|
||||||
posting_time='14:00'
|
posting_time='14:00'
|
||||||
)
|
)
|
||||||
@@ -90,7 +90,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
qty=50,
|
qty=50,
|
||||||
rate=150,
|
rate=150,
|
||||||
company=company,
|
company=company,
|
||||||
expense_account = "Stock Adjustment - _TC",
|
expense_account ="Stock Adjustment - _TC" if frappe.get_all("Stock Ledger Entry") else "Temporary Opening - _TC",
|
||||||
posting_date='2020-04-12',
|
posting_date='2020-04-12',
|
||||||
posting_time='14:00'
|
posting_time='14:00'
|
||||||
)
|
)
|
||||||
@@ -125,7 +125,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
pr = make_purchase_receipt(company="_Test Company", posting_date='2020-04-10',
|
pr = make_purchase_receipt(company="_Test Company", posting_date='2020-04-10',
|
||||||
warehouse="Stores - _TC", item_code="_Test Item for Reposting", qty=5, rate=100)
|
warehouse="Stores - _TC", item_code="_Test Item for Reposting", qty=5, rate=100)
|
||||||
|
|
||||||
return_pr = make_purchase_receipt(company="_Test Company", posting_date='2020-04-15',
|
return_pr = make_purchase_receipt(company="_Test Company", posting_date='2020-04-15',
|
||||||
warehouse="Stores - _TC", item_code="_Test Item for Reposting", is_return=1, return_against=pr.name, qty=-2)
|
warehouse="Stores - _TC", item_code="_Test Item for Reposting", is_return=1, return_against=pr.name, qty=-2)
|
||||||
|
|
||||||
# check sle
|
# check sle
|
||||||
@@ -278,7 +278,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.set_value("Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM")
|
frappe.db.set_value("Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM")
|
||||||
make_bom(item = subcontracted_item, raw_materials =[rm_item_code], currency="INR")
|
make_bom(item = subcontracted_item, raw_materials =[rm_item_code], currency="INR")
|
||||||
|
|
||||||
# Purchase raw materials on supplier warehouse: Qty = 50, Rate = 100
|
# Purchase raw materials on supplier warehouse: Qty = 50, Rate = 100
|
||||||
pr = make_purchase_receipt(company=company, posting_date='2020-04-10',
|
pr = make_purchase_receipt(company=company, posting_date='2020-04-10',
|
||||||
warehouse="Stores - _TC", item_code=rm_item_code, qty=10, rate=100)
|
warehouse="Stores - _TC", item_code=rm_item_code, qty=10, rate=100)
|
||||||
@@ -292,7 +292,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
|
|
||||||
# Update raw material's valuation via LCV, Additional cost = 50
|
# Update raw material's valuation via LCV, Additional cost = 50
|
||||||
lcv = create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company)
|
lcv = create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company)
|
||||||
|
|
||||||
pr1.reload()
|
pr1.reload()
|
||||||
self.assertEqual(pr1.items[0].valuation_rate, 125)
|
self.assertEqual(pr1.items[0].valuation_rate, 125)
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ class TestStockLedgerEntry(unittest.TestCase):
|
|||||||
# Back dated stock transactions are only allowed to stock managers
|
# Back dated stock transactions are only allowed to stock managers
|
||||||
frappe.db.set_value("Stock Settings", None,
|
frappe.db.set_value("Stock Settings", None,
|
||||||
"role_allowed_to_create_edit_back_dated_transactions", "Stock Manager")
|
"role_allowed_to_create_edit_back_dated_transactions", "Stock Manager")
|
||||||
|
|
||||||
# Set User with Stock User role but not Stock Manager
|
# Set User with Stock User role but not Stock Manager
|
||||||
frappe.set_user("test@example.com")
|
frappe.set_user("test@example.com")
|
||||||
user = frappe.get_doc("User", "test@example.com")
|
user = frappe.get_doc("User", "test@example.com")
|
||||||
|
|||||||
Reference in New Issue
Block a user