-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: move bank validation out of override class into hook (#142)
- Loading branch information
1 parent
bddc888
commit f07ad5a
Showing
13 changed files
with
70 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ module.exports = { | |
trailingComma: 'es5', | ||
useTabs: true, | ||
vueIndentScriptAndStyle: false, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
|
||
__version__ = '14.0.0' | ||
|
||
__version__ = "14.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,3 @@ | |
|
||
class TestCheckRun(unittest.TestCase): | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
# import frappe | ||
import unittest | ||
|
||
|
||
class TestCheckRunSettings(unittest.TestCase): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
from frappe import _ | ||
|
||
|
||
def get_data(): | ||
return [ | ||
{ | ||
"module_name": "Check Run", | ||
"color": "grey", | ||
"icon": "octicon octicon-file-directory", | ||
"type": "module", | ||
"label": _("Check Run") | ||
"label": _("Check Run"), | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
import frappe | ||
from frappe import _ | ||
from frappe.utils import cint, flt | ||
|
||
from erpnext.accounts.doctype.bank.bank import Bank | ||
|
||
@frappe.whitelist() | ||
def validate(doc, method=None): | ||
# Canadian banking institutions limit DFI Routing Numbers to 8 characters | ||
addresses = frappe.qb.DocType("Address") | ||
dls = frappe.qb.DocType("Dynamic Link") | ||
|
||
class CustomBank(Bank): | ||
def validate(self): | ||
# Canadian banking institutions limit DFI Routing Numbers to 8 characters | ||
addresses = frappe.qb.DocType('Address') | ||
dls = frappe.qb.DocType('Dynamic Link') | ||
countries_qb = ( | ||
frappe.qb.from_(addresses) | ||
.inner_join(dls) | ||
.on(addresses.name == dls.parent) | ||
.select(addresses.country) | ||
.where(dls.parenttype == "Address") | ||
.where(dls.link_doctype == "Bank") | ||
.where(dls.link_name == doc.name) | ||
) | ||
|
||
countries_qb = ( | ||
frappe.qb.from_(addresses) | ||
.inner_join(dls) | ||
.on(addresses.name == dls.parent) | ||
.select(addresses.country) | ||
.where(dls.parenttype == 'Address') | ||
.where(dls.link_doctype == 'Bank') | ||
.where(dls.link_name == self.name) | ||
) | ||
|
||
countries = frappe.db.sql( | ||
countries_qb, | ||
as_dict=True, | ||
pluck='country' | ||
) | ||
if 'Canada' in countries: | ||
if len(self.aba_number) > 8: | ||
frappe.throw(_("This Bank is linked to at least one Canadian address. Canadian banking institutions require the ABA Number must not exceed 8 characters.")) | ||
return | ||
countries = frappe.db.sql(countries_qb, as_dict=True, pluck="country") | ||
if "Canada" in countries: | ||
if len(doc.aba_number) > 8: | ||
frappe.throw( | ||
frappe._( | ||
"This Bank is linked to at least one Canadian address. Canadian banking institutions require the ABA Number must not exceed 8 characters." | ||
) | ||
) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ | |
"version-14" | ||
] | ||
} | ||
} | ||
} |