Topic: Missing audit trail items

I probably did something to cause this. When I started entering things in January, I was doing everything wrong, and I had to restore from backups more than once.

In reading the audit_trail PHP script, it appears that it would be an error for there to be any gl_trans records with non-zero amounts that don't have a corresponding audit_trail record. Running reports manually in MySQL, I find 4 gl_trans records that do not have a matching audit_trail record.

The first two are type=0; the credit/debit for the opening balance of a bank account (I just put the opening balance in as a deposit on January 1, rather than putting it in for the previous fiscal year, then closing that fiscal year ... I didn't know how to do that, back then).

The next two appear to be from a line item on an invoice (type=10).

Do I need to fix something, or is this just going to post an informational message when I close this fiscal year? All of the general ledger entries are correct and everything balances.

+---------+------+---------+------------+---------+-----------------+----------+--------------+---------------+----------------+-----------+
| counter | type | type_no | tran_date  | account | memo_           | amount   | dimension_id | dimension2_id | person_type_id | person_id |
+---------+------+---------+------------+---------+-----------------+----------+--------------+---------------+----------------+-----------+
|      32 |    0 |       3 | 2018-01-01 | 1060    | Opening balance |  4495.54 |            0 |             0 |           NULL | NULL      |
|      33 |    0 |       3 | 2018-01-01 | 3590    | Opening balance | -4495.54 |            0 |             0 |           NULL | NULL      |
|      46 |   10 |       7 | 2018-01-09 | 4012    |                 |      -48 |            0 |             0 |           NULL | NULL      |
|      47 |   10 |       7 | 2018-01-09 | 1200    |                 |       48 |            0 |             0 |              2 | 3         |
+---------+------+---------+------------+---------+-----------------+----------+--------------+---------------+----------------+-----------+

Re: Missing audit trail items

Unless you edit /delete any transaction, an audit trail will generally not occur.

For a brand new sql/en_US-new.sql based company, on entering 1 customer, 1 supplier and 1 item, there are no audit_trail entries at all. GL Transactions will certainly have records generated in the audit_trail table.

All audit_trail records except latest one should have the field gl_seq set to NULL to avoid need for subqueries (absent in MySQL 3) all over the code - see code and comments in function add_audit_trail() in includes/db/audit_trail_db.inc file.

Read the Wiki.

Re: Missing audit trail items

I was actually studying includes/db/audit_trail_db.inc. When no audit records match with GL transactions, it looks like it issues a warning like: "Some transactions journal GL postings were not indexed due to lack of audit trail record". That led me to believe that all gl_trans records are expected to have a matching audit record.

When to write an audit record is causing me some confusion.

Re: Missing audit trail items

It is pertinent to have such a message to accommodate records prior to inducting this table in FA and for records that straddled fiscal years when the older ones have been purged.