Jump to content

Decrease Invoice Count Cronjob


chrigu

Recommended Posts

Hello guys.

We are devloping a module, which groups all our invoices each month. When the cronjob creates an invoice, we are going to delete it.
For correct the number of created invoices the cronjob sends, we need to decrease. Do you have any idea, how we can do that?


Thanks!

Link to comment
Share on other sites

With SQL in 5 action hooks. It's pretty much complicated as some of these hooks run "in the same time". Some other work conditionally depending on WHMCS configuration. As if it wasn't enough, you have to keep in mind that WHMCS issues invoices in a lot of different ways. Detecting them is crucial otherwise you'll cause billing errors. Lastly some types of invoices can't be deleted and you can't just decrease invoice count by 1.

Good luck, you'll need it 🤐

Link to comment
Share on other sites

I would agree with @Kian on this. I've attempted such an addon myself, but have never fiinished it due to the complexity and the nature of some processes in WHMCS. Also seen colleagues create such an addon, but it never really functioned without issues (and there would be a large business for this addon if it would).

Besides, if you really do want to  alter this number in the cronjob e-mail - you should be able to do so with the `PostAutomationTask`, like so:

<?php

add_hook('PostAutomationTask', 1, function($vars) {
        if (!($vars instanceof \WHMCS\Cron\Task\CreateInvoices)) {
                return;
        }

        $vars->output('invoice.created')->write(13);
});

In this case 13 is the random number you want to set in the invoice e-mail. I'm not aware of the side effects, so please use with care.

Edited by Wouter0100
Link to comment
Share on other sites

12 hours ago, Wouter0100 said:

I would agree with @Kian on this. I've attempted such an addon myself, but have never fiinished it due to the complexity and the nature of some processes in WHMCS. Also seen colleagues create such an addon, but it never really functioned without issues (and there would be a large business for this addon if it would).

Besides, if you really do want to  alter this number in the cronjob e-mail - you should be able to do so with the `PostAutomationTask`, like so:


<?php

add_hook('PostAutomationTask', 1, function($vars) {
        if (!($vars instanceof \WHMCS\Cron\Task\CreateInvoices)) {
                return;
        }

        $vars->output('invoice.created')->write(13);
});

In this case 13 is the random number you want to set in the invoice e-mail. I'm not aware of the side effects, so please use with care.

Thank you, great!

We have a lot of different cases and work since month on this plugin. I think we are done so far and we also support some 3rd party plugins.
It would be great if you tell me, what your issues was. So maybe we can cross check if we already work with them. It would be great to hear a 2nd workflow.

Thank you!

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
Reply to this topic...

×   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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated