1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Add dedicated :MONTHYEAR reserved keyword

This commit is contained in:
David Bomba 2022-06-18 14:25:29 +10:00
parent 81e507271a
commit 7b7fbc5c13

View File

@ -116,6 +116,11 @@ class Helpers
$replacements = [ $replacements = [
'literal' => [ 'literal' => [
':MONTHYEAR' => \sprintf(
'%s %s',
Carbon::createFromDate(now()->month)->translatedFormat('F'),
now()->year,
),
':MONTH' => Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F'), ':MONTH' => Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F'),
':YEAR' => now()->year, ':YEAR' => now()->year,
':QUARTER' => 'Q' . now()->quarter, ':QUARTER' => 'Q' . now()->quarter,
@ -139,6 +144,7 @@ class Helpers
), ),
], ],
'raw' => [ 'raw' => [
':MONTHYEAR' => now()->month,
':MONTH' => now()->month, ':MONTH' => now()->month,
':YEAR' => now()->year, ':YEAR' => now()->year,
':QUARTER' => now()->quarter, ':QUARTER' => now()->quarter,
@ -256,6 +262,18 @@ class Helpers
$output = \Carbon\Carbon::create()->month($output)->translatedFormat('F'); $output = \Carbon\Carbon::create()->month($output)->translatedFormat('F');
} }
if ($matches->keys()->first() == ':MONTHYEAR') {
$final_date = now()->addMonths($output-now()->month);
$output = \sprintf(
'%s %s',
$final_date->translatedFormat('F'),
$final_date->year,
);
}
$value = preg_replace( $value = preg_replace(
$target, $output, $value, 1 $target, $output, $value, 1
); );