You are here

function commerce_billy_invoice_nr_yearly in Commerce Billy 7

Generated yearly invoice number.

1 call to commerce_billy_invoice_nr_yearly()
commerce_billy_invoice_nr in ./commerce_billy.module
Sets invoice number on order.

File

./commerce_billy.module, line 131
Commerce Billy module.

Code

function commerce_billy_invoice_nr_yearly() {
  $last_number = commerce_billy_query_variable('commerce_billy_invoice_nr_last');
  $current_year = date('Y');
  $id = 1;
  if ($last_number) {
    if ($last_number['year'] == $current_year) {
      $id = $last_number['id'] + 1;
    }
  }
  $new_nr_array = array(
    '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);
}