coopcycle / coopcycle-web

Logistics & marketplace platform. Only for worker-owned business.
https://coopcycle.org
Other
567 stars 129 forks source link

Validate SIRET number is an establishment number, not head office #4656

Closed alexsegura closed 1 month ago

alexsegura commented 1 month ago

When sending SIRETs to Edenred for sync, it sometimes fails because people configure the head office's number, which is unknown to Edenred.

We should use one of the SIRENE APIs to validate the SIRET number.

r0xsh commented 1 month ago

It can be validated without an API call, as SIRET numbers consist of 14 digits and SIREN numbers contain 9 digits. Both SIRET and SIREN include a control digit that can be verified using a checksum algorithm, which can be found here: https://portal.hardis-group.com/doccenter/pages/viewpage.action?pageId=120357227.

alexsegura commented 1 month ago

It's already validated using the Luhn algorithm. But this does not indicate if the number is head office or not.

https://github.com/coopcycle/coopcycle-web/blob/a35e4d323ac53115abeac2e62f4a025b463bcd86/src/Form/LocalBusinessType.php#L173