Hey Guys, found an old thread regarding this but without any update, does anyone have an insight regarding this?
Every time i download an invoice it randomly changes the order of the line items
Which Version are you using ?
Hey, im using V8.8.0
Download means generate a PDF?
I’ve tested it with 8.8.1:
Is it random each time you generate the PDF?
Or only one time random at invoice creation time?
Is it an upgraded system, which might still have custom / legacy code somewhere?
There are some areas where the order of things can’t be easily controlled (e.g. workflow IDs).
Here, on a fresh 8.8.1 install I wasn’t able to replicate the issue.
I assume the line items order depends on the quote line item table, in case there is no specific code in the SQL query for the item retrieval at generation time.
Sorry guys, its so many CRM’s installed i get confused xD
Its on version 8.5.1 maybe thats why yours works, tought i tested on another 8.8.0 but it was on 8.5.1 aswell xD
Will test and update y’all later, thanks for the time spent figuring it out guys
Did it work for you on the v8.8.0?
Testing as we speak, having some issues with the fatal rename failure, should be permissions, just trying to check how it was fixed on my other machines rn
Ok so after updating i can confirm the issue persists, the invoices are created and line items inserted using a python script via API, when i download the PDF Invoice it will randomly change order positions every-time i download,if the script inserts line items 1 to 10 following the logic when i “Print” it will show 3,7,2,1,etc. and in the next download will show 1,9,10,5,2,etc
Can you create an invoice from the UI with the same line items in the correct order and then check the DB for the two different invoices?
If your UI invoice remains ordered correctly, either there are some details missing when creating the the invoice via the API or there is some missing parts not implemented in the API endpoints.
Thats a great test, will check it out. Many Thanks ![]()
Hey Bastian, so if the invoice is manually made it doesn’t randomly scramble the order but if its via API it does, does anyone has a clue where i can check this process?
Did you check the DB differences for both cascading / related records?
I’ve got some API integrations with surveys - that took quite a bit of looking into details, maybe it’s similar for invoices.
Try to GET request your invoices + line items and see whether there are any attributes that hint towards an order.
Hey Bastian,
So after checking the DB entries i came to a strange conclusion, Invoices generated via API have only 1 entry in the aos_line_item_groups table and mannually created Invoices have the number of entries in the Service Line on the DB . apart from that everything looks normal so i dont think it has something to do with it.
Could you please give me some guidance @BastianHammer ?
Sorry, was able to figure out, the “number” field wasnt being applied when sent from the API, its under AOS_Products_Quotes
Sounds good.
Yes, the quotes / line items / products feature is a bit special.
Glad that it worked out.

