Errors with recurring invoices

Hello,

I like the idea of being able to select 2, 3, or 4 week recurring invoices as many of my clients are on a biweekly billing cycle. However, ever since this feature was introduced, it does not appear to be working correctly.

I can create a 2 week recurring invoice, but when I view the recurring invoice in “Recurring Invoices” the “Every” column displays the following error. Then when the invoice tries to issue, it issues multiple invoices and each time it tries to issue, it issues the exact same invoice with the same invoice and due dates and all are in draft status. I had about 150 invoices issues over a 1 months period for a single client when they should have only had 2 invoices issued.

I think someone on the dev team needs to review this issue.

The weekly recurring invoice still appears to be working correctly.

A PHP Error was encountered
Severity: Notice

Message: Undefined offset: 14

Filename: views/index_recurring.php

Line Number: 56

Backtrace:

File: /home/*******/public_html/invoices/application/modules/invoices/views/index_recurring.php
Line: 56
Function: _error_handler

File: /home/*******/public_html/invoices/application/third_party/MX/Loader.php
Line: 404
Function: include

File: /home/*******/public_html/invoices/application/third_party/MX/Loader.php
Line: 365
Function: _ci_load

File: /home/*******/public_html/invoices/application/modules/layout/controllers/Layout.php
Line: 40
Function: view

File: /home/*******/public_html/invoices/application/modules/invoices/controllers/Recurring.php
Line: 38
Function: buffer

File: /home/*******/public_html/invoices/index.php
Line: 327
Function: require_once

Thanks in advance,

Kratos

Okay, so the hundreds of draft invoices when setting a recurring invoice may not be related to the 2 week issue. I had changed it to weekly, like I have used many times in the past and this week (the first time it was due to generate) it generated about 20 draft invoices that were all duplicates.

Please help, anyone!

Thanks,
Kratos

Currently have no time to look into this.
@Contributors @Developers anyone?

Still having this issue. It appears to be random in how many invoices are generated as drafts. However, the issue is still there and invoices are not auto generating correctly, being set as sent and being emailed.

run this sql command:

ALTER TABLE `ip_invoices_recurring` CHANGE `recur_frequency` `recur_frequency` CHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

@Kovah the error is because column recur_frequency in table ip_invoices_recurring is of type char(2) while it should be char(3) in order to be able to store the 2 weeks entry 14D. Error happened because it was truncated to string 14.
Error was reproduced and fixed with the sql command above.
Can you make the change within the appropriate sql file? I’m note sure which one the public can download since i pull requests to v1.5.4, that should be a file within \application\modules\setup\sql\???.sql.
We need to change from:
\recur_frequency` CHAR(2) NOT NULL,to:`recur_frequency` CHAR(3) NOT NULL,`
(remove backslashes before CTRL+F)

@kratos kindly let us know if it still sends hundreds of invoices after this being fixed (as this is complicated to reproduce now).

Okay, I changed column recur_frequency in table ip_invoices_recurring to char(3) and can verify that the initial error (php error) has gone away and I now see frequency of 2 weeks listed. I have set a new invoice to recur every 2 weeks and will report back once I can verify if it is still generating multiple draft invoices. I also still have my weekly invoices set for recurring and will advise if I see the multiple draft invoices for those as well.

Thank you,
Kratos

Your weekly invoices should behave normally as they are stored as 7D

Unfortunately they have not been.

Okay, so the hundreds of draft invoices when setting a recurring invoice may not be related to the 2 week issue. I had changed it to weekly, like I have used many times in the past and this week (the first time it was due to generate) it generated about 20 draft invoices that were all duplicates.

The multiple draft invoices continued after I stopped and deleted the bi-weekly recurring invoices and set up new weekly invoices.

Kratos

I could not reproduce your issue.
Would you be able to tell me step by step how to reproduce the bug you are experiencing?
How many recurring invoices do you have on the following page? YOUR_SITE/invoices/recurring/index

SQL command was added to the corresponding file and pushed to the repository.

I create a new invoice and save it. I then change it to sent status and save it again. I then create a recurring invoice from the invoice I just created and choose 1 week, the date I want it to start and leave end date blank.

I currently have 2 recurring invoices set up right now because I took all of the others off recurring and have been doing them manually (huge PIA). Once is a weekly recurring that I have been using to try and figure this out for a while now. The other is a 2 week recurring I just created yesterday and has not yet generated any invoices (or draft invoices).

It appears that each time my cron job runs, it causes the weekly invoice to generate a handful of invoices (doesn’t seem to be consistent as it appears to be anywhere from 5-20 at a time). I have my cron job set up to run twice daily.

When I upgraded to the latest release, I did not incur any errors or problems.

Kratos

Why don’t you use the latest release of InvoicePlane then?

I am on version 1.5.3. I missed an updated or two in there somewhere, but in May or so I upgraded to 1.5.1 and then to 1.5.3 in June. According to my update check, there are no newer versions available.

That’s weird and I have no idea. The fact that it would generate a random number of copies is also intriguing.

I created 2 recurring invoices: per week, and per 2 weeks. I ran the cronjob and it worked fine for me. Can you re install a fresh clean version of the latest InvoicePlane and try to reproduce the bug? If not, send me a private message and I’ll give you an access on my server so you can try to “break” it.

I am not seeing a way to PM you. Not sure if I am still on a restricted account or not, but I don’t see any way on your profile or otherwise to send a PM. Thoughts?

I’m having the same issue with a 4 week recurring invoice. I’m running 1.5.3 and I’ve executed the sql command listed above.

    Filename: views/index_recurring.php

Line Number: 56

Backtrace:

File: /home/xxxxxx/public_html/invoice/application/modules/invoices/views/index_recurring.php
Line: 56
Function: _error_handler

File: /home/xxxxxx/public_html/invoice/application/third_party/MX/Loader.php
Line: 404
Function: include

File: /home/xxxxxx/public_html/invoice/application/third_party/MX/Loader.php
Line: 365
Function: _ci_load

File: /home/xxxxxx/public_html/invoice/application/modules/layout/controllers/Layout.php
Line: 40
Function: view

File: /home/xxxxxx/public_html/invoice/application/modules/invoices/controllers/Recurring.php
Line: 38
Function: buffer

File: /home/xxxxxx/public_html/invoice/index.php
Line: 327
Function: require_once

I now have it working. I deleted the recurring invoice with the errors and after using the sql command posted by musa everything is working as it should. I now have a monthly recurring invoice. :slight_smile: