Saturday, May 8, 2010

Error in project proforma invoice posting

Recently I discovered a bug in Dynamics AX proforma invoice posting in the Project module. If you post project proforma invoices (print without posting) and choose Print = After, the system will give you the error "Cannot create a record in Project invoice (ProjInvoiceJour)".

This error only happen when you post several project proforma invoices in batch (ie. using the Periodic\Post invoice function for group posting instead of posting them individually).
After diving into the X++ codes, I realised that this is kind of a design error. As with proforma invoice posting in Sales ledger and Purchase ledger, project proforma invoice posting will first insert a record in ProjInvoiceJour with blank Invoice id, and then delete this record after printing. This is not an issue when Print = Current because the record is deleted immediately after printing. But if Print = After, the system will accumulate the records in a RecordSortedList object until the posting is completed only then print and delete the proforma invoice records. In this case, when there is more than one invoice lines have the same posting/invoice date, inserting with a blank Invoice id will violate the primary key index rule in ProjInvoiceJour table, thus giving the above error message. You have to manually writing job to delete the blank Invoice id record in ProjInvoiceJour table because it will prevent any further proforma invoice posting on the same date. You cannot delete it from Table browser because the ProjInvoiceJour table is locked from user deletion.

The interesting bit here is the same error will have not happen in Sales and Purchase proforma invoice posting (or actually is printing). The system disables the Print [Current/After] checkbox if you select the Posting checkbox. And in the posting classes, it will only allow the use of Print = After when it is not proforma. I considered this is a bug, and it is found in both Dynamics AX 2009 and AX 4.0. I did not have a chance to test it on version 3.0.


Sigve said...

We have contacted Microsoft regarding this problem. And to my knowledge there are no official AX 2009 fix for this problem. We got a Axapta 3.0 solution refering to Knowledge Base article 909994.

I hoped somebody had a fix for this invoice problem.

Wai Keat Ng said...

Anyway this is a rare issue, hopefully Microsoft will fix this on AX 6.0.

Anonymous said...

I use Pro Forma Invoice at as my online invoicing solution. It is very easy to use and I can manage unlimited companies, unlimited clients, products, invoices and much more. I can even email the invoice directly to my client and give the invoice any heading I wish. If you are looking for an online tool which is easy and mobile, then you have to check out Star Invoice.