Jump to content

How to get Proforma Invoice Number Value after the Invoice has been Paid ?


Mas-J

Recommended Posts

Dear All,

I want display some fix virtual account for payment when client view invoice & on PDF.

This Virtual Account is consist of 5 digits our Bank Unique Number + 4 digits customer code from Custom Client fields + 7 digits Proforma Invoice Number

I've succesfully create the custom code in viewinvoice.tpl & invoicepdf.tpl under template folder.

The result is fine if the status still Unpaid because the Proforma Invoice number show as is.

But when this Invoice has been Paid the Invoice Number value from Database is change with sequential Invoice Number, so the custom code that I created didn't show the previous Invoice Number which is a Proforma Invoice Number.

Is there any idea how to get the Proforma Invoice Number after Invoice has been Paid ?

 

Here's my code:

invoicepdf.tpl

#Start - Payment Method
$pdf->SetFont($pdfFont,'',9); 
$paymethhtml = '<table width:"100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0">
		<tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:left;">
			<td width="100%" colspan="2" align="left">
			<h3 class="panel-title"><strong>Special Notes and Instructions</strong></h3>
			</td>
		</tr>';
$paymethhtml .= ' 		
		<tr bgcolor="#fff">
			<td width="15%" align="left">Bank</td>
			<td width="85%" align="left">: BCA KCP Permata Buana</td>
		</tr>';
if ($status == 'Paid') {
	$paymethhtml .= '
		<tr bgcolor="#fff">
				<td width="15%" align="left">A/C Number</td>
				<td width="85%" align="left">: '.$clientsdetails["customfields2"].''.substr($clientsdetails["customfields1"],3).''.$invoicenum.'</td>
		</tr>';
}		
else {
		$paymethhtml .= '
		<tr bgcolor="#fff">
				<td width="15%" align="left">A/C</td>
				<td width="85%" align="left">: '.$clientsdetails["customfields2"].''.substr($clientsdetails["customfields1"],3).''.$invoicenum.'</td>
		</tr>';
}
$paymethhtml .= ' 
		<tr bgcolor="#fff">
			<td width="15%" align="left">Account Name</td>
			<td width="85%" align="left">: '.$clientsdetails["companyname"].'</td>
		</tr>
</table>';

$pdf->writeHTML($paymethhtml, true, false, false, false, '');
#End - Payment Method

 

viewinvoice.tpl

<!--Start - How to Payment-->    
<div class="panel panel-default">
	<div class="panel-heading">
		<h3 class="panel-title"><strong>Special Notes and Instructions</strong></h3>
	</div>

	<div class="panel-body">  
		<div class="table-responsive">
			<table class="table table-condensed" width="100%">
			<thead>
				<tr>
					<td>Bank</td>
					<td>: BCA KCP Permata Buana</td>
				</tr>
			</thead>
			{if $status eq "Paid"}
				<tr>
					<td>A/C</td>
					<td>: {$clientsdetails["customfields2"]}{$clientsdetails["customfields1"]|substr:3}{$invoicenum}</td>
			    </tr>
			{else}
			    <tr>
					<td>A/C</td>
					<td>: {$clientsdetails["customfields2"]}{$clientsdetails["customfields1"]|substr:3}{$invoicenum}</td>
			    </tr>
			{/if}	
				<tr>
					<td>Account Name</td>
					<td>: {$clientsdetails.companyname}</td>
				</tr>
			</table>
		</div>
	</div>
</div>
<!--End - How to Payment-->

 

Link to comment
Share on other sites

10 minutes ago, Mas-J said:

Is there any idea how to get the Proforma Invoice Number after Invoice has been Paid ?

Despite I am not a developer, and so do not understand above code...Sometimes after proforma gets paid, I had need to know what was that proforma number before that proforma converted to invoice (gets paid)...And I saw the only way I found was checking previous emails sent out...Would be a must have a way to track proforma invoice number to.

Sometime clients pay me by bank transfer, so according to my custom email template I advice them to identify on bank payment description inform proforma number  that they receive in their email and also their names on description...and it works fine, so in my bank history payment received I saw there and I make manual payment on WHMCS choosing one of custom mail in payment gateway I have created for each bank account. But after a made manual payment, like you said I can not easily track past proforma number...

Edited by zitu4life
Link to comment
Share on other sites

6 minutes ago, zitu4life said:

But after a made manual payment, like you said I can not easily track past proforma number...

That's my pain, actually I've create custom invoicing module with modulesgarden but it has been over 2 years and still buggy and can't be implemented until now where the one of the feature is adding some notes about proforma invoice number after the invoice Paid. With that I can show the Virtual Account number which is previously as Proforma Invoice Number.

I'm still find some workaround about this, maybe one of the member in here have a solution 🙂

Btw, thanks for the sharing.

Link to comment
Share on other sites

1 hour ago, Mas-J said:

where the one of the feature is adding some notes about proforma invoice number after the invoice Paid.

this would be much appreciated. Would help a lot on tracking things...that also is one those thing that WHMCS helps a lot....actually WHMCS could implement this as core of software...but when we think in future requests we start feel fever 😨

Link to comment
Share on other sites

50 minutes ago, VirtualWorldGlobal said:

Please check the screenshot, the number shown should be the Proforma Invoice number and even when the Proforma Invoice is changed to Tax Invoice after payment this number remains the same as Proforma. Hope this helps...

As far as I know this is not always true since it depends on how Auto-Tags have been used. {NUMBER} in fact doesn't always corresponds to tblinvoice.id (the number in the query string) because it can be freely changed from Tax Configuration > Next Invoice Number. You have two option here:

  • Get rid of {NUMBER} and use ID, it never changes
  • Snapshot invoice numbers
Edited by Kian
Link to comment
Share on other sites

9 hours ago, VirtualWorldGlobal said:

Hi,

Please check the screenshot, the number shown should be the Proforma Invoice number and even when the Proforma Invoice is changed to Tax Invoice after payment this number remains the same as Proforma. Hope this helps...

WHMCS - Invoice #.png

Thanks for the suggestion, but I can't use this method since my Invoice format Tags is not follow the incremental invoice ID.

 

8 hours ago, Kian said:

As far as I know this is not always true since it depends on how Auto-Tags have been used. {NUMBER} in fact doesn't always corresponds to tblinvoice.id (the number in the query string) because it can be freely changed from Tax Configuration > Next Invoice Number. You have two option here:

  • Get rid of {NUMBER} and use ID, it never changes
  • Snapshot invoice numbers

@Kian Do you mean Snapshoot invoice number = Store Client Data Snapshot ?

In my code, I'm using variable from invoice number and when I see the table invoice_mod which is save the data of the invoice, I didn' see the value of it.

Would you elaborate your suggestion, thank you.

 

I've try some workaround, when I add payment to make the invoice become Paid. I added the transacion ID as same as the Virtual Account number.

So, I change the variable when the Invoice Paid using {$transaction.transid|substr:9} instead of {$invoicenum}

Why I substr to 9 ? Because to prevent our Admin if they forgot to input the transaction ID. Instead of show zero value it will show some variable of Custom Client Fields without the proforma invoice number.

This is not solved at all, still need manual input from admin but can be used as workaround for now.

Here's my code if you want to see, check the line substr($trans['transid'],9) on invoicepdf.tpl and {$transaction.transid|substr:9} on viewinvoice.tpl :

invoicepdf.tpl 

#Start - Payment Method
$pdf->SetFont($pdfFont,'',9); 
$paymethhtml = '<table width:"100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0">
		<tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:left;">
			<td width="100%" colspan="2" align="left">
			<h3 class="panel-title"><strong>Special Notes and Instructions</strong></h3>
			</td>
		</tr>';
$paymethhtml .= ' 		
		<tr bgcolor="#fff">
			<td width="15%" align="left">Bank</td>
			<td width="85%" align="left">: BCA KCP Permata Buana</td>
		</tr>';
if ($status == 'Paid') {
	$paymethhtml .= '
		<tr bgcolor="#fff">
				<td width="15%" align="left">A/C Number</td>
				<td width="85%" align="left">: '.$clientsdetails["customfields2"].''.substr($clientsdetails["customfields1"],3).''. substr($trans['transid'],9) .'</td>
		</tr>';
}		
else {
		$paymethhtml .= '
		<tr bgcolor="#fff">
				<td width="15%" align="left">A/C</td>
				<td width="85%" align="left">: '.$clientsdetails["customfields2"].''.substr($clientsdetails["customfields1"],3).''.$invoicenum.'</td>
		</tr>';
}
$paymethhtml .= ' 
		<tr bgcolor="#fff">
			<td width="15%" align="left">Account Name</td>
			<td width="85%" align="left">: '.$clientsdetails["companyname"].'</td>
		</tr>
</table>';

$pdf->writeHTML($paymethhtml, true, false, false, false, '');
#End - Payment Method

 

viewinvoice.tpl

<!--Start - How to Payment-->    
<div class="panel panel-default">
	<div class="panel-heading">
		<h3 class="panel-title"><strong>Special Notes and Instructions</strong></h3>
	</div>

	<div class="panel-body">  
		<div class="table-responsive">
			<table class="table table-condensed" width="100%">
			<thead>
				<tr>
					<td>Bank</td>
					<td>: BCA KCP Permata Buana</td>
				</tr>
			</thead>
			{if $status eq "Paid"}
				<tr>
					<td>A/C</td>
					<td>: {$clientsdetails["customfields2"]}{$clientsdetails["customfields1"]|substr:3}{$transaction.transid|substr:9}</td>
			    </tr>
			{else}
			    <tr>
					<td>A/C</td>
					<td>: {$clientsdetails["customfields2"]}{$clientsdetails["customfields1"]|substr:3}{$invoicenum}</td>
			    </tr>
			{/if}	
				<tr>
					<td>Account Name</td>
					<td>: {$clientsdetails.companyname}</td>
				</tr>
			</table>
		</div>
	</div>
</div>
<!--End - How to Payment-->

 

Any suggestion will be appreciated 🙂 

Link to comment
Share on other sites

On 5/20/2020 at 1:38 AM, Kian said:

As far as I know this is not always true

Hi @Kian you will always be knowing this better than many. 

 

On 5/20/2020 at 1:38 AM, Kian said:

Get rid of {NUMBER} and use ID, it never changes

Yes we have been doing this...

 

On 5/20/2020 at 10:23 AM, Mas-J said:

Thanks for the suggestion, but I can't use this method since my Invoice format Tags is not follow the incremental invoice ID.

@Mas-J  Yes surely, requirements vary user to user :)

 

We use WHMCS for Billing clients (GST Invoicing) and always try to keep it as simple as possible. 

We use another offline Accounting software...we keep the Proforma Number and date details here for reference and can trace it down later.

The  Accounting softwar we use also offers a Free Version and is quite effective and fulfills most of basic accounting needs...

http://busy.in/index.php?p=fas

 

 

 

 

 

 

Edited by VirtualWorldGlobal
Link to comment
Share on other sites

On 5/20/2020 at 6:53 AM, Mas-J said:

Do you mean Snapshoot invoice number = Store Client Data Snapshot ?

Invoice numbers (aka {NUMBER} and tblinvoices.invoicenum) are not part of Snapshots.

I was saying that the only way to preserve this value is that you code an action hook that stores it somewhere. Basically I'm suggesting to extend the concept of "Client Data Snapshot" to invoice numbers. This way you always know what was the original number the proforma before it turned into an invoice. It sounds boring... well it is.

The quickest workaround is to do what @VirtualWorldGlobal suggested. Get rid of {NUMBER} and use {ID} so that you can do the following.

 

Link to comment
Share on other sites

35 minutes ago, Kian said:

Get rid of {NUMBER} and use {ID}

Hello guys, when you say Get rid of {NUMBER} and use {ID}, means changed Setup>General>Settings>Invoices ???

image.thumb.png.951d8804061aa9457462b5117753327b.png

 

Change it to...

image.png.4be607890ed814cae886e9aec24c3a3a.png

Edited by zitu4life
If so, this is better do be implemented for next year or anytime?
Link to comment
Share on other sites

As briand said, {ID} doesn't exist but if you print() and {debug} for sure you can find the ID somewhere.

Anyway you can add as many auto-tags as you want with action hooks so that things like {ID}, {COUNTRY}, {CURRENCY} etc. will work.

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.

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