Jump to content

API addinvoicepayment duplicates Sequential Paid Invoice Numbering


Recommended Posts

===========DESCRIPTION===========

When I make several calls to addinvoicepayment api AND unpaid invoices do have an invoice number, then THE SAME sequential paid number is applied to each invoice, even when the next paid number in incremented in settings, so it generates duplicated invoice numbers.

 

=========STEPS TO REPLICATE=========

Normal process:

- I'm using "Sequential Paid Invoice Numbering"

- Sequential Invoice Number Format is "PAID{NUMBER}"

- I generate a couple of invoices

- I check "Next Paid Invoice Number"

- I run "addinvoicepayment" local api from inside a loop

- Those invoices get paid

- Sequential number is asigned to each one

- "Next Paid Invoice Number" has been incremented by 2

Up to here, everything is right :-)

 

But EU VAT Addon let me use a "Custom Invoice Numbering" for unpaid invoices, so I enable it and make the same test:

 

Weird behavior:

- I'm using "Custom Invoice Numbering" FACT-{NUMBER}

- Next Invoice Number: 101

- I'm using "Sequential Paid Invoice Numbering" PAID{NUMBER}

- Next Paid Invoice Number: 201

- I generate a couple of invoices (id 38 and 39)

- these invoices get an unpaid invoice number (FACT-101 and FACT-102)

- I run "addinvoicepayment" local api from inside a loop

- Those invoices get paid

- but *the same Paid Invoice Number* is assigned to both of them

- even when "Next Paid Invoice Number" has been incremented by 2!

Please, see attached images for before and after information

 

=======ADDITIONAL INFORMATION======

Affected versions (tested) 5.2.16 and 5.3.3

Only happens when "EU VAT Addon" is used AND "Custom Invoice Numbering" is enabled.

 

Attached a simple hook for testing this issue:

<?php

if (!defined("WHMCS"))
die("This file cannot be accessed directly");

function doit($vars) {

$command           = "addinvoicepayment";
$adminuser         = "admin";
$values["transid"] = "TEST-123456";
$values["amount"]  = "10";
$values["gateway"] = "banktransfer";

// enter your invoices IDs here
$invoices = array(7,;

foreach($invoices as $invoiceid) {
	$values["invoiceid"] = $invoiceid;
	$results = localAPI($command,$values,$adminuser);
	echo "<pre>\n"; var_dump($results); echo "</pre>\n";
}
die();
}

add_hook("ClientAreaPage",1,"doit");

addinvoicepayment.zip

01_before.jpg

02_after.jpg

03_result.jpg

Edited by egrueda
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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