function commerce_billy_invoice_nr_monthly in Commerce Billy 7
Generated monthly invoice number.
1 call to commerce_billy_invoice_nr_monthly()
- commerce_billy_invoice_nr in ./
commerce_billy.module - Sets invoice number on order.
File
- ./
commerce_billy.module, line 106 - Commerce Billy module.
Code
function commerce_billy_invoice_nr_monthly() {
$last_number = commerce_billy_query_variable('commerce_billy_invoice_nr_last');
$current_year = date('Y');
$current_month = date('m');
$id = 1;
if ($last_number) {
if ($last_number['year'] == $current_year && $last_number['month'] == $current_month) {
$id = $last_number['id'] + 1;
}
}
$new_nr_array = array(
'month' => $current_month,
'year' => $current_year,
'id' => $id,
);
variable_set('commerce_billy_invoice_nr_last', $new_nr_array);
return commerce_billy_apply_invoice_nr_pattern($new_nr_array);
}