Skip to content

Commit

Permalink
setting that named as financial year denote added to localization p…
Browse files Browse the repository at this point in the history
…art and it will be considered on the preparation of reports
  • Loading branch information
sevannerse committed Feb 12, 2021
1 parent 9665d8d commit 52cf468
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4 deletions.
10 changes: 9 additions & 1 deletion app/Abstracts/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,15 @@ public function getFormattedDate($date)
{
switch ($this->getSetting('period')) {
case 'yearly':
$i = $date->copy()->format($this->getYearlyDateFormat());
$financial_year = $this->getFinancialYear($this->year);

if ($date->greaterThanOrEqualTo($financial_year->getStartDate()) && $date->lessThanOrEqualTo($financial_year->getEndDate())) {
if (setting('localisation.financial_year_denote') == 'begins') {
$i = $financial_year->getStartDate()->copy()->format($this->getYearlyDateFormat());
} else {
$i = $financial_year->getEndDate()->copy()->format($this->getYearlyDateFormat());
}
}

break;
case 'quarterly':
Expand Down
8 changes: 7 additions & 1 deletion app/Http/Controllers/Settings/Localisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ public function edit()
'both' => trans('settings.localisation.discount_location.both'),
];

$financial_year_denote_options = [
'begins' => trans('settings.localisation.financial_year_denote.begins'),
'ends' => trans('settings.localisation.financial_year_denote.ends'),
];

return view('settings.localisation.edit', compact(
'timezones',
'date_formats',
'date_separators',
'percent_positions',
'discount_locations'
'discount_locations',
'financial_year_denote_options'
));
}
}
10 changes: 8 additions & 2 deletions app/Traits/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,20 @@ public function getFinancialStart($year = null)

$financial_start = Date::create($year, $month, $day);

// Check if FS is in last calendar year
if ($now->diffInDays($financial_start, false) > 0) {
if (setting('localisation.financial_year_denote') == 'ends' && $financial_start->dayOfYear != 1) {
$financial_start->subYear();
}

return $financial_start;
}

public function getFinancialYear($year = null)
{
$start = $this->getFinancialStart($year);

return CarbonPeriod::create($start, $start->copy()->addYear()->subDay());
}

public function getFinancialQuarters($year = null)
{
$quarters = [];
Expand Down
1 change: 1 addition & 0 deletions config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
'date_separator' => env('SETTING_FALLBACK_LOCALISATION_DATE_SEPARATOR', 'space'),
'percent_position' => env('SETTING_FALLBACK_LOCALISATION_PERCENT_POSITION', 'after'),
'discount_location' => env('SETTING_FALLBACK_LOCALISATION_DISCOUNT_LOCATION', 'total'),
'financial_year_denote' => env('SETTING_FALLBACK_LOCALISATION_FINANCIAL_YEAR_DENOTE', 'ends'),
],
'invoice' => [
'number_prefix' => env('SETTING_FALLBACK_INVOICE_NUMBER_PREFIX', 'INV-'),
Expand Down
5 changes: 5 additions & 0 deletions resources/lang/en-GB/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
'total' => 'At total',
'both' => 'Both line and total',
],
'financial_year_denote' => [
'title' => 'Financial Year Denote',
'begins' => 'By the year it begins',
'ends' => 'By the year it ends',
],
],

'invoice' => [
Expand Down
5 changes: 5 additions & 0 deletions resources/lang/tr-TR/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
'total' => 'Toplamda',
'both' => 'Satırda ve toplamda',
],
'financial_year_denote' => [
'title' => 'Mali Yıl Gösterimi',
'begins' => 'Başlangıç Yılı',
'ends' => 'Bitiş Yılı',
],
],

'invoice' => [
Expand Down
2 changes: 2 additions & 0 deletions resources/views/settings/localisation/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<div class="row">
{{ Form::dateGroup('financial_start', trans('settings.localisation.financial_start'), 'calendar', ['id' => 'financial_start', 'class' => 'form-control datepicker', 'show-date-format' => 'j F', 'date-format' => 'd-m', 'autocomplete' => 'off'], setting('localisation.financial_start')) }}

{{ Form::selectGroup('financial_year_denote', trans('settings.localisation.financial_year_denote.title'), 'calendar', $financial_year_denote_options, setting('localisation.financial_year_denote'), []) }}

{{ Form::selectGroupGroup('timezone', trans('settings.localisation.timezone'), 'globe', $timezones, setting('localisation.timezone'), []) }}

{{ Form::selectGroup('date_format', trans('settings.localisation.date.format'), 'calendar', $date_formats, setting('localisation.date_format'), ['autocomplete' => 'off']) }}
Expand Down

0 comments on commit 52cf468

Please sign in to comment.