mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-16 12:57:32 -04:00
Add $YCO parameter (invoice numbering per year)
This commit is contained in:
@@ -279,11 +279,18 @@ class Sales extends Secure_area
|
||||
if (empty($invoice_number))
|
||||
{
|
||||
$invoice_number=$this->config->config['sales_invoice_format'];
|
||||
// don't query if this variable isn't used
|
||||
if (strstr($invoice_number,'$YCO'))
|
||||
{
|
||||
$invoice_number_year=$this->Sale->get_invoice_number_for_year(date('Y'));
|
||||
$invoice_number=str_replace('$YCO',$invoice_number_year,$invoice_number);
|
||||
}
|
||||
}
|
||||
$invoice_count=$this->Sale->get_invoice_count();
|
||||
$invoice_number=str_replace('$CO',$invoice_count,$invoice_number);
|
||||
$invoice_count=$this->Sale_suspended->get_invoice_count();
|
||||
$invoice_number=str_replace('$SCO',$invoice_count,$invoice_number);
|
||||
|
||||
$invoice_number=strftime($invoice_number);
|
||||
|
||||
$customer_id=$this->sale_lib->get_customer();
|
||||
|
||||
@@ -22,6 +22,16 @@ class Sale extends CI_Model
|
||||
$this->db->where('invoice_number', $invoice_number);
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
function get_invoice_number_for_year($year, $start_from = 0)
|
||||
{
|
||||
$this->db->select("COUNT( 1 ) AS invoice_number_year", FALSE);
|
||||
$this->db->from('sales');
|
||||
$this->db->where("DATE_FORMAT(sale_time, '%Y' ) = ", $year, FALSE);
|
||||
$this->db->where("invoice_number IS NOT ", "NULL", FALSE);
|
||||
$result = $this->db->get()->row_array();
|
||||
return ($start_from + $result[ 'invoice_number_year' ] + 1);
|
||||
}
|
||||
|
||||
function exists($sale_id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user