From 3c55463b4b86e9715e194d8c8268ee6190a5d30c Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 7 Jan 2021 12:41:44 +0530 Subject: [PATCH 1/4] fix: validation for ldc against supplier and section code --- .../lower_deduction_certificate.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py index e8a8ed8750..d4e7c12362 100644 --- a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py +++ b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py @@ -5,12 +5,16 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import getdate +from frappe.utils import getdate, get_link_to_form from frappe.model.document import Document from erpnext.accounts.utils import get_fiscal_year class LowerDeductionCertificate(Document): 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): frappe.throw(_("Valid Upto date cannot be before Valid From date")) @@ -24,3 +28,10 @@ class LowerDeductionCertificate(Document): <= fiscal_year.year_end_date): 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))) + From f1107598976d5584beaa3011654e78159b09b618 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Wed, 20 Jan 2021 18:12:48 +0530 Subject: [PATCH 2/4] fix: date validation --- .../lower_deduction_certificate.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py index d4e7c12362..b0a656af30 100644 --- a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py +++ b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py @@ -29,9 +29,19 @@ class LowerDeductionCertificate(Document): 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}") + duplicate_certificate = frappe.db.get_value('Lower Deduction Certificate', {'supplier': self.supplier, 'section_code': self.section_code}, ['name', 'valid_from', 'valid_upto'], as_dict=True) + if duplicate_certificate and self.are_dates_overlapping(duplicate_certificate): + certificate_link = get_link_to_form('Lower Deduction Certificate', duplicate_certificate.name) + frappe.throw(_("There is already a valid Lower Deduction Certificate {0} for Supplier {1} against Section Code {2} for this time period.") .format(certificate_link, frappe.bold(self.supplier), frappe.bold(self.section_code))) + def are_dates_overlapping(self,duplicate_certificate): + valid_from = duplicate_certificate.valid_from + valid_upto = duplicate_certificate.valid_upto + if valid_from <= getdate(self.valid_from) and getdate(self.valid_from) <= valid_upto: + return True + elif valid_from <= getdate(self.valid_upto) and getdate(self.valid_upto) <= valid_upto: + return True + elif getdate(self.valid_from) <= valid_from and valid_upto <= getdate(self.valid_upto): + return True + return False \ No newline at end of file From 1ab95413beacf98f7f7627ee2f8b6a3a2b0930ce Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 9 Feb 2021 17:35:17 +0530 Subject: [PATCH 3/4] fix: conditions simplified --- .../lower_deduction_certificate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py index b0a656af30..ad60db0559 100644 --- a/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py +++ b/erpnext/regional/doctype/lower_deduction_certificate/lower_deduction_certificate.py @@ -38,9 +38,9 @@ class LowerDeductionCertificate(Document): def are_dates_overlapping(self,duplicate_certificate): valid_from = duplicate_certificate.valid_from valid_upto = duplicate_certificate.valid_upto - if valid_from <= getdate(self.valid_from) and getdate(self.valid_from) <= valid_upto: + if valid_from <= getdate(self.valid_from) <= valid_upto: return True - elif valid_from <= getdate(self.valid_upto) and getdate(self.valid_upto) <= valid_upto: + elif valid_from <= getdate(self.valid_upto) <= valid_upto: return True elif getdate(self.valid_from) <= valid_from and valid_upto <= getdate(self.valid_upto): return True From fd4e7bdbb11793bf9b809edd2097c9386a0ec8d1 Mon Sep 17 00:00:00 2001 From: Richard Case <64409021+casesolved-co-uk@users.noreply.github.com> Date: Mon, 15 Feb 2021 06:28:27 +0000 Subject: [PATCH 4/4] fix: plaid client version to support latest API (#24531) --- .../doctype/plaid_settings/plaid_connector.py | 4 ++-- requirements.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py index 66d0e5f77d..5f990cdd03 100644 --- a/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py +++ b/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py @@ -20,7 +20,7 @@ class PlaidConnector(): client_id=self.settings.plaid_client_id, secret=self.settings.get_password("plaid_secret"), environment=self.settings.plaid_env, - api_version="2019-05-29" + api_version="2020-09-14" ) def get_access_token(self, public_token): @@ -29,7 +29,7 @@ class PlaidConnector(): response = self.client.Item.public_token.exchange(public_token) access_token = response["access_token"] return access_token - + def get_token_request(self, update_mode=False): country_codes = ["US", "CA", "FR", "IE", "NL", "ES", "GB"] if self.settings.enable_european_access else ["US", "CA"] args = { diff --git a/requirements.txt b/requirements.txt index 4511aa54d8..5a352364b6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ frappe gocardless-pro==1.11.0 googlemaps==3.1.1 pandas>=1.0.5 -plaid-python==6.0.0 +plaid-python>=7.0.0 pycountry==19.8.18 PyGithub==1.44.1 python-stdnum==1.12 @@ -12,4 +12,4 @@ taxjar==1.9.0 tweepy==3.8.0 Unidecode==1.1.1 WooCommerce==2.1.1 -pycryptodome==3.9.8 \ No newline at end of file +pycryptodome==3.9.8