1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02: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 = [
'literal' => [
':MONTHYEAR' => \sprintf(
'%s %s',
Carbon::createFromDate(now()->month)->translatedFormat('F'),
now()->year,
),
':MONTH' => Carbon::createFromDate(now()->year, now()->month)->translatedFormat('F'),
':YEAR' => now()->year,
':QUARTER' => 'Q' . now()->quarter,
@ -139,6 +144,7 @@ class Helpers
),
],
'raw' => [
':MONTHYEAR' => now()->month,
':MONTH' => now()->month,
':YEAR' => now()->year,
':QUARTER' => now()->quarter,
@ -256,6 +262,18 @@ class Helpers
$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(
$target, $output, $value, 1
);