Address and company lookup
Three features that help to enter data (Exment 7.3.0 or later):
- Postal code to address: type a postal code, and the address columns are filled
- Find a company by corporate number: search a company by its name or corporate number, and fill its name and address into columns
- Check an invoice registration number: on save, check that the registration number is registered now
All of them are off at first. Turn on the ones you use in "Admin settings → Feature Management". Their settings are on the page "Address and company lookup" (system administrators only, shown while one of them is on).
About the Web-API of the National Tax Agency "Find a company by corporate number" and "Check an invoice registration number" use the Corporate Number Web-API and the Qualified Invoice Issuer Web-API of the National Tax Agency (NTA) of Japan. This service uses the NTA's Web-API, but the content of the service is not guaranteed by the NTA.
1. Postal code to address
- Turn on "Postal code to address" in Feature Management
- In the settings of "Address and company lookup", choose where the postal codes come from
- Japan Post data imported on the server (recommended): nothing is asked outside while you type. Once imported, it works without the internet
- Japan Post postal code and digital address API: needs a registration with Japan Post. Enter the client ID, the secret key and the IP address of the registered server. Digital addresses can be looked up too
The Japan Post postal-code API client has not yet been tested against the real service. Check that it works with your registered account before you rely on it.
- To use the data on the server, run this command on the server once to import it
php artisan exment:postal-import- To add the postal codes of large offices, add
--officeor turn on "Also import the office postal codes" in the settings - On a server without the internet, download
ken_all.zip(andjigyosyo.zip) from the Japan Post site on another computer, and import themphp artisan exment:postal-import --file=ken_all.zip --file=jigyosyo.zip - With "Update every month" on, the new data is fetched on the morning of the 3rd of each month and replaces the old one when it changed (the scheduler's cron is needed)
- "Import now" on the settings page starts it too (system administrators only, when the data on the server is used). One import runs at a time, and the page says so while it runs
- Backup: the rows of the postal code data are not in a backup (only the table is). After a restore, import them again
- To add the postal codes of large offices, add
- In the settings of a text column, set "Postal code", and choose the columns for the prefecture, city and town (or the whole address)
- On the data page, type 7 digits (with or without a hyphen, also full-width) in the postal code column, and the chosen columns are filled
- When a postal code has several towns, a list to choose from is shown
- "Find from address" finds a postal code from a part of an address
2. Find a company by corporate number
- Register an application ID for the NTA "Corporate Number Web-API" (free). If you also check invoice numbers, use an application ID for invoices
- Turn on "Find a company by corporate number" in Feature Management, and enter the application ID in the settings of "Address and company lookup". The ID is stored encrypted and never shown again
- In the settings of the text column of a company name or corporate number, set "Company lookup". Choose what this column holds (name or number), and the columns for the name, furigana, corporate number, postal code, prefecture, city, street and address
- On the data page, press "Find a company" and search by a part of the name or the 13-digit corporate number. Choose one of the candidates (name, address, number, closed), and the chosen columns are filled
- What you type is sent from the server to the NTA, never from the browser
- The check digit of a 13-digit corporate number is checked first (no request for a wrong number)
3. Check an invoice registration number
- Turn on "Check an invoice registration number" in Feature Management, and enter the application ID (for invoices)
- In the settings of the text column of the registration number, set "Invoice registration number". Choose what happens when it does not match (warn / do not save), and the column of the name to compare
- On save, it checks
- the form: T and 13 digits
- that it is registered now (not cancelled or expired)
- that the name matches (full-width and half-width, spaces, and "(株)" versus "株式会社" are not compared)
- When the NTA cannot be asked (no ID, no answer, the request limit), the save is never refused, even with "do not save": it only warns
4. Settings (.env)
| Name | Default | What |
|---|---|---|
EXMENT_LOOKUP_TIMEOUT | 8 | Seconds to wait for an API |
EXMENT_LOOKUP_CACHE_SECONDS | 86400 | Seconds an API answer is kept |
EXMENT_LOOKUP_PER_MINUTE | 30 | Searches per user per minute |
EXMENT_LOOKUP_POSTAL_MIN_ROWS | 100000 | Data with fewer rows is not imported |
EXMENT_LOOKUP_POSTAL_KEN_ALL_URL / EXMENT_LOOKUP_POSTAL_OFFICE_URL | The official Japan Post URLs | Where the postal code data comes from |
EXMENT_LOOKUP_JAPANPOST_API_URL | https://api.da.pf.japanpost.jp/api/v2 | Japan Post API |
EXMENT_LOOKUP_HOUJIN_API_URL / EXMENT_LOOKUP_INVOICE_API_URL | The official NTA URLs (v4 / v1) | NTA Web-API |
5. Safety
- Only the server asks Japan Post and the NTA. The IDs and secret keys are never in a page, an answer or a log
- Only signed-in users can search, with a limit per user per minute (
EXMENT_LOOKUP_PER_MINUTE) - While a feature is off, its endpoints answer 404 and its column options are hidden (settings already made are kept)
