mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-29 07:26:05 +00:00
fiscal year start
This commit is contained in:
@@ -1243,6 +1243,49 @@ class Base
|
||||
];
|
||||
break;
|
||||
|
||||
case 'currentFiscalYear':
|
||||
case 'lastFiscalYear':
|
||||
$dtToday = new \DateTime();
|
||||
$dt = new \DateTime();
|
||||
$fiscalYearShift = $this->getConfig()->get('fiscalYearShift', 0);
|
||||
$dt->modify('first day of January this year')->modify('+' . $fiscalYearShift . ' months');
|
||||
if (intval($dtToday->format('m')) < $fiscalYearShift + 1) {
|
||||
$dt->modify('-1 year');
|
||||
}
|
||||
if ($type === 'lastFiscalYear') {
|
||||
$dt->modify('-1 year');
|
||||
}
|
||||
$part['AND'] = [
|
||||
$attribute . '>=' => $dt->format('Y-m-d'),
|
||||
$attribute . '<' => $dt->add(new \DateInterval('P1Y'))->format('Y-m-d')
|
||||
];
|
||||
break;
|
||||
|
||||
case 'currentFiscalQuarter':
|
||||
case 'lastFiscalQuarter':
|
||||
$dtToday = new \DateTime();
|
||||
$dt = new \DateTime();
|
||||
$fiscalYearShift = $this->getConfig()->get('fiscalYearShift', 0);
|
||||
$dt->modify('first day of January this year')->modify('+' . $fiscalYearShift . ' months');
|
||||
$month = intval($dtToday->format('m'));
|
||||
$quarterShift = floor(($month - $fiscalYearShift - 1) / 3);
|
||||
if ($quarterShift) {
|
||||
if ($quarterShift >= 0) {
|
||||
$dt->add(new \DateInterval('P'.($quarterShift * 3).'M'));
|
||||
} else {
|
||||
$quarterShift *= -1;
|
||||
$dt->sub(new \DateInterval('P'.($quarterShift * 3).'M'));
|
||||
}
|
||||
}
|
||||
if ($type === 'lastFiscalQuarter') {
|
||||
$dt->modify('-3 months');
|
||||
}
|
||||
$part['AND'] = [
|
||||
$attribute . '>=' => $dt->format('Y-m-d'),
|
||||
$attribute . '<' => $dt->add(new \DateInterval('P3M'))->format('Y-m-d')
|
||||
];
|
||||
break;
|
||||
|
||||
case 'between':
|
||||
if (is_array($value)) {
|
||||
$part['AND'] = [
|
||||
|
||||
@@ -576,7 +576,11 @@
|
||||
"ever": "Ever",
|
||||
"isEmpty": "Is Empty",
|
||||
"olderThanXDays": "Older Than X Days",
|
||||
"afterXDays": "After X Days"
|
||||
"afterXDays": "After X Days",
|
||||
"currentFiscalYear": "Current Fiscal Year",
|
||||
"lastFiscalYear": "Last Fiscal Year",
|
||||
"currentFiscalQuarter": "Current Fiscal Quarter",
|
||||
"lastFiscalQuarter": "Last Fiscal Quarter"
|
||||
},
|
||||
"searchRanges": {
|
||||
"is": "Is",
|
||||
|
||||
@@ -105,7 +105,8 @@
|
||||
"emailAddressIsOptedOutByDefault": "Mark new email addresses as opted-out",
|
||||
"outboundEmailBccAddress": "BCC address for external clients",
|
||||
"cleanupDeletedRecords": "Clean up deleted records",
|
||||
"addressCountryList": "Address Country Autocomplete List"
|
||||
"addressCountryList": "Address Country Autocomplete List",
|
||||
"fiscalYearShift": "Fiscal Year Start"
|
||||
},
|
||||
"options": {
|
||||
"weekStart": {
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
[{"name": "dateFormat"}, {"name": "weekStart"}],
|
||||
[{"name": "timeFormat"}, {"name": "thousandSeparator"}],
|
||||
[{"name": "addressFormat"}, {"name": "decimalMark"}],
|
||||
[{"name": "addressPreview"}, {"name": "addressCountryList"}]
|
||||
[{"name": "addressPreview"}, {"name": "addressCountryList"}],
|
||||
[{"name": "fiscalYearShift"}, false]
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
"options": [0, 1],
|
||||
"default": 0
|
||||
},
|
||||
"fiscalYearShift": {
|
||||
"type": "enumInt",
|
||||
"default": 0,
|
||||
"view": "views/settings/fields/fiscal-year-shift"
|
||||
},
|
||||
"thousandSeparator": {
|
||||
"type": "varchar",
|
||||
"default": ",",
|
||||
|
||||
@@ -48,6 +48,16 @@ Espo.define('views/fields/date', 'views/fields/base', function (Dep) {
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
if (this.getConfig().get('fiscalYearShift')) {
|
||||
this.searchTypeList = Espo.Utils.clone(this.searchTypeList);
|
||||
if (this.getConfig().get('fiscalYearShift') % 3 != 0) {
|
||||
this.searchTypeList.push('currentFiscalQuarter');
|
||||
this.searchTypeList.push('lastFiscalQuarter');
|
||||
}
|
||||
this.searchTypeList.push('currentFiscalYear');
|
||||
this.searchTypeList.push('lastFiscalYear');
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
|
||||
43
client/src/views/settings/fields/fiscal-year-shift.js
Normal file
43
client/src/views/settings/fields/fiscal-year-shift.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2018 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/settings/fields/fiscal-year-shift', 'views/fields/enum-int', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setupOptions: function () {
|
||||
this.params.options = [];
|
||||
this.translatedOptions = {};
|
||||
var monthNameList = this.getLanguage().get('Global', 'lists', 'monthNames') || [];
|
||||
monthNameList.forEach(function (name, i) {
|
||||
this.params.options.push(i);
|
||||
this.translatedOptions[i] = name;
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user