One feature that makes life easier for freelancers and small businesses is the ability to recreate the same invoice at any given interval, this prompted me to list it as a priority feature for Trevidia.
What the recurring feature does
With Trevidia, users can:
- Set an invoice to recur daily, weekly, bi-weekly, monthly, quarterly, or yearly.
- Automatically calculate the next invoice date
- Keep invoices linked, so users can track payment history over time
- Edit or stop a recurring invoice at any point No hacks. No duplicate clutter. One source of truth.
How I approached it (at a high level)
Instead of duplicating invoices blindly, each recurring invoice is linked to the original invoice data, where by the recurrence frequency can be gotten along with the next recurring date.
I built a laravel schedule to schedule a job called ProcessRecurringInvoices daily, the job scans the database for invoices that have their next recurring dates on the day it scanned, once it has gotten it, it duplicates the values and increments the invoice number based on the past invoice number and then sends the invoice to the previously sent email. The email is only sent if the owner of the email did not unsubscribe from receiving emails.
Conclusion
That's how I implemented the feature, although I didn't post any code snippet, I hope you understand the logic behind it and also this is my first post on Dev.to, I rarely write blogs or content I don't have the skill yet and I'm starting my journey to improve it, starting with this post. Thanks for reading and I'd make sure to make a new post next week.
Top comments (0)