Jump to content

Recommended Posts

Hi,

I am just sharing you my experiences that is found by me. 

After change my new Billing address with  new Tax no, all existing paid/ unpaid invoices are showing new address with new Tax no. That is major bugs. All existing paid invoices should be  unchanged.  Just like the Client information.   

 

Share this post


Link to post
Share on other sites
Posted (edited)

That's not a bug but how WHMCS works. Your company details on invoices come "live" from database. Changing the address will result in changes on all the issued proformas and invoices. Here is how you can solve your problem. First off use this hook point to override Company Details from viewinvoice.tpl depending on dates. The script is commented. Change it to match your needs.

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAreaPageViewInvoice', 1, function($vars)
{
    $InvoiceDate = Capsule::table('tblinvoices')->where('id', $vars['invoiceid'])->value('date');

    if ($InvoiceDate <= '2016-12-31')
    {
        // Company Details for all invoices/proformas issued until 2016-12-31
        return array('payto' => 'Milan Ltd.<br>Address 100<br>Metropolis, MM<br>US');
    }
    elseif ($InvoiceDate <= '2017-12-31')
    {
        // Company Details for all invoices/proformas issued from 2017-01-01 to 2017-12-31
        return array('payto' => 'Juventus Ltd.<br>Address 200<br>Atlantis, AA<br>GR');
    }
    elseif ($InvoiceDate <= '2018-12-31')
    {
        // Company Details for all invoices/proformas issued from 2018-01-01 to 2018-12-31
        return array('payto' => 'Inter Ltd.<br>Address 300<br>Gotham City, GC<br>US');
    }

    // What happens in 2019, 2020, 2021 and so on? The default Pay To Text will be used (Setup > General Settings > General > Pay To Text)
});

Open templates/{YOUR_TEMPLATE}/invoicepdf.tpl and place the code provided below anywhere you want before this statement:

foreach ($companyaddress as $addressLine) {

Code:

# Conditional Company Details
if (date('Y-m-d', strtotime($datecreated)) <= '2016-12-31')
{
	$companyaddress[] = 'Milan Ltd.';
	$companyaddress[] = 'Address 100';
	$companyaddress[] = 'Metropolis, MM';
	$companyaddress[] = 'US';
}
elseif (date('Y-m-d', strtotime($datecreated)) <= '2017-12-31')
{
	$companyaddress[] = 'Juventus Ltd.';
	$companyaddress[] = 'Address 200';
	$companyaddress[] = 'Atlantis, AA';
	$companyaddress[] = 'GR';
}
elseif (date('Y-m-d', strtotime($datecreated)) <= '2018-12-31')
{
	$companyaddress[] = 'Inter Ltd.';
	$companyaddress[] = 'Address 300';
	$companyaddress[] = 'Gotham City, US';
	$companyaddress[] = 'US';
}

There are commercial addons that take a snapshot of your own company details  but they're expensive. No need to buy them for such a simple thing.

Edited by Kian

Share this post


Link to post
Share on other sites
44 minutes ago, Kian said:

There are commercial addons that take a snapshot of your own company details  but they're expensive. No need to buy them for such a simple thing.

i'd agree on that - there is a built-in feature called "Store Client Data Snapshot" that locks the client details to as they were when the invoice was first created - but it's only effectively for invoices created *after* you enable the feature, so it wouldn't help with your situation of dealing with existing invoices.

Share this post


Link to post
Share on other sites
4 minutes ago, brian! said:

i'd agree on that - there is a built-in feature called "Store Client Data Snapshot" that locks the client details to as they were when the invoice was first created - but it's only effectively for invoices created *after* you enable the feature, so it wouldn't help with your situation of dealing with existing invoices.

He can't do anything with Snapshots ☹️ The address of his own company has changed.

Share this post


Link to post
Share on other sites
Just now, Kian said:

He can't do anything with Snapshots ☹️ The address of his own company has changed.

aaahh my bad. 😎

that said, you will probably want to be careful when posting code like you did, cos users will blindly just copy & paste it, complain when it doesn't work, and then you'll have to spend longer replying with specific correct code (if you choose to) - welcome to life as a GearHead. ☺️

Share this post


Link to post
Share on other sites
2 hours ago, Kian said:

That's not a bug but how WHMCS works. Your company details on invoices come "live" from database. Changing the address will result in changes on all the issued proformas and invoices. You need to edit your invoicepdf.tpl, quotepdf.tpl, viewinvoice.tpl, viewquote.tpl and place your company details inside an if like follows (it's pseudo-code):


if (INVOICE_DATE <= REFERENCE_DATE)
{
    // My Company Ltd.
    // Old Address 555
    // Atlantia, AA
    // GR
}
else
{
    // My Company Ltd.
    // New Address 999
    // Metropolis, MM
    // US
}

There are commercial addons that take a snapshot of your own company details  but they're expensive. No need to buy them for such a simple thing.

Thanks for guide.

But It`s complicated .  On update , it is not good that all previous  paid invoices updation.  Store Client Data Snapshot - is  only for client data . This is known as bugs.

 

 

Share this post


Link to post
Share on other sites
22 minutes ago, webhostingpeople said:

But It`s complicated .

it's not really - granted, Kian hasn't given you the precise code for each template, but his suggestion is absolutely logical.

32 minutes ago, webhostingpeople said:

On update , it is not good that all previous  paid invoices updation.

if you mean that after every WHMCS update, you'll have to update the templates with these changes, then yes - I can see no simple way around that - although actually you could use an action hook for the html invoice/quote templates (and that might be preferable than editing those templates to avoid update issues), but certainly not for their PDF template equivalents as they don't use hooks.

as Kian says, all invoices are generated from the current values in the database, so if you change your company address today, and view an old invoice from last year, it will use the new address... that's definitely not a bug, it's how WHMCS has always worked... and probably will for the foreseeable future.

Share this post


Link to post
Share on other sites
2 hours ago, brian! said:

that said, you will probably want to be careful when posting code like you did, cos users will blindly just copy & paste it, complain when it doesn't work, and then you'll have to spend longer replying with specific correct code (if you choose to) - welcome to life as a GearHead. ☺️

True. Updated.

1 hour ago, webhostingpeople said:

But It`s complicated .  On update , it is not good that all previous  paid invoices updation.  Store Client Data Snapshot - is  only for client data . This is known as bugs.

Take a look here.

Share this post


Link to post
Share on other sites
5 hours ago, Kian said:

That's not a bug but how WHMCS works. Your company details on invoices come "live" from database. Changing the address will result in changes on all the issued proformas and invoices. Here is how you can solve your problem. First off use this hook point to override Company Details from viewinvoice.tpl depending on dates. The script is commented. Change it to match your needs.


<?php

use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAreaPageViewInvoice', 1, function($vars)
{
    $InvoiceDate = Capsule::table('tblinvoices')->where('id', $vars['invoiceid'])->value('date');

    if ($InvoiceDate <= '2016-12-31')
    {
        // Company Details for all invoices/proformas issued until 2016-12-31
        return array('payto' => 'Milan Ltd.<br>Address 100<br>Metropolis, MM<br>US');
    }
    elseif ($InvoiceDate <= '2017-12-31')
    {
        // Company Details for all invoices/proformas issued from 2017-01-01 to 2017-12-31
        return array('payto' => 'Juventus Ltd.<br>Address 200<br>Atlantis, AA<br>GR');
    }
    elseif ($InvoiceDate <= '2018-12-31')
    {
        // Company Details for all invoices/proformas issued from 2018-01-01 to 2018-12-31
        return array('payto' => 'Inter Ltd.<br>Address 300<br>Gotham City, GC<br>US');
    }

    // What happens in 2019, 2020, 2021 and so on? The default Pay To Text will be used (Setup > General Settings > General > Pay To Text)
});

Open templates/{YOUR_TEMPLATE}/invoicepdf.tpl and place the code provided below anywhere you want before this statement:


foreach ($companyaddress as $addressLine) {

Code:


# Conditional Company Details
if (date('Y-m-d', strtotime($datecreated)) <= '2016-12-31')
{
	$companyaddress[] = 'Milan Ltd.';
	$companyaddress[] = 'Address 100';
	$companyaddress[] = 'Metropolis, MM';
	$companyaddress[] = 'US';
}
elseif (date('Y-m-d', strtotime($datecreated)) <= '2017-12-31')
{
	$companyaddress[] = 'Juventus Ltd.';
	$companyaddress[] = 'Address 200';
	$companyaddress[] = 'Atlantis, AA';
	$companyaddress[] = 'GR';
}
elseif (date('Y-m-d', strtotime($datecreated)) <= '2018-12-31')
{
	$companyaddress[] = 'Inter Ltd.';
	$companyaddress[] = 'Address 300';
	$companyaddress[] = 'Gotham City, US';
	$companyaddress[] = 'US';
}

There are commercial addons that take a snapshot of your own company details  but they're expensive. No need to buy them for such a simple thing.

Thanks for your effort but not perfect.

Share this post


Link to post
Share on other sites
3 minutes ago, webhostingpeople said:

Thanks for your effort but not perfect.

what do you want it to do that it isn't doing ?

Share this post


Link to post
Share on other sites
2 minutes ago, brian! said:

what do you want it to do that it isn't doing ?

It  is using in invoicepdf.tpl  .  Everytime  maintain  invoicepdf.tpl  after updation whmcs. 

  Pay To Text  would be empty in Setup> General

Code  -  if (date('Y-m-d', strtotime($datecreated)) <= '2016-12-31')  is correct but what will be code   after the date  2016-12-31 ?

Share this post


Link to post
Share on other sites
Posted (edited)
14 minutes ago, webhostingpeople said:

It  is using in invoicepdf.tpl  .  Everytime  maintain  invoicepdf.tpl  after updation whmcs. 

That's why...

Before you begin customising it for your needs, the first step is to create your own copy of the template. This ensures your customisations are not lost when updating.

The complete article is here. Now given that you created your own copy of the template, you won't have any issue with updates of WHMCS.

14 minutes ago, webhostingpeople said:

  Pay To Text  would be empty in Setup> General 

Why? Here you just need to keep your company details up to date.

14 minutes ago, webhostingpeople said:

Code  -  if (date('Y-m-d', strtotime($datecreated)) <= '2016-12-31')  is correct but what will be code   after the date  2016-12-31 ? 

Did you read comments?

// Company Details for all invoices/proformas issued until 2016-12-31 --> MILAN LTD.
// Company Details for all invoices/proformas issued from 2017-01-01 to 2017-12-31 --> JUVENTUS.LTD
// Company Details for all invoices/proformas issued from 2018-01-01 to 2018-12-31 --> INTER LTD.
// The default Pay To Text will be used (Setup > General Settings > General > Pay To Text) for invoices/proformas issued from 2019-01-01

In other words in my example I was Milan in 2016, Juventus in 2017, Inter in 2018 and what you have in Pay To Text for 2019, 2020, 2021, 2022 etc.

Edited by Kian

Share this post


Link to post
Share on other sites
2 minutes ago, Kian said:

Now given that you created your own copy of the template, you won't have any issue with updates of WHMCS.

until WHMCS update their template with new variables/coding, and your custom template becomes outdated and bugged.

Share this post


Link to post
Share on other sites
On 7/9/2019 at 4:54 PM, brian! said:

until WHMCS update their template with new variables/coding, and your custom template becomes outdated and bugged.

It keeps your brain young 🙂

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Web Host Pro
      Hi,
      I just upgraded to 7.3.0 and have two issues I noticed right away.
      1. When I try to insert a FAQ into a support ticket. The pop up screen just redirects to the home page when I click on a category link.
      2. On my FAQ page there is double space for each category box on the right. You can see them to the right https://webhost.pro/knowledgebase.php They seems to be double the proper height.
    • By jljubich
      Some email templates were overriten after upgrading to 5.2.6.
       
      Now, clients that should receive related emails in different languages are receiving them in English despite English is not the default one in this installation.
    • By earthgirl
      To reproduce:
      Login as client
      Click View Invoice on product that requires subscription
      Select 2Checkout
      Click Create Automated Recurring Subscription
      ERROR: This file cannot be accessed directly
       
      If I replace the modules/gateways/tco.php with the file from v5.1.2 it works. Has not worked in any update since.
    • By jljubich
      I have noted in WHMCS 5.2.10 (and now in 5.2.12) that Configurable Options were unable to add or edit items when there are about 7 in a list. I mean that items can be added or edited in new lists; but, when reaching a determined number of items, they are not able to be added or edited anymore. Did you also note this issue as well?
    • By dev_sarks
      Hi Guys,
       
      Does anybody have noticed that the WHMCS (version 5.2.12) is not sending Quote Accepted Emails to the clients while accepting the Quote from clientarea....?
       
      As you can see there is one email template "Quote Accepted" which we can used to send email notification to clients when they accept the quote. But for us, only the admin emails are working, not getting any emails to the client email address.
       
      Please test this scenario and reply here if you have facing the same issue. Also please let me know if there is any settings/config to manage this Quote module(didn't disable the sent option in Email Template).
       
       
      Thanks & Regards,
      Salih
  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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