[Vtigercrm-developers] extra functionality for invoices

J.P.C. Spiekman pieter at spiekman.nl
Fri Jan 19 07:50:51 PST 2007


Hello,

I don't know if this is the right way to send you my contribution for future
releases vtiger, but i hope that someone who is 'responsible' for the
releases can pick it up and implement/use it in future releases.

first, the change request.
- I needed a way to generate invoice numbers in a way that every year a
counter starts at zero, and every new invoice has an ascending invoice ID,
without gaps. eg; 20070001, 20070002, 20070003, 20070004, and so on.

I have implemented this on the following way, using the subject field in
Invoice.

//Append in EditView.php after line 40 ($rate = $rate_symbol['rate'];)

$invoice_number = getInvoiceNumber();
$focus->column_fields['subject'] = $invoice_number;

//Place the function below in CommonUtils.php:
 
// Extra function to create unique invoice_number
function getInvoiceNumber() {
	global $adb;
	$sql="select max(subject) as aantal from vtiger_invoice where
Year(invoicedate) = year(now())";
	$result = $adb->query($sql);
  $invoice_subject=  $adb->query_result($result,0,"aantal");
// strip off year from invoice_number/subject
   $invoice_subject = substr($invoice_subject,4,4);
// raise last invoice_number of invoice with 1
	$invoice_count = $invoice_subject + 1;
	$invoice_count = str_repeat("0",4-strlen($invoice_count)).$invoice_count;
	$invoice_year = date("Y");
	$invoice_number= $invoice_year.$invoice_count;
	return $invoice_number;
}



Best Regards,

Pieter

________________________________________________
Message sent using UebiMiau 2.7.10





More information about the vtigercrm-developers mailing list