mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
@@ -14,13 +14,15 @@ class PricingRule(Document):
|
|||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_min_max_qty()
|
self.validate_min_max_qty()
|
||||||
self.cleanup_fields_value()
|
self.cleanup_fields_value()
|
||||||
|
self.validate_price_or_discount()
|
||||||
|
|
||||||
def validate_mandatory(self):
|
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 "")
|
tocheck = frappe.scrub(self.get(field) or "")
|
||||||
if tocheck and not self.get(tocheck):
|
if tocheck and not self.get(tocheck):
|
||||||
throw(_("{0} is required").format(self.meta.get_label(tocheck)), frappe.MandatoryError)
|
throw(_("{0} is required").format(self.meta.get_label(tocheck)), frappe.MandatoryError)
|
||||||
|
|
||||||
|
|
||||||
def validate_min_max_qty(self):
|
def validate_min_max_qty(self):
|
||||||
if self.min_qty and self.max_qty and flt(self.min_qty) > flt(self.max_qty):
|
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"))
|
throw(_("Min Qty can not be greater than Max Qty"))
|
||||||
@@ -37,3 +39,8 @@ class PricingRule(Document):
|
|||||||
f = frappe.scrub(f)
|
f = frappe.scrub(f)
|
||||||
if f!=fieldname:
|
if f!=fieldname:
|
||||||
self.set(f, None)
|
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))
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ def execute():
|
|||||||
"label": "Supplier Shipment Date",
|
"label": "Supplier Shipment Date",
|
||||||
"fieldname": "challan_date",
|
"fieldname": "challan_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"insert_after": "challan_no"
|
"insert_after": "is_subcontracted"
|
||||||
}],
|
}],
|
||||||
"Employee": [{
|
"Employee": [{
|
||||||
"label": "PAN Number",
|
"label": "PAN Number",
|
||||||
@@ -31,7 +31,7 @@ def execute():
|
|||||||
"label": "Gratuity LIC Id",
|
"label": "Gratuity LIC Id",
|
||||||
"fieldname": "gratuity_lic_id",
|
"fieldname": "gratuity_lic_id",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"insert_after": "pan_number"
|
"insert_after": "company_email"
|
||||||
}, {
|
}, {
|
||||||
"label": "Esic Card No",
|
"label": "Esic Card No",
|
||||||
"fieldname": "esic_card_no",
|
"fieldname": "esic_card_no",
|
||||||
@@ -41,7 +41,7 @@ def execute():
|
|||||||
"label": "PF Number",
|
"label": "PF Number",
|
||||||
"fieldname": "pf_number",
|
"fieldname": "pf_number",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"insert_after": "esic_card_no"
|
"insert_after": "bank_ac_no"
|
||||||
}],
|
}],
|
||||||
"Salary Slip": [{
|
"Salary Slip": [{
|
||||||
"label": "Esic No",
|
"label": "Esic No",
|
||||||
@@ -53,7 +53,7 @@ def execute():
|
|||||||
"label": "PF Number",
|
"label": "PF Number",
|
||||||
"fieldname": "pf_no",
|
"fieldname": "pf_no",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"insert_after": "esic_no",
|
"insert_after": "letter_head",
|
||||||
"permlevel": 1
|
"permlevel": 1
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from frappe import throw, _
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class Currency(Document):
|
class Currency(Document):
|
||||||
pass
|
def validate(self):
|
||||||
|
frappe.clear_cache()
|
||||||
|
|
||||||
def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
|
def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
|
||||||
"""common validation for currency and price list currency"""
|
"""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,
|
"conversion_rate_label": conversion_rate_label,
|
||||||
"from_currency": currency,
|
"from_currency": currency,
|
||||||
"to_currency": company_currency
|
"to_currency": company_currency
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user