Tax number completion: on insert and by integrity fix

Completing invoice customer and supplier tax numbers from the partner master on the common invoice insert path, the integrity check finding, the fix endpoint and the rights.

Two paths complete an 8-digit tax number to the partner master's 11-digit number: the common invoice insert for every new invoice, and the fix endpoint of the integrity report for old invoices. Both apply the same safe condition.

New invoice

Dlbtinvoice::completeTaxhuFromMaster() runs on the common addInvoice() path for every source (NAV, invoice image, e-mail task, manual, scheduled). If the customer or supplier tax number is exactly 8 digits and the assigned partner's master holds 11 digits with the same first 8, the full form (for example 12345678-1-42) goes onto the invoice. Empty, different-core or already full values are left alone; on error the original stays and the error is logged.

Integrity check

  • Check code: partner_taxhu_full. Finding: an old invoice where the customer or supplier side holds only the core number while the partner master has the full number with the same first 8 digits; deleted invoices (status 9) excluded, within content scope.
  • The row shows the amount and a link to open the invoice (with invoice list).
  • Scheduling: a daily 01:00 template in the scheduled job queue (integrity_check).

Fix endpoint

  1. Right (report/integrity fixtaxhu).
  2. Key filtering (invoice ID and side); empty: "Select at least one fixable row (tax number completion)."
  3. Content scope from the central filter.
  4. The invoice model's fixPartnerTaxFull() re-checks the same condition at the moment of fixing, writes only then, and logs the change (old → new).
  5. Response: counts of completed and skipped rows, or "Nothing was changed …".

Data

Table names carry the installation's own prefix in the database. Written fields: invoice.customer_taxhu, invoice.supplier_taxhu (owner: the invoice model; inserts only through addInvoice()). Read: company.company_taxhu. Check master: integrity_check; scheduling: cron_queue.

Permissions

  • report/integrity list: reading the report.
  • report/integrity fixtaxhu (base package): fixing. The list right grants no write.
  • Content scope: by the invoice's client.