Jump to content

Invoice marked as paid -> Next Due Date changes - How to stop it?


kon
Go to solution Solved by DennisHermannsen,

Recommended Posts

Hello,

The current/normal WHMCS operation is the following:

  • On an invoice we add a payment
  • Invoice status changes to paid
  • Next Due Date changes according to the invoice

Although the thought behind this system is pretty good, it causes us troubles quite frequently. Until we make our internal operation system completely automatic, we can't make use of this logic.

We want to stop the trigger which changes the Next Due Date when we add a payment to an invoice. We'd like to manually update the Next Due Date and the Expiry Date.

Ideally, in the future when we will fix our internal operation we'd like to bring the current/normal operation back.

 

How can we disable this trigger?

Using WHMCS v8.8.0.

 

Kindest regards

Edited by kon
Link to comment
Share on other sites

  • Solution
14 hours ago, kon said:

How can we disable this trigger?

That's the neat part. You don't. It's hardcoded 🙂
You can work around the issue with hooks. You could also change the billing cycle to "One time" - that should provide exactly what you're looking for, although clients could be confused when they see their billing cycle being "One time payment".

Link to comment
Share on other sites

  • 2 weeks later...

Hi Kon, 
      For this, you need a custom Hook. I create Hook for you as per your requirement. please save this code in a PHP file with any file name example "Due_date_Hook.php" and Upload it in your WHMCS Install Directory -> Includes -> Hooks that is 
 

<?php
/**
 * Restore Due Date Hook Function
 *
 * @package    NHGroup
 * @author     Network Hosting Group
 * @copyright  Copyright (c) Network Hosting Group 2023-2033
 * @license    https://networkhostinggroup.com/terms-of-service
 * @version    1.0.0
 * @link       https://networkhostinggroup.com/
 */
 
if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

use Illuminate\Database\Capsule\Manager as Capsule;
use Carbon\Carbon;

function override_next_due_date($table,$id,$date){
    $data = Capsule::table($table)->where('id',$id)->update(array('nextduedate'=>$date,'nextinvoicedate'=>$date));
    return true;
};
add_hook('InvoicePaid', 1, function($vars) {
    $command = 'GetInvoice';
    $postData = array(
        'invoiceid' => $vars['invoiceid'],
    );
    $results = localAPI($command, $postData);
    $invoice_due_date = $results['duedate'];
    foreach($results['items']['item'] as $item){
        if($item['type']=="Hosting"){
            override_next_due_date("tblhosting",$item['relid'],$invoice_due_date);
        }elseif(strpos($item['type'], "omain")>0){
            override_next_due_date("tbldomains",$item['relid'],$invoice_due_date);
        }
    }
});

?>

It just keeps your old due date after an invoice is paid. 

Note: If you use this type of scenario then you should disable your daily cron jobs because if you do not disable this then in the next daily cron job the invoice for that service is generated again. Because your due date is not changed. 

If this works for your please mark it as a solution. 

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