Skip to content

Commit

Permalink
remove invoice-new-year-reset option
Browse files Browse the repository at this point in the history
  • Loading branch information
timiwahalahti committed Jul 20, 2023
1 parent 45cc50e commit 4e7676d
Showing 1 changed file with 1 addition and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ public static function invoice_settings( $section ) {
sprintf( __( 'Allow ticket buyers to ask for an invoice when purchasing their tickets.', 'wordcamporg' ), date( 'Y' ) )
);

$camptix->add_settings_field_helper(
'invoice-new-year-reset',
__( 'Yearly reset', 'wordcamporg' ),
'field_yesno',
'invoice',
// translators: %1$s is a date.
sprintf( __( 'Invoice numbers are prefixed with the year, and will be reset on the 1st of January (e.g. %1$s-125)', 'wordcamporg' ), date( 'Y' ) )
);

add_settings_field(
'invoice-date-format',
__( 'Date format', 'wordcamporg' ),
Expand Down Expand Up @@ -166,9 +157,6 @@ public static function validate_options( $output, $input ) {
if ( isset( $input['invoice-active'] ) ) {
$output['invoice-active'] = (int) $input['invoice-active'];
}//end if
if ( isset( $input['invoice-new-year-reset'] ) ) {
$output['invoice-new-year-reset'] = (int) $input['invoice-new-year-reset'];
}//end if
if ( isset( $input['invoice-date-format'] ) ) {
$output['invoice-date-format'] = $input['invoice-date-format'];
}//end if
Expand Down Expand Up @@ -234,15 +222,6 @@ public static function create_invoice_number() {
$opt = get_option( 'camptix_options' );
$current = get_option( 'invoice_current_number', 1 );

$year = date( 'Y' );
if ( ! empty( $opt['invoice-new-year-reset'] ) ) {
if ( ! empty( $opt['invoice-current-year'] ) && $opt['invoice-current-year'] !== $year ) {
$current = 1;
$opt['invoice-current-year'] = $year;
update_option( 'camptix_options', $opt );
}//end if
}//end if

/**
* Sets the current invoice number.
*
Expand All @@ -251,11 +230,7 @@ public static function create_invoice_number() {
$current = apply_filters( 'tix_invoice_current_number', $current );
update_option( 'invoice_current_number', $current + 1 );

if ( empty( $opt['invoice-new-year-reset'] ) ) {
return sprintf( '%s-%s', get_current_blog_id(), $current );
} else {
return sprintf( '%s-%s-%s', get_current_blog_id(), $year, $current );
}
return sprintf( '%s-%s', get_current_blog_id(), $current );
}

/**
Expand Down

0 comments on commit 4e7676d

Please sign in to comment.