Tax account — system description
Data model of the NAV itemised tax account mirror, the steps of synchronisation and PDF building, cleanup, the scheduled background job, permissions and the known scope gaps.
Overview
Mirror of the tax account (NAV M2M itemised tax account query) per company and tax year: a main row, items per tax type, and one statement PDF per tax year in the document centre. Items are loaded with the NAV sync button or a scheduled background job; there is no manual entry.
Data model
Table names carry the installation's own prefix in the database.
| Table | Purpose | Relation |
|---|---|---|
nav_tax_account | main row: company + tax year, source, balance | parent of items and documents |
nav_tax_account_item | item per tax type | tax type, value date, amount, tax type account number |
nav_tax_type | tax type master | the sync adds unknown names |
nav_tax_account_document | the module's link table for the statement PDF | kept beside the document centre link |
doc | the statement PDF in the document centre | object type nav_tax_account |
Process
- List: filter by company group and client (also a comma-separated company list), date (quick range from the master, default current year), tax type, technical items; sort by company name or tax year; documents from the document centre object links; unlinking requires the document centre
editpermission. - Sync: splits the requested period into calendar years for the filtered companies; per tax year a NAV M2M query (booked and pending items); adds the tax type name to the master, identifies the bank account from the master, mirrors the items of the affected tax types; logs the raw NAV answer for duplicate items. Then builds the statement PDF per tax year on the server with the manual template setting.
- PDF rebuild: from the main row's company, tax year and stored items; releases the old document(s) with the document centre cleanup operation, files the new one and writes it into the link table. The template setting is whitelisted and stored in a global setting (manual and scheduled mode separately).
- Delete: after a per-company content check, deletes the linked documents, then the main row; the response reports PDFs skipped for lack of permission and failed deletions.
- Purge all statements: physically deletes every linked PDF of every tax account within the user's scope from the storage together with the document centre relations, then the link rows; items are untouched. It first checks that the document centre model has the required methods; if not, nothing is deleted.
- Manual entry: saving always refuses after the permission check (mirrored data).
Background job
A per-company row of type taxaccount in the job queue; the catalogue-side controller performs the same query and mirroring with the catalogue-side model and generates a PDF with the scheduled template setting. Requirements: NAV M2M settings, the company's tax number, a storage rule (nav, otherwise document).
Permissions
- Layer 1: sync, PDF, delete, purge and save also require modify permission.
- Layer 2:
list,sync,pdf,delete,purgestatements,sendmail(empty mail link without it),debug(SQL and EXPLAIN);add/editonly for the refusing save. - Layer 3: the list filters on the permitted companies in the model query; delete checks per row, purge works on permitted tax accounts.
Known limitations
- The sync does not intersect the company identifiers coming from the filter with the content scope.
- The PDF rebuild does not check the content scope of the tax account identifier.