mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
Merge pull request #51338 from mihir-kandoi/gh43256
This commit is contained in:
@@ -45,7 +45,7 @@ class SupplierScorecardCriteria(Document):
|
|||||||
mylist = re.finditer(regex, test_formula, re.MULTILINE | re.DOTALL)
|
mylist = re.finditer(regex, test_formula, re.MULTILINE | re.DOTALL)
|
||||||
for _dummy1, match in enumerate(mylist):
|
for _dummy1, match in enumerate(mylist):
|
||||||
for _dummy2 in range(0, len(match.groups())):
|
for _dummy2 in range(0, len(match.groups())):
|
||||||
test_formula = test_formula.replace("{" + match.group(1) + "}", "0")
|
test_formula = test_formula.replace("{" + match.group(1) + "}", "1")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
frappe.safe_eval(test_formula, None, {"max": max, "min": min})
|
frappe.safe_eval(test_formula, None, {"max": max, "min": min})
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class TestSupplierScorecardCriteria(IntegrationTestCase):
|
|||||||
def test_formula_validate(self):
|
def test_formula_validate(self):
|
||||||
delete_test_scorecards()
|
delete_test_scorecards()
|
||||||
self.assertRaises(frappe.ValidationError, frappe.get_doc(test_bad_criteria[1]).insert)
|
self.assertRaises(frappe.ValidationError, frappe.get_doc(test_bad_criteria[1]).insert)
|
||||||
self.assertRaises(frappe.ValidationError, frappe.get_doc(test_bad_criteria[2]).insert)
|
|
||||||
|
|
||||||
|
|
||||||
def delete_test_scorecards():
|
def delete_test_scorecards():
|
||||||
@@ -68,16 +67,8 @@ test_bad_criteria = [
|
|||||||
"name": "Fake Criteria 2",
|
"name": "Fake Criteria 2",
|
||||||
"weight": 40.0,
|
"weight": 40.0,
|
||||||
"doctype": "Supplier Scorecard Criteria",
|
"doctype": "Supplier Scorecard Criteria",
|
||||||
"formula": "(({cost_of_on_time_shipments} / {tot_cost_shipments}))* 100", # Force 0 divided by 0
|
"formula": "(({cost_of_on_time_shipments} {cost_of_on_time_shipments} / {tot_cost_shipments}))* 100", # Two variables beside eachother
|
||||||
"criteria_name": "Fake Criteria 2",
|
"criteria_name": "Fake Criteria 2",
|
||||||
"max_score": 100.0,
|
"max_score": 100.0,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Fake Criteria 3",
|
|
||||||
"weight": 40.0,
|
|
||||||
"doctype": "Supplier Scorecard Criteria",
|
|
||||||
"formula": "(({cost_of_on_time_shipments} {cost_of_on_time_shipments} / {tot_cost_shipments}))* 100", # Two variables beside eachother
|
|
||||||
"criteria_name": "Fake Criteria 3",
|
|
||||||
"max_score": 100.0,
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user