Undefined property: CI::$mdl_invoice_amounts on recurring invoices

Good day everyone,

Firstly, great product! Definitely the best out there.

Everything works fine, except for my recurring invoices. I tried using recurring invoices in 1.5.4, but then I saw that there was a bug on not retrieving the taxes correctly, which resulted in an error and said it was scheduled to be fixed in 1.5.5. I have upgraded my version to 1.5.5, but I’m receiving a different error this time:

Undefined property: CI::$mdl_invoice_amounts

It generates a new invoice, but the amount is left 0. Could someone please assist with what I’m doing wrong. I am clicking on Save first before creating the recurring invoice.

Here is the full trace:


Severity: Notice

Message: Undefined property: CI::$mdl_invoice_amounts

Filename: MX/Controller.php

Line Number: 59

Backtrace:

File: C:\inetpub\invoices\application\third_party\MX\Controller.php
Line: 59
Function: _error_handler

File: C:\inetpub\invoices\application\modules\invoices\controllers\Cron.php
Line: 116
Function: __get

File: C:\inetpub\invoices\index.php
Line: 327
Function: require_once

Fatal error: Call to a member function calculate() on null in C:\inetpub\invoices\application\modules\invoices\controllers\Cron.php on line 116
A PHP Error was encountered

Severity: Error

Message: Call to a member function calculate() on null

Filename: controllers/Cron.php

Line Number: 116

Backtrace:

https://development.invoiceplane.com/browse/IP-611

I 2nd this - as of 1.5.5, recurring invoices are now being generated however, there are no items listed in the invoice.

I’m still running 1.5.4, but my error is a different variable.

Severity: Notice

Message: Undefined property: CI::$mdl_invoice_tax_rates

Filename: core/Model.php

Line Number: 77

Backtrace:

File: /var/www/html/application/modules/invoices/models/Mdl_invoices.php
Line: 252
Function: __get

File: /var/www/html/application/modules/invoices/controllers/Cron.php
Line: 61
Function: copy_invoice

File: /var/www/html/index.php
Line: 327
Function: require_once

Sadly this is the second time that I’ve applied an update to InvoicePlane and found recurring invoices to be broken the following month.

I wish this were more thoroughly tested as it’s making me begin to question whether or not to update, which isn’t something I should be asking about my billing software…

Is it possible to roll back to a previous version?

This error was fixed in version 1.5.5.

If I had the time or money to pay someone to do this, I would definitly test more. But I don’t have neither. So it is a task of the community to help test the software and fix bugs. :slight_smile:

This is because the model has not been loaded before
Add to file /application/modules/invoices/controllers/Cron.php on line 31

$this->load->model(‘invoices/mdl_invoice_amounts’);

and all will run smoothly

That prevented the CRON errors but now all recurring invoices are empty.

In file /application/modules/invoices/controllers/Cron.php
on line 61
$this->mdl_invoices->copy_invoice($source_id, $target_id, true);

set this to false
$this->mdl_invoices->copy_invoice($source_id, $target_id, false);

on my case it’s work, recurring invoice not empty
CMIIW

Thanks to @smile for his fix. Just test it and it works I just made a Pull Request it should be fix in the next version :slight_smile: