Jump to content

Send Updated Invoice (Automatically)


Bertie

Recommended Posts

Hi,

Is there a way if a client disables auto-renew on a domain name which then removes it from an active invoice. That specific invoice is then re-sent out to the client? For example an invoice on a clients account had two items. One of them was removed as they disabled auto-renew on the domain name. Is it possible to make that invoice to be sent back to the client via email with the updated version? 

It would only make sense if the invoice had multiple products on them though so not sure if that makes it even harder to do. 

Have an awkward accounts department for a client who refuses to log into the portal to see the updated invoices. So seeing if there is an easier way to make this better for everyone involved. 

Cheers,

Edited by Bertie
Link to comment
Share on other sites

I think you could use this hook: UpdateInvoiceTotal

Quote

Executes when an invoice is updated with changes to or additions of line items. Can be used to manipulate the invoice.

Try this:

<?php
 /**
  * WHMCS hook that will automatically send the 'Invoice Modified' once an invoice is modified
  * @author DennisHermannsen
  */
add_hook('UpdateInvoiceTotal', 1, function($vars) {
	$command = 'SendEmail';
	$postData = array(
		'messagename' => 'Invoice Modified',
		'id' => $vars['invoiceid'],
	);

	localAPI($command, $postData);

});

I've tested it on my dev installation and it seems to work just fine.

I'm using this API call: https://developers.whmcs.com/api-reference/sendemail/

 

Edit: A thing that is worth to mention is that laws in some countries doesn't allow you to change anything (not even the address or name of receiver) about an invoice once it has been sent. Unfortunately, WHMCS doesn't care for this at all and will still modify the invoices. It's a shame.

Edited by DennisHermannsen
Link to comment
Share on other sites

46 minutes ago, DennisHermannsen said:

I think you could use this hook: UpdateInvoiceTotal

Try this:


<?php
 /**
  * WHMCS hook that will automatically send the 'Invoice Modified' once an invoice is modified
  * @author DennisHermannsen
  */
add_hook('UpdateInvoiceTotal', 1, function($vars) {
	$command = 'SendEmail';
	$postData = array(
		'messagename' => 'Invoice Modified',
		'id' => $vars['invoiceid'],
	);

	localAPI($command, $postData);

});

I've tested it on my dev installation and it seems to work just fine.

I'm using this API call: https://developers.whmcs.com/api-reference/sendemail/

 

Edit: A thing that is worth to mention is that laws in some countries doesn't allow you to change anything (not even the address or name of receiver) about an invoice once it has been sent. Unfortunately, WHMCS doesn't care for this at all and will still modify the invoices. It's a shame.

I shall give it a go and see what happens. Regarding your last comment:

Yeah I've seen that a credit note function was requested 4 years ago and it's still in "Planned" status. Really not sure what is taking so long considering many countries require such things. 

Link to comment
Share on other sites

1 hour ago, Bertie said:

Really not sure what is taking so long considering many countries require such things. 

Time and effort.

It takes time to learn accounting laws for a single country. It takes forever to learn the laws of every country.

Sadly, that's not an excuse. The more I've learned about different countries' laws about accounting, the more it feels like WHMCS is made solely by developers without much input from accountants.

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