Merge branch 'develop' into fixed-consolidated-report-not-working-develop

This commit is contained in:
Deepesh Garg 2021-02-15 16:35:31 +05:30 committed by GitHub
commit 47f5f4757a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 5 deletions

View File

@ -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 = {

View File

@ -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,20 @@ 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', '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) <= valid_upto:
return True
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
return False

View File

@ -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
pycryptodome==3.9.8