From 7cba72a0b7de4f8f9e85c7ed6761c0006c098589 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Jun 2014 11:09:21 +0530 Subject: [PATCH 1/2] Pricing Rule: price / discount percentage can not be negative --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 9 ++++++++- erpnext/setup/doctype/currency/currency.py | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 61e7ade4415..a15b45a381a 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -14,13 +14,15 @@ class PricingRule(Document): self.validate_mandatory() self.validate_min_max_qty() self.cleanup_fields_value() + self.validate_price_or_discount() def validate_mandatory(self): - for field in ["apply_on", "applicable_for", "price_or_discount"]: + for field in ["apply_on", "applicable_for"]: tocheck = frappe.scrub(self.get(field) or "") if tocheck and not self.get(tocheck): throw(_("{0} is required").format(self.meta.get_label(tocheck)), frappe.MandatoryError) + def validate_min_max_qty(self): if self.min_qty and self.max_qty and flt(self.min_qty) > flt(self.max_qty): throw(_("Min Qty can not be greater than Max Qty")) @@ -37,3 +39,8 @@ class PricingRule(Document): f = frappe.scrub(f) if f!=fieldname: self.set(f, None) + + def validate_price_or_discount(self): + for field in ["Price", "Discount Percentage"]: + if flt(self.get(frappe.scrub(field))) < 0: + throw(_("{0} can not be negative").format(field)) diff --git a/erpnext/setup/doctype/currency/currency.py b/erpnext/setup/doctype/currency/currency.py index 9dc6e3b2290..5be618b80e4 100644 --- a/erpnext/setup/doctype/currency/currency.py +++ b/erpnext/setup/doctype/currency/currency.py @@ -8,7 +8,8 @@ from frappe import throw, _ from frappe.model.document import Document class Currency(Document): - pass + def validate(self): + frappe.clear_cache() def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): """common validation for currency and price list currency""" @@ -20,4 +21,4 @@ def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, c "conversion_rate_label": conversion_rate_label, "from_currency": currency, "to_currency": company_currency - }) \ No newline at end of file + }) From 6febfca5a6eeba0a39898b7becd7125afab4f8ef Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 10 Jun 2014 11:21:38 +0530 Subject: [PATCH 2/2] changed insert after for india related custom fields --- .../create_custom_fields_for_india_specific_fields.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py b/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py index eeb0f5b9042..9b07000554f 100644 --- a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py +++ b/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py @@ -20,7 +20,7 @@ def execute(): "label": "Supplier Shipment Date", "fieldname": "challan_date", "fieldtype": "Date", - "insert_after": "challan_no" + "insert_after": "is_subcontracted" }], "Employee": [{ "label": "PAN Number", @@ -31,7 +31,7 @@ def execute(): "label": "Gratuity LIC Id", "fieldname": "gratuity_lic_id", "fieldtype": "Data", - "insert_after": "pan_number" + "insert_after": "company_email" }, { "label": "Esic Card No", "fieldname": "esic_card_no", @@ -41,7 +41,7 @@ def execute(): "label": "PF Number", "fieldname": "pf_number", "fieldtype": "Data", - "insert_after": "esic_card_no" + "insert_after": "bank_ac_no" }], "Salary Slip": [{ "label": "Esic No", @@ -53,7 +53,7 @@ def execute(): "label": "PF Number", "fieldname": "pf_no", "fieldtype": "Data", - "insert_after": "esic_no", + "insert_after": "letter_head", "permlevel": 1 }] }