Configuration Issue? Item(s) Added to Past Due Invoices Not Showing on the PDF or Client Portal

Environment: Production Invoice Ninja Self Hosted v5.3.96
OS - Debian 10 server with current security patches (Linux)
PHP - v8.0.19 with current security patches
DataBase Engine - MySQL/MariaDB - Current version with latest security patches
Web Server - Apache v2.4.52 with current security patches
PDF Engine - Local SnapPDF (not using Phantom)
Other - Virtual Machine = yes
Other - VM is not Docker; private VM instance with dedicated resources

Bug: We needed to add a line item to a past due invoice to reflect late fees. There seems to be no issues adding the line item to the existing (past due) invoice and saving the edit. When we look at either the PDF or the client portal after the edit, the old invoice is displayed without the changes. Also when we download the PDF from the dashboard, the downloaded PDF does not show the change either

Can the Issue be Reproduced? We are able to reproduce this issue on demand

Other Info: The affected invoices are over a year old and were created as new invoices in v5, they were not part of our migration from Invoice Ninja v4. We only have these two past due invoices and can’t see if this issue affects past due invoices less than a year old

Troubleshooting Steps: We have cleared the PDF cache at invoiceninja/public/storage
(see Regenerate PDF after Invoice Design Change) but this did not resolve the issue.
Additionally we have not added the system maintenance task that will perform a system cleanup of PDFs and Backup .html files (See release notes for v5.3.90 at Release notes · invoiceninja/invoiceninja Wiki · GitHub)

Hi,

@david do you have any suggestions?

@amp51

Are you using

QUEUE_CONNECTION=sync

or

QUEUE_CONNECTION=database.

It sounds like you may be using database, but with the queues not running.

Thanks for the quick reply. It is configured to use QUEUE_CONNECTION=database

What is the corrective action on this?

@amp51,

if you are on the command line can you try running

php artisan queue:listen

If the system starts spewing out jobs it means that all of your jobs have been queued but not executed.

As a work around for the short term, we added the PDF maintenance task to the .env and set the days to 1. This got us the results we needed to get adjusted invoice out to our client.

DELETE_PDF_DAYS=1
DELETE_BACKUP_DAYS=1

Here is the output. Permissions errors are apparent.
What areas and permissions need to be adjusted? The current permissions for /var/www/html/invoiceninja/storage/logs/ are set to www-data

-rwxr-xr-x 1 www-data www-data 11639830 Jun 12 13:48 laravel.log

Output of php artisan queue:listen

┌─[xxxx@yyyyyyy]─[/var/www/html/invoiceninja]
└──╼ $php artisan queue:listen
[2022-06-12 17:49:53][12058] Processing: App\Jobs\Entity\EmailEntity
[2022-06-12 17:49:55][12058] Processed:  App\Jobs\Entity\EmailEntity
[2022-06-12 17:49:55][12059] Processing: App\Listeners\Invoice\InvoiceEmailActivity
[2022-06-12 17:49:59][12059] Failed:     App\Listeners\Invoice\InvoiceEmailActivity

In StreamHandler.php line 146:
                                                                               
  The stream or file "/var/www/html/invoiceninja/storage/logs/laravel.log" co  
  uld not be opened in append mode: Failed to open stream: Permission denied   
  The exception occurred while attempting to log: The stream or file "/var/ww  
  w/html/invoiceninja/storage/logs/laravel.log" could not be opened in append  
   mode: Failed to open stream: Permission denied                              
  The exception occurred while attempting to log: The stream or file "/var/ww  
  w/html/invoiceninja/storage/logs/laravel.log" could not be opened in append  
   mode: Failed to open stream: Permission denied                              
  The exception occurred while attempting to log: file_put_contents(/var/www/  
  html/invoiceninja/public/storage/redacted.html): Failed to open stream: Perm  
  ission denied                                                                
  Context: {"exception":{}}                                                    
  Context: {"exception":{}}                                                    
  Context: {"exception":{}}                                                    
                                                                               

[2022-06-12 17:50:00][12060] Processing: App\Listeners\Invoice\InvoiceEmailedNotification
[2022-06-12 17:50:00][12060] Processed:  App\Listeners\Invoice\InvoiceEmailedNotification
[2022-06-12 17:50:00][12061] Processing: App\Listeners\Invoice\InvoiceEmailFailedActivity
[2022-06-12 17:50:06][12061] Failed:     App\Listeners\Invoice\InvoiceEmailFailedActivity

In StreamHandler.php line 146:
                                                                               
  The stream or file "/var/www/html/invoiceninja/storage/logs/laravel.log" co  
  uld not be opened in append mode: Failed to open stream: Permission denied   
  The exception occurred while attempting to log: The stream or file "/var/ww  
  w/html/invoiceninja/storage/logs/laravel.log" could not be opened in append  
   mode: Failed to open stream: Permission denied                              
  The exception occurred while attempting to log: The stream or file "/var/ww  
  w/html/invoiceninja/storage/logs/laravel.log" could not be opened in append  
   mode: Failed to open stream: Permission denied                              
  The exception occurred while attempting to log: file_put_contents(/var/www/  
  html/invoiceninja/public/storage/redacted.html): Failed to open stream: Perm  
  ission denied                                                                
  Context: {"exception":{}}                                                    
  Context: {"exception":{}}                                                    
  Context: {"exception":{}}                                                    
                                                                               

[2022-06-12 17:50:52][12068] Processing: App\Jobs\Entity\EmailEntity
[2022-06-12 17:50:53][12068] Processed:  App\Jobs\Entity\EmailEntity
[2022-06-12 17:50:54][12072] Processing: App\Jobs\Mail\NinjaMailerJob
[2022-06-12 17:50:54][12072] Processed:  App\Jobs\Mail\NinjaMailerJob
[2022-06-12 17:50:54][12073] Processing: App\Jobs\Util\SystemLogger
[2022-06-12 17:50:54][12073] Processed:  App\Jobs\Util\SystemLogger
[2022-06-12 17:50:55][12074] Processing: App\Listeners\Mail\MailSentListener
[2022-06-12 17:50:55][12074] Processed:  App\Listeners\Mail\MailSentListener
[2022-06-12 17:50:59][12069] Processing: App\Listeners\Invoice\InvoiceEmailActivity
[2022-06-12 17:51:03][12069] Failed:     App\Listeners\Invoice\InvoiceEmailActivity

You’ll need to ensure the webuser (which should also be the user that is running the queues) has write access to storage/logs/laravel.log

if you have started the queue from the command line, ensure that you start it via the webuser, ie.

sudo -u www-data php artisan queue:listen

Sorry for the delay in reply. When we run the sudo -u www-data php artisan queue:listen, there is no output.

Unsure what is happening here. As long as the directories are writable by the webuser this should work as expected.

The issue looks to be the queue not running as expected.

Understood. We are looking into other areas of the system and may install the dedicated task process scheduler.