mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
fix: validation for ldc against supplier and section code
This commit is contained in:
@@ -5,12 +5,16 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate, get_link_to_form
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
class LowerDeductionCertificate(Document):
|
class LowerDeductionCertificate(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_dates()
|
||||||
|
self.validate_supplier_against_section_code()
|
||||||
|
|
||||||
|
def validate_dates(self):
|
||||||
if getdate(self.valid_upto) < getdate(self.valid_from):
|
if getdate(self.valid_upto) < getdate(self.valid_from):
|
||||||
frappe.throw(_("Valid Upto date cannot be before Valid From date"))
|
frappe.throw(_("Valid Upto date cannot be before Valid From date"))
|
||||||
|
|
||||||
@@ -24,3 +28,10 @@ class LowerDeductionCertificate(Document):
|
|||||||
<= fiscal_year.year_end_date):
|
<= fiscal_year.year_end_date):
|
||||||
frappe.throw(_("Valid Upto date not in Fiscal Year {0}").format(frappe.bold(self.fiscal_year)))
|
frappe.throw(_("Valid Upto date not in Fiscal Year {0}").format(frappe.bold(self.fiscal_year)))
|
||||||
|
|
||||||
|
def validate_supplier_against_section_code(self):
|
||||||
|
duplicate_certificate = frappe.db.get_value('Lower Deduction Certificate', {'supplier': self.supplier, 'section_code': self.section_code}, ['name'])
|
||||||
|
if duplicate_certificate:
|
||||||
|
certificate_link = get_link_to_form('Lower Deduction Certificate', duplicate_certificate)
|
||||||
|
frappe.throw(_("There is already a Lower Deduction Certificate {0} for Supplier {1} against Section Code {2}")
|
||||||
|
.format(certificate_link, frappe.bold(self.supplier), frappe.bold(self.section_code)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user