Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move VAT ID Check into a separate DocType #7

Merged
merged 28 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8ec3f62
feat: check_vat_approx
barredterra Mar 26, 2023
d2d4ec1
feat: doctype VAT ID Check
barredterra Mar 26, 2023
25285a3
feat: cronjob for checking VAT IDs
barredterra Mar 26, 2023
4610128
Merge remote-tracking branch 'upstream/version-14' into check_vat
barredterra Jun 12, 2023
ae4ed1d
feat(VAT ID Check): add status formatter
barredterra Jun 12, 2023
716d731
fix(VAT ID Check): list view fields
barredterra Jun 12, 2023
c4b6d61
fix(VAT ID Check): store formatted VAT id
barredterra Jun 12, 2023
ed0803d
feat(VAT ID Check): add to customer connections
barredterra Jun 12, 2023
4c270d5
feat(VAT ID Check): add translations
barredterra Jun 12, 2023
7f4ef21
feat!: remove VAT check button in Cust and Supp
barredterra Jun 12, 2023
ca85a78
fix(VAT ID Check): naming and translations
barredterra Jun 12, 2023
93e0ec3
docs: new VAT ID Check
barredterra Jun 12, 2023
75a6573
fix(VAT ID Check): make Customer VAT ID mandatory
barredterra Jun 13, 2023
d1d660c
feat: retry request
barredterra Jun 13, 2023
dee17c1
Merge branch 'version-14' into check_vat
barredterra Jun 13, 2023
7530464
feat(VAT ID Check): run async
barredterra Jun 13, 2023
9237c91
fix: increase max retry wait
barredterra Jun 13, 2023
91e7790
feat: check trader name and address
barredterra Jul 10, 2023
6320e31
fix: handle RetryError
barredterra Jul 10, 2023
823a590
feat: improve trader address and name matching
barredterra Jul 11, 2023
9a0cf1d
feat: handle invalid input, improve list view
barredterra Jul 11, 2023
287d28c
refactor: better parameter name
barredterra Jul 14, 2023
e9ee913
fix: log other errors
barredterra Jul 14, 2023
de809c5
fix: handle ValueError
barredterra Jul 14, 2023
aaf7dd3
feat: better doctype layout
barredterra Jul 14, 2023
9a6b1d4
feat: do less magic
barredterra Jul 14, 2023
140e9d0
Merge remote-tracking branch 'upstream/version-14' into check_vat
barredterra Jul 14, 2023
cbff07e
feat: remove custom records on uninstall
barredterra Jul 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ App to hold regional code for Germany, built on top of ERPNext.

- Validation of EU VAT IDs

![Validate EU VAT ID](docs/validate_vat_id.gif)
Automatically checks the validity of EU VAT IDs of all your customers every three months, or manually whenever you want.

![Validate EU VAT ID](docs/vat_check.png)

### HR

Expand Down
Binary file removed docs/validate_vat_id.gif
Binary file not shown.
Binary file added docs/vat_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions erpnext_germany/api.py
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.
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
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) {

// }
});
260 changes: 260 additions & 0 deletions erpnext_germany/erpnext_germany/doctype/vat_id_check/vat_id_check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
{
"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",
"trader_name",
"customer_address",
"trader_street",
"trader_postcode",
"trader_city",
"column_break_hmgxr",
"status",
"section_break_xljfy",
"company",
"column_break_scjlu",
"requester_vat_id",
"section_break_dowxn",
"is_valid",
"trader_name_match",
"trader_street_match",
"trader_postcode_match",
"trader_city_match",
"column_break_c4uco",
"request_id",
"actual_trader_name",
"actual_trader_address"
],
"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"
},
{
"fieldname": "column_break_c4uco",
"fieldtype": "Column Break"
},
{
"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\nUnavailable\nInvalid Input",
barredterra marked this conversation as resolved.
Show resolved Hide resolved
"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
}
barredterra marked this conversation as resolved.
Show resolved Hide resolved
],
"links": [],
"modified": "2023-07-11 15:44:25.409571",
"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"
}
Loading