Initial commit: ws_vatcheck at v1.0.3
Includes the fix for the GR/EL VAT prefix bug that broke exemption for every Greek VAT number (in_array-on-values vs array_key_exists in CacheTaxManager/VatNumber, plus the missing use import in EuValidatorAdapter). Adds IMPROVEMENTS.txt with a checklist of features adopted from comparing against the vatchecker module (offline-fallback policy, failure logging, company-name check, configurable EU country list, per-product exclusion, GB/XI mapping, AJAX live validation, address-priority strategy). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
ws_vatcheck — planned improvements
|
||||
adapted from a comparison against the "vatchecker" module (Inform-All & Keraweb), 2026-09-11
|
||||
cache TTL (1 year) explicitly kept as-is, not on this list.
|
||||
|
||||
[ ] 1. Configurable VIES-offline fallback policy
|
||||
- Add a setting (e.g. VATCHECK_OFFLINE_MODE) with explicit modes instead of an
|
||||
implicit fail-closed default:
|
||||
- always mark invalid (current implicit behavior)
|
||||
- always mark valid
|
||||
- reuse last cached result, fall back to invalid if none
|
||||
- reuse last cached result, fall back to valid if none
|
||||
- Directly related to the GR/EL bug fixed this session: the fallback behavior
|
||||
should be an explicit, chosen policy, not an accidental side effect of
|
||||
whether an exception happens to get caught.
|
||||
|
||||
[ ] 2. Log every VIES check failure
|
||||
- Currently EuValidatorAdapter::checkAndStore() has no logging at all on
|
||||
failure (this silence was a big part of why the GR/EL bug took so long to
|
||||
diagnose). Add PrestaShopLogger::addLog(...) (or equivalent) whenever the
|
||||
Europa/Validator call throws, including the VAT number, country code, and
|
||||
the fault message.
|
||||
|
||||
[ ] 3. Company-name cross-check against VIES response
|
||||
- When VIES returns a company name for a validated VAT number, optionally
|
||||
compare it (normalized: lowercase, strip punctuation/legal-entity suffixes
|
||||
like bv/gmbh/ltd/nv/sa) against the address's company field. Make this
|
||||
togglable, since not all member states return a name.
|
||||
|
||||
[ ] 4. Configurable EU country allow-list
|
||||
- Replace hardcoded VatNumber::$euIso-driven behavior with an admin-configurable
|
||||
list of which EU countries are allowed to order VAT-free, similar to
|
||||
vatchecker's VATCHECKER_EU_COUNTRIES setting.
|
||||
|
||||
[ ] 5. Per-product VAT exclusion
|
||||
- Some products (e.g. certain digital services) may need to always charge VAT
|
||||
regardless of customer VAT-exempt status. Add a product-level flag/table
|
||||
(mirroring vatchecker_excluded_products) and consult it before applying the
|
||||
0% tax manager for a given product line.
|
||||
|
||||
[ ] 6. GB -> XI (Northern Ireland) mapping
|
||||
- VatNumber::$euIso has no entry at all for the UK/Northern Ireland. If this
|
||||
shop (or any future ws_vatcheck deployment) ships to Northern Ireland with an
|
||||
XI-prefixed VAT number, it will hit the same class of key/value bug already
|
||||
fixed for Greece. Add the mapping and cover it with the same key-based checks.
|
||||
|
||||
[ ] 7. Front-end AJAX live VAT validation
|
||||
- Add an AJAX front controller + JS so the address form validates the VAT
|
||||
number as the customer types, instead of only on form submit
|
||||
(hookActionValidateCustomerAddressForm). Mirrors vatchecker's ajax.php +
|
||||
front.js/front.css pattern. Improves UX and surfaces bad VAT numbers earlier.
|
||||
|
||||
[ ] 8. Configurable address-priority strategy
|
||||
- Add a setting for which address's VAT number is authoritative when invoice
|
||||
and delivery addresses differ (shipping only / invoice only / prioritize
|
||||
invoice / prioritize shipping), instead of relying on implicit PS tax-address
|
||||
resolution. Mirrors vatchecker's VATCHECKER_ADDRESS_SELECT.
|
||||
|
||||
Explicitly deferred / not adopting:
|
||||
- Shortening the 1-year cache TTL (Config::CACHE_VALIDITY) — decided to leave as-is.
|
||||
- Class overrides (Carrier/Product) as used by vatchecker — do not port this pattern;
|
||||
it conflicts with other modules that override the same core classes and is fragile
|
||||
across PS core upgrades. If shipping/product tax rule assignment ever needs
|
||||
behavior beyond what the taxManager hook covers, investigate a hook-based solution
|
||||
first before reaching for an override.
|
||||
- Legacy $this->l() / translations/{iso}.php system — ws_vatcheck already uses
|
||||
$this->trans() correctly per house convention for PS >= 1.7.6.0.
|
||||
Reference in New Issue
Block a user