Jump to content
  • 0

Only Send Renewal Invoices On Weekdays.


Jason

Question

Is there a way to delay the sending of renewal invoices on weekends? That way my clients only receive their invoices on weekdays.

 

I know it is a long shot, but I am hoping there is a simple way to stop Blesta from sending/renewing on weekends.  E.g.   If today = a weekend, stop the process. Of course, every 5 minute,s or whatever the cron is set to, the system will be blocked, but once Monday hits, the system would work through the backlog and process the renewals like normal. I have a small client base, so I don't necessarily need to worry about the backlog breaking my system, but I would love to find a way to block the system from sending renewals on weekends.

 

A better method might be to actually adjust the renewal date itself instead of blocking the emails.  If there was a way to add an additional check when the system sets the next renewal date, that would probably work as well.  The additional check could calculate if the renewal falls on a weekend and then automatically schedule the next renewal to be on the closest weekday in the future.  E.g.  If next renewal date = a weekend, set renewal ahead to Monday.

 

Any idea on how I could do this?  Or at least could you point me in the right direction to find the files that handle these functions in Blesta?

Thanks so much for your help!

--Jason

 

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Invoices for service renewals are only generated once a day. If you want to prevent invoices for renewing services from being generated on weekends, you could update /app/controllers/cron.php and look for createRenewingServiceInvoices, which is the method you would want to update. Simply return an empty string from that method without doing anything if today is on a weekend.

Link to comment
Share on other sites

  • 0

Thanks for the help Tyson. That info is super helpful.

I think it would work better if I could actually adjust renewal dates so that they only hit weekdays, but as a close second, shutting off the cron seems like a really good option.

 

One question about that though.  If I block the entire  "private function createRenewingServiceInvoices() {" from running will that skip the renewals entirely, or simply postpone them?  So if it skips Saturday's invoices, will it automatically pick those up on Monday, or will it not process those invoices since the cron didn't catch them on Saturday?

 

I added a simple code that just checks to see if it is the weekend, and if it is, it manually set the output to "" and skips the entire function.

So my code looks something like this:

 

private function createRenewingServiceInvoices() {
  if (date('N') >= 6) { $output = ""; } else {

 

........ Normal cron stuff skipped ........

 

  }

return $output;
    }

 

Can you see any reason this would cause errors (e.g. are there required variables within the cron section I am skipping that would be needed to complete the other elements of the cron)?

--Jason

Link to comment
Share on other sites

  • 0

I added a simple code that just checks to see if it is the weekend, and if it is, it manually set the output to "" and skips the entire function.

So my code looks something like this:

 

private function createRenewingServiceInvoices() {

  if (date('N') >= 6) { $output = ""; } else {

 

........ Normal cron stuff skipped ........

 

  }

return $output;

    }

 

Can you see any reason this would cause errors (e.g. are there required variables within the cron section I am skipping that would be needed to complete the other elements of the cron)?

 

What you have looks fine. It wouldn't affect the operation of other cron tasks. However, you should make a note of your file changes. Updating Blesta in the future can overwrite that file, and you would need to reapply your changes.

 

 

One question about that though.  If I block the entire  "private function createRenewingServiceInvoices() {" from running will that skip the renewals entirely, or simply postpone them?  So if it skips Saturday's invoices, will it automatically pick those up on Monday, or will it not process those invoices since the cron didn't catch them on Saturday?

 

The cron will catch up on billing anything that it had missed in the past. For instance, if the cron fails to run for a week, it will create that week's invoices the next time it is able to run successfully. This behavior is not shared with all other cron tasks. For example, if a payment reminder is set to be sent out 3 days before the invoice is due, and the cron does not run 3 days before that invoice is due, then that reminder will not be sent.

 

 

I think it would work better if I could actually adjust renewal dates so that they only hit weekdays, but as a close second, shutting off the cron seems like a really good option.

 

Automatically adjusting renewal dates so they skip weekends is a much more complex task. This can potentially affect the system in unexpected ways, such as if you have a service that renews on a daily basis. For example, changing a daily service's renew date such that it next renews on Monday instead of Saturday would give two free days of service and no invoices would ever be generated for Saturday or Sunday.

 

If you're mainly concerned with customers losing track of their invoices among spam and other email that they collected over the weekend, you might consider some alternatives, such as:

  1. Disabling the "Deliver Invoices" cron task on Friday and re-enabling it again on Monday. This can be done manually in the UI or automatically via a plugin.
  2. Continuing to send invoices on the weekend, but now also send them a reminder email on Monday containing a list of all currently unpaid invoices. This would be a plugin.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...