fix: Test Cases
diff --git a/erpnext/accounts/dashboard_fixtures.py b/erpnext/accounts/dashboard_fixtures.py
index f90ac26..b2abffc 100644
--- a/erpnext/accounts/dashboard_fixtures.py
+++ b/erpnext/accounts/dashboard_fixtures.py
@@ -9,11 +9,15 @@
def _get_fiscal_year(date=None):
try:
- fiscal_year = get_fiscal_year(date=nowdate())
+ fiscal_year = get_fiscal_year(date=nowdate(), as_dict=True)
+ return fiscal_year
+
except FiscalYearError:
#if no fiscal year for current date then get default fiscal year
try:
- fiscal_year = get_fiscal_year()
+ fiscal_year = get_fiscal_year(as_dict=True)
+ return fiscal_year
+
except FiscalYearError:
#if still no fiscal year found then no accounting data created, return
return None
@@ -77,8 +81,8 @@
"filters_json": json.dumps({
"company": company.name,
"filter_based_on": "Fiscal Year",
- "from_fiscal_year": fiscal_year[0],
- "to_fiscal_year": fiscal_year[0],
+ "from_fiscal_year": fiscal_year.get('name'),
+ "to_fiscal_year": fiscal_year.get('name'),
"periodicity": "Monthly",
"include_default_book_entries": 1
}),
@@ -174,8 +178,8 @@
"report_name": "Budget Variance Report",
"filters_json": json.dumps({
"company": company.name,
- "from_fiscal_year": fiscal_year[0],
- "to_fiscal_year": fiscal_year[0],
+ "from_fiscal_year": fiscal_year.get('name'),
+ "to_fiscal_year": fiscal_year.get('name'),
"period": "Monthly",
"budget_against": "Cost Center"
}),
@@ -208,8 +212,8 @@
def get_number_cards(fiscal_year):
- year_start_date = get_date_str(fiscal_year[1])
- year_end_date = get_date_str(fiscal_year[2])
+ year_start_date = get_date_str(fiscal_year.get("year_start_date"))
+ year_end_date = get_date_str(fiscal_year.get("year_end_date"))
return [
{
"doctype": "Number Card",
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
index 894ec5b..8834385 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
@@ -72,7 +72,11 @@
if doctype == "Budget":
add_dimension_to_budget_doctype(df, doc)
else:
- create_custom_field(doctype, df)
+ meta = frappe.get_meta(doctype, cached=False)
+ fieldnames = [d.fieldname for d in meta.get("fields")]
+
+ if df['fieldname'] not in fieldnames:
+ create_custom_field(doctype, df)
count += 1
diff --git a/erpnext/assets/dashboard_fixtures.py b/erpnext/assets/dashboard_fixtures.py
index d1e65e1..7f3c1de 100644
--- a/erpnext/assets/dashboard_fixtures.py
+++ b/erpnext/assets/dashboard_fixtures.py
@@ -15,8 +15,8 @@
if not fiscal_year:
return frappe._dict()
- year_start_date = get_date_str(fiscal_year[1])
- year_end_date = get_date_str(fiscal_year[2])
+ year_start_date = get_date_str(fiscal_year.get('year_start_date'))
+ year_end_date = get_date_str(fiscal_year.get('year_end_date'))
return frappe._dict({
"dashboards": get_dashboards(),
@@ -59,8 +59,8 @@
"company": company,
"status": "In Location",
"filter_based_on": "Fiscal Year",
- "from_fiscal_year": fiscal_year[0],
- "to_fiscal_year": fiscal_year[0],
+ "from_fiscal_year": fiscal_year.get('name'),
+ "to_fiscal_year": fiscal_year.get('name'),
"period_start_date": year_start_date,
"period_end_date": year_end_date,
"date_based_on": "Purchase Date",
diff --git a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
index bebf0cc..c7204a1 100644
--- a/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
+++ b/erpnext/buying/report/procurement_tracker/test_procurement_tracker.py
@@ -15,7 +15,7 @@
def test_result_for_procurement_tracker(self):
filters = {
'company': '_Test Procurement Company',
- 'cost_center': '_Test Cost Center - _TC'
+ 'cost_center': 'Main - _TPC'
}
expected_data = self.generate_expected_data()
report = execute(filters)
@@ -33,24 +33,27 @@
country="Pakistan"
)).insert()
warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company")
- mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse)
+ mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse, cost_center="Main - _TPC")
po = make_purchase_order(mr.name)
po.supplier = "_Test Supplier"
- po.get("items")[0].cost_center = "_Test Cost Center - _TC"
+ po.get("items")[0].cost_center = "Main - _TPC"
po.submit()
pr = make_purchase_receipt(po.name)
+ pr.get("items")[0].cost_center = "Main - _TPC"
pr.submit()
frappe.db.commit()
date_obj = datetime.date(datetime.now())
+ po.load_from_db()
+
expected_data = {
"material_request_date": date_obj,
- "cost_center": "_Test Cost Center - _TC",
+ "cost_center": "Main - _TPC",
"project": None,
"requesting_site": "_Test Procurement Warehouse - _TPC",
"requestor": "Administrator",
"material_request_no": mr.name,
- "description": '_Test Item 1',
+ "item_code": '_Test Item',
"quantity": 10.0,
"unit_of_measurement": "_Test UOM",
"status": "To Bill",
@@ -58,9 +61,9 @@
"purchase_order": po.name,
"supplier": "_Test Supplier",
"estimated_cost": 0.0,
- "actual_cost": None,
- "purchase_order_amt": 5000.0,
- "purchase_order_amt_in_company_currency": 300000.0,
+ "actual_cost": 0.0,
+ "purchase_order_amt": po.net_total,
+ "purchase_order_amt_in_company_currency": po.base_net_total,
"expected_delivery_date": date_obj,
"actual_delivery_date": date_obj
}
diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py
index 4c2d3f6..2bef5fb 100644
--- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py
+++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py
@@ -15,6 +15,7 @@
patient = create_patient()
# Schedule Admission
ip_record = create_inpatient(patient)
+ ip_record.expected_length_of_stay = 0
ip_record.save(ignore_permissions = True)
self.assertEqual(ip_record.name, frappe.db.get_value("Patient", patient, "inpatient_record"))
self.assertEqual(ip_record.status, frappe.db.get_value("Patient", patient, "inpatient_status"))
@@ -26,7 +27,7 @@
self.assertEqual("Occupied", frappe.db.get_value("Healthcare Service Unit", service_unit, "occupancy_status"))
# Discharge
- schedule_discharge(patient=patient)
+ schedule_discharge(frappe.as_json({'patient': patient}))
self.assertEqual("Vacant", frappe.db.get_value("Healthcare Service Unit", service_unit, "occupancy_status"))
ip_record1 = frappe.get_doc("Inpatient Record", ip_record.name)
@@ -44,8 +45,10 @@
patient = create_patient()
ip_record = create_inpatient(patient)
+ ip_record.expected_length_of_stay = 0
ip_record.save(ignore_permissions = True)
ip_record_new = create_inpatient(patient)
+ ip_record_new.expected_length_of_stay = 0
self.assertRaises(frappe.ValidationError, ip_record_new.save)
service_unit = get_healthcare_service_unit()
diff --git a/erpnext/projects/doctype/task/test_task.py b/erpnext/projects/doctype/task/test_task.py
index bd33694..47a28fd 100644
--- a/erpnext/projects/doctype/task/test_task.py
+++ b/erpnext/projects/doctype/task/test_task.py
@@ -64,7 +64,7 @@
def assign():
from frappe.desk.form import assign_to
assign_to.add({
- "assign_to": "test@example.com",
+ "assign_to": ["test@example.com"],
"doctype": task.doctype,
"name": task.name,
"description": "Close this task"