Skip to content

What a Data Purge Does ​

A data purge removes the detail of old, closed years from the database up to a cut-off date, while keeping every balance the business still depends on. After ten or fifteen years a busy installation holds hundreds of millions of rows of old ledger, stock and cost transactions; reports slow down, backups grow, and every reprocessing tool has more history to walk. The purge replaces that history with a small set of opening balances, the way a bank can replace ten years of statements with one certified balance and send the old statements to the archive room.

This page explains what happens to each kind of data. The other pages of this section explain how to prepare, configure, check, run, resume and verify a purge.

A purge can not be undone

Deleted documents and transactions come back only from a backup. Every purge starts with a fresh backup of the main database and of the archive database, taken after the last change.

The cut-off and the purge period ​

The cut-off is not typed as a date. It is the end date of a special fiscal period whose Period Type is Purge Period. You add that period as the last period of the last fiscal year you want to purge, with its start date and end date both equal to the year's end date. Everything dated on or before that day is the purged range.

The purge period has a second job: the roll-up documents that carry the balances forward are posted into it. Because every later purge leaves the purge periods alone, those roll-ups survive the next cycle and the one after it.

A purge always covers the whole database: every company (legal entity) at once. Some stock ages and debt ages tables are shared by all companies, so purging one company alone would damage the others. The roll-up documents are still created per company, so each company keeps its own balances.

What happens to each kind of data ​

DataWhat the purge does
Committed documents dated in the rangeEach document type gets one of three behaviours: copy to the archive database and delete, delete only, or mark as purged. See The three behaviours below.
Ledger transactions, dimension balances, quantity, serial and reservation transactions, cost transactions (average or FIFO), stock ages, debt lines and their matchingsDeleted up to the cut-off. Each family can also be copied to the archive database first, by its own option on the configuration.
Actions history and version historyDeleted up to the end of the cut-off day, when Delete Actions History and Delete Version History are ticked (both are ticked by default).
User notifications and pending tasksAlways deleted up to the end of the cut-off day.
Balances, stock on hand and cost at the cut-offRestated on new roll-up documents, Purge Journal and Purge Stock Receipt, dated on the cut-off day inside the purge period.
Documents dated after the cut-off, and their transactionsUntouched.
Drafts (uncommitted documents) of any dateUntouched. The purge only processes committed documents.
Master files (customers, items, accounts, warehouses, …)Untouched.
Roll-up documents of an earlier purgeUntouched, so balances stay continuous across purge cycles.

The three behaviours ​

Every document type in the range is handled in one of three ways. You choose them on the Purge Configuration screen.

  • Copy to the archive and delete. The document's header and lines are copied to the archive database, then deleted from the main database. Only ten document types support it: sales and purchase invoices and returns, stock issues and receipts, point of sale invoices and returns, and car sales invoices and returns.
  • Delete only. The document is deleted from the main database without a copy.
  • Mark as purged. The document stays in the main database, flagged as purged. You can still open and read it, but it can no longer be changed, and its ledger, stock and cost effects are gone like everybody else's in the range. This is the behaviour of every type you did not list, because it is the only one that destroys nothing.

When a document is deleted, the purge also deletes its attachments, its approval cases, its aliases and its system entries, and it empties every link that a surviving record had to it (for example, a return dated after the cut-off that names a deleted invoice keeps its own data, but the link to the invoice becomes empty). The highest document number of every book and prefix is kept, so numbering continues where it was.

What is carried forward ​

The purge only restates what the deleted rows prove. It does not create balances and it does not repair old mistakes.

Account balances: the Purge Journal ​

For every company with balances in the range, the purge builds Purge Journal documents that restate the balance of every account, subsidiary (customer, supplier, …) and dimension at the cut-off. The trial balance at the cut-off is therefore the same before and after the purge. A journal holds at most 1,000 lines; a company that needs more gets several journals, and each of them is balanced by one line on the Purge Roll-up Clearing Account of the journal's term. The lines on that account cancel each other out across the company's journals, so the account ends at zero (or at the old imbalance of the range, if the range itself did not balance).

Roll-up journals and receipts are coded from the configuration's code and a running number, and their From Document is the purge configuration. Nobody can save or delete them by hand.

Stock on hand and cost: the Purge Stock Receipt ​

For every company and item configuration, Purge Stock Receipt documents restate the quantity on hand at the cut-off for each item and dimension (warehouse, locator, lot, …) together with its cost.

  • Under average costing, each on-hand line carries its share of the cost. A group that is negative at the cut-off is carried as a negative line, and value that sits on a key with no stock (average costing moves value between warehouses of one cost dimension) is carried on a line with zero quantity, so the stock valuation does not change.
  • Under FIFO costing, nothing is averaged. The remaining FIFO layers stay exactly as they were, with their own quantity, unit cost, date and dimensions, and are moved under the roll-up receipts. Issue lines that are still waiting for a layer at the cut-off are kept too (see Limitations).

Customer and supplier open amounts ​

The debt lines of the range are deleted. A settlement that links a purged line to a surviving one is undone, and the surviving line gets its open amount back. The balance of each customer and supplier is restated on the roll-up journal, and the debt ages engine matches it again. The open amount per account and subsidiary is the same before and after the purge; in the ageing, the old open invoices show as the roll-up amount dated on the cut-off day.

Stock ages ​

Stock ages rows of the range are deleted and new ages lines are created for the roll-up receipts, followed by a rematch of each affected item. If the range holds no stock ages history at all (stock ages were switched on after the cut-off), no ages lines are created.

After the purge the range stays closed ​

Once a purge has started, the purged range is protected for good, also after the purge has finished:

  • A document dated in the range can not be saved, committed, deleted or run through an entity flow, and no request can be sent for it. The user sees Can not operate on this document because its fiscal period {0} is inside a purged range — «لا يمكن التعامل مع هذا المستند لأن فترته المالية {0} تقع ضمن نطاق تم حذف بياناته».
  • A document marked as purged answers Can not operate on entity {0} because it was purged — «لا يمكن إجراء عمليات على السجل {0} لأنه محذوف ضمن حذف البيانات».
  • A purge can only move forward: a later purge must have a later cut-off, and no two configurations can share a purge period.

What a purge is not ​

  • It is not a repair tool. Old inconsistencies (a cost transaction whose stock effect was deleted, a stock shortage never received, debt lines that never matched the ledger) are either carried forward as they are or make the pre-flight check refuse the run. They are never silently corrected.
  • It is not a way to remove one company's data. It always covers every company.
  • It does not shrink the database files. The space it frees is reused by new data; see Database space.
  • It does not work with replication. Replication must be switched off for the purge; afterwards, sites get a copy of the purged database.
  • It does not delete master files, and it never touches anything dated after the cut-off: the years that are still open go on exactly as before.