Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Recurring Invoices

Ken Minardo   ( User )

Commented 5 years ago

Hello fellow users,

This isn't really a question, but I've been fighting with the recurring functions for a couple days and I've finally nailed down most that I had change to get it working, so I thought I'd share here in case anyone is looking in the future. All information is relevant as of v1.3.17

Most of these bugs are contained in /app/Console/Commands/RecurringCheck.php

Issue: If you change your timezone in the software settings, the recurring function will never run. Akaunting will begin saving invoice dates as the selected time zone, and the recurring function compares against "today" as a UTC date by default to decide if the invoice needs duplicated. As the timezone you've chosen probably isn't UTC, it's no longer equal. That will cause the function to break out of it loops at RecurringCheck.php Line 71

Resolution: Modify /config/app.php line 67
Change from 'timezone' => 'UTC',
to 'timezone' => 'Americas/New_York', (aka your relevant php-compatible timezone)
This will set the "global" timezone in the Carbon library to the correct one - now dates will match!

Issue: Daily Recurring w/ 0 limit will duplicate hundreds of times each time the recurring function is called
Resolution: RecurringCheck.php Line 124 set's the duplicated invoice with this line:
$clone->due_at = $this->today->addDays($diff_days)->format('Y-m-d');
By doing that, it's incrementing the $this->today variable, so each loop "Today" is increased and it duplicates again. Change that line to include copying the date before adding the days to resolve.
$clone->due_at = $this->today->copy()->addDays($diff_days)->format('Y-m-d');

Issue: When attempting to duplicate the invoice model at RecurringCheck.php Line 114, it will error saying the 'reconciled' column could not be found in the database. The actual problem is the duplicate function copies the object as it sits directly to the database, all fields on the object are mapped to appropriate columns in the database. I'm guessing at some point 'reconciled' was moved to be stored in a different db table, but the object was not cleaned up, resulting in this error.
Resolution: I'm not sure the ramifications of this change, so use at your own risk, but I've unset the field before the duplication is performed. This removes the field from the object and allows the duplicate function to mirror the object into the database successfully.

On line 113, add:
unset($model->reconciled);

Final Thoughts:
I'm still experiencing Laravel saying "No scheduled commands are ready to run." when I try to execute 'php artisan schedule:run' so I'm not convinced this is going to run on the cron job as expected, but I'll find out tomorrow.

I am disappointed in this software's lack of quality around this area - I think the developers should really consider revisiting recurring invoices as it's just straight up broken at this time and it's a primary reason I chose to use this software in the first place.

Hopefully this helps someone!
- Ken

Ken Minardo   ( User )

Commented 4 years ago

Well it's now been 2 months and I can confirm that despite the changes listed above, recurring invoices still don't work.. it would be really nice if a dev team member could comment on patches or upcoming changes to restore this functionality.

Mario   ( User )

Commented 2 years ago

Also not working for me, self hosted. Such a bummer :(

Please login or register to leave a response.

Showing 1 to 3 of 3 discussions