-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from alyf-de/check_vat
feat: move VAT ID Check into a separate DocType
- Loading branch information
Showing
21 changed files
with
582 additions
and
88 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,20 +1,21 @@ | ||
import frappe | ||
from .utils.eu_vat import check_vat, parse_vat_id | ||
|
||
|
||
@frappe.whitelist() | ||
def validate_vat_id(vat_id: str) -> bool: | ||
"""Use the EU VAT checker to validate a VAT ID.""" | ||
from .utils.eu_vat import is_valid_eu_vat_id | ||
|
||
result = frappe.cache().hget("eu_vat_validation", vat_id, shared=True) | ||
if result is not None: | ||
return result | ||
is_valid = frappe.cache().hget("eu_vat_validation", vat_id, shared=True) | ||
if is_valid is not None: | ||
return is_valid | ||
|
||
try: | ||
result = is_valid_eu_vat_id(vat_id) | ||
frappe.cache().hset("eu_vat_validation", vat_id, result, shared=True) | ||
country_code, vat_number = parse_vat_id(vat_id) | ||
result = check_vat(country_code, vat_number) | ||
is_valid = result.valid | ||
frappe.cache().hset("eu_vat_validation", vat_id, is_valid, shared=True) | ||
except Exception: | ||
frappe.response["status_code"] = 501 | ||
result = None | ||
is_valid = None | ||
|
||
return result | ||
return is_valid |
Empty file.
9 changes: 9 additions & 0 deletions
9
erpnext_germany/erpnext_germany/doctype/vat_id_check/test_vat_id_check.py
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2023, ALYF GmbH and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
from frappe.tests.utils import FrappeTestCase | ||
|
||
|
||
class TestVATIDCheck(FrappeTestCase): | ||
pass |
8 changes: 8 additions & 0 deletions
8
erpnext_germany/erpnext_germany/doctype/vat_id_check/vat_id_check.js
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2023, ALYF GmbH and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('VAT ID Check', { | ||
// refresh: function(frm) { | ||
|
||
// } | ||
}); |
270 changes: 270 additions & 0 deletions
270
erpnext_germany/erpnext_germany/doctype/vat_id_check/vat_id_check.json
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 |
---|---|---|
@@ -0,0 +1,270 @@ | ||
{ | ||
"actions": [], | ||
"creation": "2023-03-26 18:28:14.770174", | ||
"default_view": "List", | ||
"doctype": "DocType", | ||
"editable_grid": 1, | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"customer", | ||
"customer_vat_id", | ||
"customer_address", | ||
"column_break_hmgxr", | ||
"status", | ||
"section_break_6ctcl", | ||
"trader_name", | ||
"trader_street", | ||
"trader_postcode", | ||
"trader_city", | ||
"column_break_cxvts", | ||
"trader_name_match", | ||
"trader_street_match", | ||
"trader_postcode_match", | ||
"trader_city_match", | ||
"column_break_cjvyk", | ||
"actual_trader_name", | ||
"actual_trader_address", | ||
"section_break_xljfy", | ||
"company", | ||
"column_break_scjlu", | ||
"requester_vat_id", | ||
"section_break_dowxn", | ||
"is_valid", | ||
"request_id" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "customer", | ||
"fieldtype": "Link", | ||
"in_standard_filter": 1, | ||
"label": "Customer", | ||
"options": "Customer", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fieldname": "column_break_hmgxr", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "request_id", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"label": "Request ID", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "is_valid", | ||
"fieldtype": "Check", | ||
"label": "Is Valid", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "company", | ||
"fieldtype": "Link", | ||
"label": "Company", | ||
"options": "Company", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fieldname": "section_break_xljfy", | ||
"fieldtype": "Section Break", | ||
"label": "Requester" | ||
}, | ||
{ | ||
"fieldname": "column_break_scjlu", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"depends_on": "eval:!doc.__islocal", | ||
"fieldname": "section_break_dowxn", | ||
"fieldtype": "Section Break", | ||
"label": "Result" | ||
}, | ||
{ | ||
"fetch_from": "customer.tax_id", | ||
"fetch_if_empty": 1, | ||
"fieldname": "customer_vat_id", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"in_standard_filter": 1, | ||
"label": "Customer VAT ID", | ||
"reqd": 1, | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fetch_from": "company.tax_id", | ||
"fetch_if_empty": 1, | ||
"fieldname": "requester_vat_id", | ||
"fieldtype": "Data", | ||
"label": "Requester VAT ID", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"default": "Planned", | ||
"fieldname": "status", | ||
"fieldtype": "Select", | ||
"label": "Status", | ||
"options": "Planned\nRunning\nCompleted\nService Unavailable\nInvalid Input\nError", | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "customer_address", | ||
"fieldtype": "Link", | ||
"label": "Customer Address", | ||
"options": "Address", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fetch_from": "customer.customer_name", | ||
"fetch_if_empty": 1, | ||
"fieldname": "trader_name", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"label": "Trader Name", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fetch_from": "customer_address.address_line1", | ||
"fetch_if_empty": 1, | ||
"fieldname": "trader_street", | ||
"fieldtype": "Data", | ||
"label": "Trader Street", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fetch_from": "customer_address.pincode", | ||
"fetch_if_empty": 1, | ||
"fieldname": "trader_postcode", | ||
"fieldtype": "Data", | ||
"label": "Trader Postcode", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fetch_from": "customer_address.city", | ||
"fetch_if_empty": 1, | ||
"fieldname": "trader_city", | ||
"fieldtype": "Data", | ||
"label": "Trader City", | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "trader_name_match", | ||
"fieldtype": "Check", | ||
"label": "Trader Name Match", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "trader_street_match", | ||
"fieldtype": "Check", | ||
"label": "Trader Street Match", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "trader_postcode_match", | ||
"fieldtype": "Check", | ||
"label": "Trader Postcode Match", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "trader_city_match", | ||
"fieldtype": "Check", | ||
"label": "Trader City Match", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "actual_trader_name", | ||
"fieldtype": "Data", | ||
"label": "Actual Trader Name", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "actual_trader_address", | ||
"fieldtype": "Small Text", | ||
"label": "Actual Trader Address", | ||
"no_copy": 1, | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "section_break_6ctcl", | ||
"fieldtype": "Section Break" | ||
}, | ||
{ | ||
"fieldname": "column_break_cxvts", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "column_break_cjvyk", | ||
"fieldtype": "Column Break" | ||
} | ||
], | ||
"links": [], | ||
"modified": "2023-07-14 19:27:17.103880", | ||
"modified_by": "Administrator", | ||
"module": "ERPNext Germany", | ||
"name": "VAT ID Check", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
}, | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "Sales Manager", | ||
"share": 1, | ||
"write": 1 | ||
}, | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "Sales Master Manager", | ||
"share": 1, | ||
"write": 1 | ||
}, | ||
{ | ||
"create": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "Sales User", | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "creation", | ||
"sort_order": "DESC", | ||
"states": [], | ||
"title_field": "customer_vat_id" | ||
} |
Oops, something went wrong.