The Purge Configuration Screen
A Purge Configuration record describes one purge: how far back it goes, what it copies to the archive, how each document type is treated, and which books and terms the roll-up documents use. You create one record per cut-off. Once its purge has started, the record becomes the permanent proof of how far the database was purged, so it can no longer be edited or deleted.
Open it from Administration → Purge Documents → Purge Configuration. The same menu group lists the roll-up documents, Purge Journal and Purge Stock Receipt.
The actions
| Action | What it does |
|---|---|
| Run Purge | With Dry Run (preview only) ticked, writes a preview of what would be deleted into Last Run Log and changes nothing. With it cleared, starts the real purge after a single confirmation. Prefer the Purge Monitor for the real run; see the warning below. |
| Populate Purge Grids | Fills the two document grids with a suggestion for every document type that has documents in the range. Nothing is saved until you save the record. |
| Create Missing Indexes | Creates the indexes the purge needs and drops the old foreign keys that slow it down. Needs the admin user signed in through the Namasoft CRM. See Indexes and old foreign keys. |
| Purge Monitor | Opens the Purge Monitor on this configuration. |
Run the real purge from the Purge Monitor
Run Purge on this screen starts the real purge as soon as Dry Run (preview only) is cleared, after only the generic question Are you sure you want to continue?. The Purge Monitor's Run purge asks for more: a dry run since the server started, a pre-flight that did not refuse, a tick that a backup was taken, and the configuration's code typed in full. Keep Dry Run (preview only) ticked while you prepare, and clear it only right before you run from the monitor.
The header
| Field | What it means |
|---|---|
| Up To Period | The cut-off. Only fiscal periods of type Purge Period can be chosen. Every committed document and transaction dated on or before its end date is purged. It must end before today, it must be later than the cut-off of every purge that has already started, and no other configuration may use the same period, except a supplementary run. |
| Dry Run (preview only) | Ticked by default. While ticked, the configuration can only be previewed: Run Purge writes a preview, and the monitor refuses Run purge. Clear it and save to run for real. |
| Min Records To Suggest Delete | Used only by Populate Purge Grids: a document type that can not be archived is suggested for deletion only when it has at least this many documents in the range. Default 10,000. Smaller types are left out of the grids, so they are marked as purged. |
| Copy Purged Cost Records To Archive DB | Copy the cost transactions (average or FIFO) to the archive database before deleting them. |
| Copy Purged Quantity Records To Archive DB | Same for the quantity, serial and reservation transactions. |
| Copy Purged Accounting Records To Archive DB | Same for the ledger transactions and dimension balances. |
| Copy Purged Stock Ages To Archive DB | Same for the stock ages rows and their matchings. |
| Copy Purged Debt Ages To Archive DB | Same for the debt lines and their matchings. |
| Delete Actions History | Delete the actions history up to the end of the cut-off day. |
| Delete Version History | Delete the saved earlier versions of records up to the end of the cut-off day. |
| Delete Report Run Log | Delete the log of report runs up to the end of the cut-off day. Cleared by default. |
| Delete Expired Or Fully Redeemed Reward Points | Delete the reward point entries that can no longer change a customer's balance (see Reward points). Cleared by default. |
| Delete Executed E-Commerce Integration Requests | Delete the item, price and quantity requests that were already sent to the online store, up to the end of the cut-off day. Requests that are still waiting or failed are kept. Cleared by default. |
| Delete Attendance Lines | Delete the attendance lines up to the end of the cut-off day. They are usually small and hold history people still ask about, so leave this cleared unless the customer asks for it. Cleared by default. |
| Supplementary Run For A Purged Period (documents and system tables only) | Makes this record a second pass over a period that was already purged (see A supplementary run). Cleared by default. |
| Purge Status | Where the purge stands (see Statuses). Read-only. |
| Total Batches, Executed Batches, Failed Batches | The size and progress of the run, counted in batches (one per document type, one per module, and the clean-up). Read-only. |
| Last Run Log | The latest preview, the reason of the latest failure, or, once finished, the audit of the run: cut-off, who started it, and the rows processed per batch with the behaviour each document type was purged with. |
| Journal Entries Book, Journal Entries Term | Book and term of the Purge Journal documents. Both must be system records for the type Purge Journal. The term is required when there is a balance to roll up, and it carries the Purge Roll-up Clearing Account. |
| Stock Receipt Book, Stock Receipt Term | Book and term of the Purge Stock Receipt documents. Both are required and must be system records for the type Purge Stock Receipt. |
All copy options and both history options are ticked by default. The four delete options after them, and the supplementary run, are cleared by default.
The system tables
Around the documents and their transactions the database keeps rows that only exist to serve them. Once the documents of the range are gone these rows serve nothing, and on a large database they are a big share of what is left: on one customer the requests alone were more than a third of the database after the purge. The clean-up at the end of every run removes them.
Removed in every run, with no option, because nothing can read them any more:
- the notifications and the pending tasks up to the end of the cut-off day;
- the processed ledger and inventory requests of the purged periods, with their processing status. A request stays when a transaction that was kept still belongs to it, and the requests of the roll-up documents always stay;
- the ledger transaction numbers that no transaction uses any more. The highest number of each prefix is kept, so numbering continues where it stopped;
- the delivery queue entries and the quantity tracking rows of documents that were deleted. Rows of documents that still exist, purged or not, are never touched.
Removed only when you tick the option, because a customer may still want them: the actions history, the version history, the report run log, the settled reward points, the executed e-commerce requests and the attendance lines.
None of these rows is copied to the archive database. The dry run shows how many rows of each table would be removed.
The rule of every table is everything up to the cut-off, not what this run purged. So an option you left cleared can be ticked in the next purge, or in a supplementary run, and it removes what the earlier runs left.
Reward points
With Delete Expired Or Fully Redeemed Reward Points ticked, a reward point entry is deleted in two cases only:
- it expired on or before the cut-off; or
- it was earned on or before the cut-off and all its points were redeemed, by redemptions that are all dated on or before the cut-off.
In both cases the entry has no points left to use, so the balance of every customer on any date after the cut-off is exactly what it was. An entry with points still valid after the cut-off is never deleted, however old it is.
Expired points that were never processed
If the customer uses the Expired Reward Points Effect document for the accounting effect of expired points, issue it for the expired points before the purge. The pre-flight warns when expired points in the range were never processed by it; once deleted, they can no longer be.
A coupon redeemed long ago
A fully redeemed entry is deleted together with the record of its redemptions. If a coupon that redeemed those points is cancelled after the purge, the points are not given back, because the entry they would return to is gone. Customers who cancel old coupons should leave this option cleared.
A supplementary run
A period can be purged only once. But after the purge finishes, a customer may change their mind about two things: a document type that was only marked as purged should now be deleted (sales orders are the usual case), or an option that was left cleared should now be ticked. A supplementary run does exactly these two things on a period that is already purged, without restoring anything.
- Add a new Purge Configuration record, choose the same purge period in Up To Period, and tick Supplementary Run For A Purged Period (documents and system tables only).
- Fill the grids with what you want now. A type that was marked as purged and is now in a grid with a delete behaviour is deleted (or archived and deleted) in this run. A type you leave out stays as it is.
- Tick the delete options you want.
- Dry run, then run it from the Purge Monitor like any purge.
What it does not do: it creates no roll-up documents and touches no ledger, quantity, cost or debt transaction. The balances were rolled up by the first purge and stay exactly as they are, which is why a supplementary run is safe to repeat and needs no closing entries or books.
It is accepted only when every other purge configuration of the same period is Finished. Only document types that can be deleted by the purge can go from marked to deleted; accounting documents such as credit notes can not, and stay marked.
The document grids
Every document type that has committed documents in the range is processed, whether you list it or not. The two grids tell the purge what to do with each one.
Purged Documents
The first grid, Purged Documents, is for the ten document types that can be archived:
| Document type | Arabic name |
|---|---|
| Sales Invoice | فاتورة مبيعات |
| Sales Return | مردودات مبيعات |
| Purchase Invoice | فاتورة مشتريات |
| Purchase Return | مردودات مشتريات |
| Stock Issue | صرف مخزني |
| Stock Receipt | توريد مخزني |
| POS Sales Invoice | فاتورة مبيعات نقاط البيع |
| POS Sales Return | مردود نقاط البيع |
| Car Sales Invoice | فاتورة مبيعات سيارة |
| Car Sales Return | مردود مبيعات سيارة |
Each line has a Document Type, a Purge Behavior (required) and a read-only Records Count.
The grid of documents to delete
The second grid is for every other document type you want deleted (the product's messages call it the documents to delete grid). Each line has a Document Type, Delete Documents and a read-only Records Count. A type that can be archived is refused here; put it in Purged Documents instead.
The three behaviours
| Behaviour | Name on this screen | Name on the Purge Monitor | What happens to a committed document dated in the range |
|---|---|---|---|
| Archive and delete | Delete And Copy To Archive DB | Copy to the archive and delete — «نسخ إلى الأرشيف ثم حذف» | Copied to the archive database (header and lines), then deleted from the main database together with its attachments, approval cases and system rows. |
| Delete only | Delete Only, or a line in the second grid with Delete Documents ticked | Delete only — «حذف فقط» | Deleted the same way, without a copy. |
| Mark as purged | Mark Purged, or a type in neither grid, or a second-grid line with Delete Documents cleared | Mark purged — «تعليم كمحذوف» | Stays in the main database, flagged as purged: readable, never editable again. Its aliases, numbering rows and system entries are removed (the highest number of each book is kept, and attachments stay). |
In every case the document's ledger, stock, cost and debt transactions in the range are deleted and restated by the roll-up documents; the behaviour decides only what happens to the document record itself.
How to choose:
- Archive the high-volume documents the customer may one day want to look up (sales invoices, stock issues).
- Delete high-volume documents nobody will look up again (delivery documents, sales orders, transfer requests).
- Mark the rest: thousands of small types with a few documents each cost nothing to keep, and marking is the only behaviour that destroys nothing.
Populate Purge Grids
Populate Purge Grids saves you building the grids by hand:
- every archivable type with documents in the range is added to Purged Documents with Delete And Copy To Archive DB;
- every other type with at least Min Records To Suggest Delete documents is added to the second grid with Delete Documents ticked;
- lines you already had are kept as they are; only their Records Count is refreshed.
Review the suggestion with the customer, change behaviours where needed, then save. The record counts come from a quick count that includes drafts, so they can be a little higher than what the purge will actually process.
If both grids are left empty while archivable documents exist in the range, the purge refuses to start: an untouched configuration would only mark everything, which is never what was meant.
The Purge Batches list
Below the grids, the collapsible Purge Batches list shows the batches of a started purge: one plan batch, one batch per document type, one per module (inventory, then ledger) and one clean-up batch per system table, each with its status, attempts, processed rows and last error. The batches of a finished purge are removed; their summary stays in Last Run Log. The Purge Monitor shows the same batches with much more detail.
Statuses
| Status (monitor label) | Meaning |
|---|---|
| Initial — «مبدئي» | Not started. The record can be edited, previewed and deleted. |
| Planning — «تخطيط» | The run was accepted and the batches are being created. |
| Purging — «جاري الحذف» | Documents, then inventory, then ledger are being processed. |
| Cleaning up — «جاري التنظيف» | The history tables and the other system tables are being cleaned. |
| Finished — «منتهي» | Done. The range stays protected for good. |
| Failed — «فشل» | A batch failed five times and the purge is paused. It must be resumed; see When a Purge Fails. |
From Planning onwards the record can no longer be edited or deleted, and a dry run is no longer possible.
Messages you may see
| Message | Why | What to do |
|---|---|---|
| Period {0} must be of type {1} — «الفترة {0} يجب أن تكون من نوع {1}» | Up To Period is not a purge period. | Add a purge period to the fiscal year and choose it. |
| The purge cut-off period {0} must end before today (its end date is {1}); purging up to the current or a future date would delete live data — «فترة نهاية الحذف {0} يجب أن تنتهي قبل اليوم (تاريخ نهايتها {1})، لأن الحذف حتى التاريخ الحالي أو تاريخ مستقبلي سيحذف بيانات ما زالت مستخدمة» | The purge period ends today or later. | Choose an earlier year. |
| The purge config {0} already purged up to {1}; purging backwards up to {2} would roll the same range up a second time and duplicate the opening balances - a purge can only move forward — «ملف إعدادات الحذف {0} حذف بالفعل حتى {1}، والحذف بأثر رجعي حتى {2} سيعيد تجميع نفس المدى مرة ثانية ويكرر الأرصدة الافتتاحية - لا يمكن للحذف أن يتقدم إلا للأمام» | An earlier purge already reached a later or equal cut-off. | Choose a later cut-off. |
| There is already another purge file {0} for the period {1} — «يوجد بالفعل ملف حذف آخر {0} للفترة {1}» | Another configuration uses this period. | Use that configuration, or delete it while it is still Initial. If that purge is finished and you want to delete more from the same period, tick the supplementary run on the new record. |
| A supplementary run needs a finished purge file for the period {0}, and there is none — «التشغيل التكميلي يحتاج إلى ملف حذف منتهٍ للفترة {0}، ولا يوجد ملف كذلك» | The supplementary run is ticked, but the period was never purged. | Clear the tick to purge the period for the first time. |
| The purge file {0} for the period {1} is not finished yet (status: {2}); a supplementary run starts only after every other purge file of the period is finished — «ملف الحذف {0} للفترة {1} لم ينته بعد (الحالة: {2})، والتشغيل التكميلي لا يبدأ إلا بعد انتهاء كل ملفات الحذف الأخرى لنفس الفترة» | Another purge of the same period is still running, failed, or was never started. | Finish that purge first (resume it if it failed, or delete it if it is still Initial). |
| The type {0} is set to be deleted, but fixed asset entries point at its documents and every later document of the same asset reads them - set the type to be marked as purged — «النوع {0} محدد له الحذف، لكن قيود الأصول الثابتة تشير إلى مستنداته وكل مستند لاحق على نفس الأصل يقرؤها - اجعل سلوك النوع تعليم كمحذوف» | A document type that fixed assets were built from is in a grid with a delete behaviour. Every later document on such an asset recalculates it from all its earlier documents. | Remove the type from the grid, or clear Delete Documents, so that it is marked as purged. |
| {0} expired reward point entries were never posted by an expired points effect document; they are deleted with the rest, so post them first if their accounting effect is wanted — «{0} من سجلات نقاط المكافأة المنتهية لم ترحل بمستند تسوية نقاط المكافأة منتهية الصلاحية، وستحذف مع الباقي، فقم بترحيلها أولا إذا كان أثرها المحاسبي مطلوبا» | A warning of the pre-flight: the reward points option is ticked and expired points in the range were never processed. | Process them first if the customer wants their accounting effect; otherwise continue. |
| Choose a purge behavior for the type {0} — «اختر طريقة الحذف للنوع {0}» | A Purged Documents line has no behaviour. | Choose one. |
| The type {0} does not support archiving — «النوع {0} لا يدعم الأرشفة» | The type can not go in that grid. In the second grid the message means the type can not be deleted by the purge at all. | Remove the line; the type will be marked as purged. |
| The type {0} supports archiving, please put it in the {1} grid — «النوع {0} يدعم الأرشفة، يرجى وضعه في جدول {1}» | An archivable type was put in the second grid. | Move it to Purged Documents (choose Delete Only there if you do not want a copy). |
| The type {0} is repeated twice at lines {1} and {2} — «النوع {0} مكرر مرتين في السطرين {1} و {2}» | The same type appears twice in one grid. | Keep one line. |
| The book {0} must be a system book — «الدفتر {0} يجب أن يكون دفتر نظام» | The roll-up book is not marked System. | Mark it or choose another. |
| The book {0} must be for the type {1} — «الدفتر {0} يجب أن يكون للنوع {1}» | The book belongs to another document type. | Choose a book of Purge Journal / Purge Stock Receipt. |
| The term {0} must be a system term — «التوجيه {0} يجب أن يكون توجيه نظام» | The roll-up term is not marked System. | Mark it or choose another. |
| The term {0} must be for the type {1} — «التوجيه {0} يجب أن يكون للنوع {1}» | The term belongs to another document type. | Choose the right term. |
| Purge already started, can not edit purge file {0} — «بدأ الحذف بالفعل، لا يمكن تعديل ملف الحذف {0}» | The purge has started. | Nothing to change; resume it if it failed. |
| Can not delete purge config after starting it — «لا يمكن حذف ملف إعدادات الحذف بعد بدء تشغيله» | The purge has started. | A started configuration is kept for good. |
| Only admin user can edit this file — «يمكن للمستخدم المسؤول فقط تعديل هذا الملف» | The user is not admin. | Sign in as admin. |
| Only admin user can run the purge — «يمكن للمستخدم المسؤول فقط تشغيل الحذف» | The user is not admin. | Sign in as admin. |
| Dry-run preview for purge config {0} written to the Last Run Log field. — «تمت كتابة معاينة التشغيل التجريبي لملف إعدادات الحذف {0} في حقل سجل آخر تشغيل.» | Run Purge was pressed with Dry Run (preview only) ticked. | Read Last Run Log. |
| Purge for config {0} has been queued and will run in the background — «تمت جدولة الحذف لملف الإعدادات {0} وسيعمل في الخلفية» | The real purge was accepted. | Follow it on the Purge Monitor. |
| Purge configuration {0} is already running in the background (status {1}); it will continue automatically. Re-run it only if it has failed. — «ملف إعدادات الحذف {0} قيد التشغيل بالفعل في الخلفية (الحالة {1})، وسيستمر تلقائيا. لا تعد تشغيله إلا إذا فشل.» | Run was pressed on a purge that is running. | Nothing; it continues by itself. |
| Purge configuration file {0} is finished — «ملف إعدادات الحذف {0} منتهٍ» | Run was pressed on a finished purge. | Nothing to do. |