Moved invoice to draft and now get 503 error

v 22.0.3

I recently moved a completed invoice back to draft status to make an adjustment and now I get a 503 error only when I try to access that particular invoice. When I access the customer’s third party page (comm/card.php?socid=xxx), I can see the invoice is in draft status and I can preview the PDF with the magnifier+ icon and the PDF is in draft status. But I cannot access it through compta/facture/card.php?id=xxx.

I have previously moved invoices back to draft status with no problems. This invoice does have a credit for using a down payment against the final total. Perhaps that is the problem?

Does anyone have a suggestion? Thanks in advance for your replies.

Hi @lkeet

You can try checking two logs: one is the Dolibarr log, and the other is the PHP error log. I’m sure you’ll find some useful clues there.

Thanks & regards

Saikat Koley

Software Developer(Dolibarr)

Call/WhatsApp : +919903256573

https://www.linkedin.com/in/saikatkoley/

I have the dolibarr log attached to this message. The last action before I loaded this log is when I tried to open the problem invoice. Do you see any clues here? I cannot find any error message.

dolibarr.log (736.5 KB)

first of all, your file is almost 1 MegaByte big. That is way too much log information, I just wanted to see right around when you open it.

here’s how you can make it as small as possible on linux.

tail -n0 -f dolibarr.log | tee /tmp/bad_invoice_log.txt

Then you load the page with the bad invoice, and just that page

The tee command will both show the content to stdout and it will store only that content in that file.

As soon as the page seems to be done loading, like when the output stops coming in the log window, then you press ctrl+c and abort it.

Then you can look in that file in /tmp/ to see what happens

besides this I’d like to see your webservers log during the same time

@lkeet in, your Dolibarr log file, I found some errors.

2025-12-10 22:52:57 DEBUG 199.244.54.204 663430 33188 sql=SELECT url , fieldname , showbutton, popupon FROM llx_inputcalculator_inputcalculatorsetup WHERE
‘/home3/lkeeton/public_html/actg24/admin/modules.php’ like concat(‘%’, url, ‘%’)
2025-12-10 22:52:57 ERR 199.244.54.204 663430 33188 DoliDBMysqli::query Exception in query instead of returning an error: Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist
2025-12-10 22:52:57 ERR 199.244.54.204 663430 33188 DoliDBMysqli::query SQL Error message: DB_ERROR_NOSUCHTABLE Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist From /home3/lkeeton/public_html/actg24/custom/inputcalculator/class/actions_inputcalculator.class.php:145.

By seeing the table structure, I think this error is coming from a custom module. Disable that custom module once, and then try and see.

Thanks & regards

Saikat Koley

Software Developer(Dolibarr)

Call/WhatsApp : +919903256573

https://www.linkedin.com/in/saikatkoley/

@satty yeah, but that is like 14 minutes before looking at that facture

2025-12-10 23:00:42 ERR 199.244.54.204 685760 33188 DoliDBMysqli::query Exception in query instead of returning an error: Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist
2025-12-10 23:00:42 ERR 199.244.54.204 685760 33188 DoliDBMysqli::query SQL Error message: DB_ERROR_NOSUCHTABLE Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist From /home3/lkeeton/public_html/actg24/custom/inputcalculator/class/actions_inputcalculator.class.php:145.
2025-12-10 23:00:45 ERR 199.244.54.204 685842 33188 DoliDBMysqli::query Exception in query instead of returning an error: Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist
2025-12-10 23:00:45 ERR 199.244.54.204 685842 33188 DoliDBMysqli::query SQL Error message: DB_ERROR_NOSUCHTABLE Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist From /home3/lkeeton/public_html/actg24/custom/inputcalculator/class/actions_inputcalculator.class.php:145.

and then the access to that invoice is 14 minutes later? I don’t think they are related

JonSweet16:tmp jonbendtsen$ tail dolibarr.txt
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 sql=SELECT rowid FROM llxaj_facture WHERE fk_facture_source = 63 AND type < 2 ORDER BY fk_statut DESC
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 Facture::liste_contact
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 sql=SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact, ‘-1’ as socid, t.statut as statuscontact, t.login, t.photo, t.gender, t.fk_country as country_id, t.civility as civility, t.lastname as lastname, t.firstname, t.email, t.address, t.zip, t.town, tc.source, tc.element, tc.code, tc.libelle as type_label, co.label as country FROM llxaj_c_type_contact as tc, llxaj_element_contact as ec LEFT JOIN llxaj_user as t on ec.fk_socpeople = t.rowid LEFT JOIN llxaj_c_country as co ON co.rowid = t.fk_country WHERE ec.element_id = 63 AND ec.fk_c_type_contact = tc.rowid AND tc.element = ‘facture’ AND tc.source = ‘internal’ AND tc.active = 1 ORDER BY t.lastname ASC
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 Facture::liste_contact
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 sql=SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact, t.fk_soc as socid, t.statut as statuscontact, t.fk_pays as country_id, t.civility as civility, t.lastname as lastname, t.firstname, t.email, t.address, t.zip, t.town, tc.source, tc.element, tc.code, tc.libelle as type_label, co.label as country FROM llxaj_c_type_contact as tc, llxaj_element_contact as ec LEFT JOIN llxaj_socpeople as t on ec.fk_socpeople = t.rowid LEFT JOIN llxaj_c_country as co ON co.rowid = t.fk_pays WHERE ec.element_id = 63 AND ec.fk_c_type_contact = tc.rowid AND tc.element = ‘facture’ AND tc.source = ‘external’ AND tc.active = 1 ORDER BY t.lastname ASC
2025-12-10 23:14:58 INFO 199.244.54.204 737272 33188 files.lib.php::dol_dir_list path=/home3/lkeeton/dolibarrdata/facture/09157 types=files recursive=0 filter=“” excludefilter=“(\.meta|_preview.*\.png)$”
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 sql=SELECT COUNT(rowid) as nb FROM llxaj_links WHERE objecttype = ‘facture’ AND objectid = 63 AND entity = 1
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 sql=SELECT COUNT(id) as nb FROM llxaj_actioncomm WHERE fk_element = 63 AND elementtype = ‘invoice’
2025-12-10 23:14:58 DEBUG 199.244.54.204 737272 33188 sql=SELECT cc.code FROM llxaj_c_country as cc WHERE cc.eec = 1
2025-12-10 23:14:58 INFO 199.244.54.204 737272 33188 — End access to /actg24/compta/facture/card.php

looking at line numbers

1746:2025-12-10 23:00:45 ERR 199.244.54.204 685842 33188 DoliDBMysqli::query Exception in query instead of returning an error: Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist
1747:2025-12-10 23:00:45 ERR 199.244.54.204 685842 33188 DoliDBMysqli::query SQL Error message: DB_ERROR_NOSUCHTABLE Table ‘lkeeton_doli972.llx_inputcalculator_inputcalculatorsetup’ doesn’t exist From /home3/lkeeton/public_html/actg24/custom/inputcalculator/class/actions_inputcalculator.class.php:145.

there’s a long way up to that last line at 2622

2117:2025-12-10 23:01:13 INFO 199.244.54.204 687029 33188 — End access to /actg24/compta/facture/card.php
2177:2025-12-10 23:01:16 INFO 199.244.54.204 687226 33188 — End access to /actg24/compta/facture/card.php
2225:2025-12-10 23:01:20 INFO 199.244.54.204 687704 33188 — End access to /actg24/compta/facture/card.php
2341:2025-12-10 23:01:25 INFO 199.244.54.204 687903 33188 — End access to /actg24/compta/facture/card.php
2622:2025-12-10 23:14:58 INFO 199.244.54.204 737272 33188 — End access to /actg24/compta/facture/card.php

Thank you SK. I did see that yesterday and disabled that custom module. It did not seem to change the 503 error.

I am attaching two log files. I opened two invoices from this page: /compta/facture/list.php? by opening in a new browser tab, so nothing should be happening other than the tooltip for each invoice appears before invoice opens. The page for the defective invoice looks like this in the browser:

Dolibarr log open defective invoice.txt (29.3 KB)

Dolibarr log open good invoice.txt (61.4 KB)

This is the last line in common for both logs:

2025-12-11 21:50:53 DEBUG 199.244.54.204 164332 33188 sql=SELECT COUNT(id) as nb FROM llxaj_actioncomm WHERE fk_element = 63 AND elementtype = ‘invoice’

2025-12-11 21:52:37 DEBUG 199.244.54.204 172005 33188 sql=SELECT COUNT(id) as nb FROM llxaj_actioncomm WHERE fk_element = 61 AND elementtype = ‘invoice’

This is the line that is next in the good invoice:

2025-12-11 21:52:37 DEBUG 199.244.54.204 172005 33188 Facture::getSommePaiement

As I suspected, it may have to do with the credit (payment) I applied to the “bad” invoice that came from a down payment invoice that was paid earlier this year. When I moved the “bad” invoice back to draft status to make an adjustment, it seems to have broken the Dolibarr system somehow.

Is there a fix or workaround?

There is always a fix, but it may be difficult to find. I’ll take a look at the log files

@lkeet Are the 2 currencies in the same currency?

Do you even use more than 1 currency?

Are the invoices of the same kind? meaning both are customer invoices, and not a vendor + a customer (or flipped) and both are an invoice and not a credit note?

Are both invoices with a down payment?

It sounds like the invoice might be stuck due to the credit/down payment. Try duplicating the invoice or removing the credit temporarily to see if it loads, and check for any database inconsistencies.

@jonbendtsen I only use 1 currency. Yes, both are customer invoices. I don’t have any vendor + customer combos. I have never issued a credit note. These are the last two invoices to this same customer. The broken one has a down payment that was applied from a down payment invoice. The “good” one has no down payment. Neither invoice has any other payments applied.

@Jayden-Lee I cannot access the card page to remove the credit from the down payment. I can generate a PDF of the printed invoice (which says it is in draft status), but I cannot generate the card page to make any changes.

@Jayden-Lee can you give me a procedure for checking for database inconsistencies? Where can I learn about those?

Do you have raw database access?

Could you perhaps use the export function of Dolibarr to export these 2 invoices and notice where the difference is?

I’m having this same issues with my invoices, can anyone help

okay @Enose, the same questions apply to you.

Which Dolibarr version are you running?
Which PHP version are you running it on?

Please send us a small snippet of your webservers log, only the time when you load that invoice, that should not be more than perhaps a handful or 2 of lines.

Please enable debug logging in Dolibarr and send us a little snippet, the snippet where you load the broken invoice.

Also tell us if you know how that invoice ended up in the situation it is in?

@jonbendtsen @saikatkoley @Jayden-Lee

I have been troubleshooting and found some new information:

I turned off a lot of modules and nothing changed.

When I opened the card page on a “good” invoice and then tried to generate a new version of the PDF, it now returns the 503 Error. And, it will not open the card page on that invoice again without returning the 503 Error. I turned off any customized PDF templates. I tried to generate a PDF on a “good” invoice using the Sponge template and it returned the 503 Error.

What are my next steps in troubleshooting? I have used the Console on phpMyAdmin on my hosted site to search a large amount of the SQL strings in the Dolibarr logs and the Debug bar. Those have not produced any errors that I have found. When the 503 error shows, I cannot get any debug info that led to that page.

Could the PDF library be broken? How can I test that?

Also, it does generate the new PDF. I can preview and download it from /compta/facture/list.php? page. But I still cannot open the /compta/facture/card.php page for those invoices. What changes in the SQL tables when the PDF generates?

Is there a timeout variable that is set too short on my system?