pH-7 / eu-vat-validator

:moneybag: A simple and clean PHP library that validates EU VAT registration numbers against the central ec.europa.eu database (using the official europa API) :eu:
https://github.com/pH-7/eu-vat-validator
GNU General Public License v3.0
93 stars 17 forks source link

Can you help me pH-7 #11

Open ghost opened 1 year ago

ghost commented 1 year ago

i'm trying to write prestashop in back-end and front. VAT number and validate like you wrote. and also siret france (KvK number NL) and eng Chamber of combers.

SIRET SIRET **What is this? prestashop_1.7.8.8\prestashop\app\Resources\translations\default\AdminOrderscustomersFeature.xlf location** Shop registration information (e.g. SIRET or RCS). Shop registration information (e.g. SIRET or RCS). Line: 464 Same : **prestashop_1.7.8.8\prestashop\app\Resources\translations\default\AdminShopparametersHelp.xlf** Identification number Identification number Line: 156 Comment: Please localize this string with the applicable registration number type in your country. For example : "SIRET" in France and "Código fiscal" in Spain. ?? **prestashop_1.7.8.8\prestashop\app\Resources\translations\default\ShopFormsLabels.xlf** /** @var string WebSite * */ public $website; /** @var string Company */ public $company; /** @var string SIRET */ public $siret; /** @var string APE */ public $ape; ~~ 'website' => ['type' => self::TYPE_STRING, 'validate' => 'isUrl'], 'company' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName'], 'siret' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName'], 'ape' => ['type' => self::TYPE_STRING, 'validate' => 'isApe'], **file: prestashop_1.7.8.8\prestashop\classes\Customer.php** $format['siret'] = (new FormField()) ->setName('siret') ->setType('text') ->setLabel($this->translator->trans( // Please localize this string with the applicable registration number type in your country. For example : "SIRET" in France and "Código fiscal" in Spain. 'Identification number', [], 'Shop.Forms.Labels' )); **prestashop_1.7.8.8\prestashop\classes\form\CustomerFormatter.php** **i tink here is the best place for your script in site? location: prestashop_1.7.8.8\prestashop\classes\Validate.php** /** * Validate SIRET Code. * * @param string $siret SIRET Code * * @return bool Return true if is valid */ public static function isSiret($siret) { if (Tools::strlen($siret) != 14) { return false; } $sum = 0; for ($i = 0; $i != 14; ++$i) { $tmp = ((($i + 1) % 2) + 1) * (int) ($siret[$i]); if ($tmp >= 10) { $tmp -= 9; } $sum += $tmp; } return $sum % 10 === 0; } /** * Validate APE Code. * * @param string $ape APE Code * * @return bool Return true if is valid */ public static function isApe($ape) { return (bool) preg_match('/^[0-9]{3,4}[a-zA-Z]{1}$/s', $ape); } **Here is the not working place of shop location :prestashop_1.7.8.8\prestashop\controllers\admin\AdminStoresController.php** doesn't show frontside shop?? and no valadation and now VAT number . 'PS_SHOP_DETAILS' => [ 'title' => $this->trans('Registration number', [], 'Admin.Shopparameters.Feature'), 'hint' => $this->trans('Shop registration information (e.g. SIRET or RCS).', [], 'Admin.Shopparameters.Help'), 'validation' => 'isGenericName', 'type' => 'textarea', 'cols' => 30, 'rows' => 5, **~~later fax ??** 'PS_SHOP_FAX' => [ 'title' => $this->trans('Fax', [], 'Admin.Global'), 'validation' => 'isGenericName', 'type' => 'text', **Maybe some countries but i like to see : KvK-nummer: 32147382 (siret) frans (8 NL) (10 BE) (outher country??) BTW-identificatienummer Nederland: NL820471616B01 or BTW-identificatienummer België: BE0824148721 etc. Bank-number : NL21 INGB 0004546905 or Geregistreerd KvK nummer: 08137001 IBAN: NL21 INGB 0004546905 BTW: NL001947572B19** **prestashop_1.7.8.8\prestashop\install\data\db_structure.sql** for data base but now VAT number?? `company` varchar(255), `siret` varchar(14), `ape` varchar(5), **prestashop_1.7.8.8\prestashop\src\Adapter\Customer\CommandHandler\AddCustomerHandler.php** they also got B2B but notting Sire frontend (yep mix drop box not nice by information store) No VAT number // fill b2b customer fields $customer->company = $command->getCompanyName(); $customer->siret = $command->getSiretCode(); $customer->ape = $apeCode; **prestashop_1.7.8.8\prestashop\vendor\prestashop\translationtools-bundle\Translation\Fixtures\fields_catalogue.php** first page siret and vat_number But what is page? I'm maybe not long reading these scrips and structure's like 4 mounts? $_FIELDS['Customer_342f5c77ed008542e78094607ce1f7f3'] = 'firstname'; $_FIELDS['Customer_8ad75c5a8821cc294f189181722acb56'] = 'lastname'; $_FIELDS['Customer_cf673f7ee88828c9fb8f6acf2cb08403'] = 'birthday'; $_FIELDS['Customer_0c83f57c786a0b4a39efab23731c7ebc'] = 'email'; $_FIELDS['Customer_d1befa03c79ca0b84ecc488dea96bc68'] = 'website'; $_FIELDS['Customer_93c731f1c3a84ef05cd54d044c379eaa'] = 'company'; $_FIELDS['Customer_01b0fd027f8764f9c069506b8de8bf2e'] = 'siret'; $_FIELDS['Warehouse_b8af13ea9c8fe890c9979a1fa8dbde22'] = 'reference'; $_FIELDS['Warehouse_b068931cc450442b63f5b3d276ea4297'] = 'name'; $_FIELDS['Warehouse_23c3b4d168a45ef94635494ce42eb658'] = 'management_type'; $_FIELDS['Country_213ecf1210f43736b6d4997fcfa27954'] = 'iso_code'; $_FIELDS['Country_b068931cc450442b63f5b3d276ea4297'] = 'name'; $_FIELDS['Country_37f577d6d447ff0743d74245446223b3'] = 'zip_code_format'; $_FIELDS['State_213ecf1210f43736b6d4997fcfa27954'] = 'iso_code'; $_FIELDS['State_b068931cc450442b63f5b3d276ea4297'] = 'name'; $_FIELDS['Address_93c731f1c3a84ef05cd54d044c379eaa'] = 'company'; $_FIELDS['Address_8ad75c5a8821cc294f189181722acb56'] = 'lastname'; $_FIELDS['Address_342f5c77ed008542e78094607ce1f7f3'] = 'firstname'; $_FIELDS['Address_81e70cb16ec45f5ab19bb6638e8e6c2d'] = 'address1'; $_FIELDS['Address_f669f8e9f6599d0dfcd613bc6e2f347e'] = 'address2'; $_FIELDS['Address_e90ebd9556fa4031171f043013794b61'] = 'postcode'; $_FIELDS['Address_4ed5d2eaed1a1fadcc41ad1d58ed603e'] = 'city'; $_FIELDS['Address_795f3202b17cb6bc3d4b771d8c6c9eaf'] = 'other'; $_FIELDS['Address_f7a42fe7211f98ac7a60a285ac3a9e87'] = 'phone'; $_FIELDS['Address_2df2ca5cf808744c2977e4073f6b59c8'] = 'phone_mobile'; $_FIELDS['Address_eec0a9661213354fa7a52519eea3f827'] = 'vat_number'; $_FIELDS['Address_d56f5e97524d5d1ad77ec197ae11dad0'] = 'dni'; $catalogue = new \Symfony\Component\Translation\MessageCatalogue(); function addEntry($catalogue, $original, $translation, $domain = 'messages') { $catalogue->set($original, $translation, $domain); $catalogue->setMetadata($original, ['line' => 0, 'file' => __FILE__], $domain); } foreach ($_FIELDS as $key => $value) { addEntry($catalogue, $value, $value, reset(explode('_', $key))); } **rest VAT numbers look up:** prestashop_1.7.8.8\prestashop\app\Resources\translations\default\AdminOrderscustomersFeature.xlf (2 overeenkomsten) Regel 1216: VAT number Regel 1217: VAT number prestashop_1.7.8.8\prestashop\app\Resources\translations\default\ShopFormsLabels.xlf (2 overeenkomsten) Regel 51: VAT number Regel 52: VAT number prestashop_1.7.8.8\prestashop\app\Resources\translations\default\ShopPdf.xlf (2 overeenkomsten) Regel 425: VAT Number Regel 426: VAT Number prestashop_1.7.8.8\prestashop\classes\Address.php (1 overeenkomsten) Regel 90: /** @var string VAT number */ prestashop_1.7.8.8\prestashop\classes\form\CustomerAddressFormatter.php (1 overeenkomsten) Regel 229: return $this->translator->trans('VAT number', [], 'Shop.Forms.Labels'); prestashop_1.7.8.8\prestashop\controllers\admin\AdminImportController.php (1 overeenkomsten) Regel 442: 'vat_number' => ['label' => $this->trans('VAT number', [], 'Admin.Orderscustomers.Feature')], prestashop_1.7.8.8\prestashop\docs\CHANGELOG.txt (2 overeenkomsten) Regel 2046: - #22841: Bring back vat number to address on order view (by @kpodemski) Regel 5851: - #8138: Fix tax calculation when vat number is used prestashop_1.7.8.8\prestashop\docs\csv_import\addresses_import.csv (1 overeenkomsten) Regel 1: Address ID;Alias*;Active (0/1);Customer e-mail*;Customer ID;Manufacturer;Supplier;Company;Lastname*;Firstname*;Address 1*;Address 2;Zipcode*;City*;Country*;State;Other;Phone;Mobile Phone;VAT number;DNI prestashop_1.7.8.8\prestashop\pdf\invoice.summary-tab.tpl (1 overeenkomsten) Regel 32: {l s='VAT Number' d='Shop.Pdf' pdf='true'} prestashop_1.7.8.8\prestashop\pdf\order-slip.summary-tab.tpl (1 overeenkomsten) Regel 30: {l s='VAT Number' d='Shop.Pdf' pdf='true'} prestashop_1.7.8.8\prestashop\src\Core\Domain\Address\Configuration\AddressConstraint.php (1 overeenkomsten) Regel 80: * Maximum length for VAT number (value is constrained by database) prestashop_1.7.8.8\prestashop\src\Core\Import\EntityField\Provider\AddressFieldsProvider.php (1 overeenkomsten) Regel 76: new EntityField('vat_number', $this->trans('VAT number', 'Admin.Orderscustomers.Feature')), prestashop_1.7.8.8\prestashop\src\PrestaShopBundle\Form\Admin\Sell\Address\CustomerAddressType.php (1 overeenkomsten) Regel 257: 'label' => $this->trans('VAT number', 'Admin.Orderscustomers.Feature'), Where can i place your script ? Kind reagards Imke.