Skip to content

Commit

Permalink
VCST-916: Update last-xxx filters (#414)
Browse files Browse the repository at this point in the history
feat: Updates last-xxx filters with these rules:

Today.
Last Day - Display date range from the day before the current date (exclusive) to the current date at midnight (exclusive).
Last Week - Calculate date range starting from the Monday of the week before the current date (inclusive) to the Monday of the current week (exclusive).
Last Month - Determine date range from the first day of the previous month (inclusive) to the first day of the current month (exclusive).
Last Year - Define date range from the first day of the year before the current year (inclusive) to the first day of the current year (exclusive).
  • Loading branch information
OlegoO authored Apr 9, 2024
1 parent 4895c22 commit 0cb51ff
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected virtual IList<IFilter> GetPermanentFilters(CustomerOrderSearchCriteria

if (criteria.StartDate.HasValue && criteria.EndDate.HasValue)
{
result.Add(FilterHelper.CreateDateRangeFilter("createddate", criteria.StartDate, null, true, true));
result.Add(FilterHelper.CreateDateRangeFilter("createddate", criteria.StartDate, criteria.EndDate, true, true));
}
else if (criteria.StartDate.HasValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"labels": {
"new-filter": "Neuen Filter hinzufügen",
"unnamed-filter": "Unbenannter Filter",
"today-filter": "Heute",
"last-day-filter": "Gestern",
"last-week-filter": "Letzte Woche",
"last-month-filter": "Letzter Monat",
"last-year-filter": "Letztes Jahr",
"number": "Bestellnummer",
"customer": "Kunde",
"confirmed": "Bestätigt",
Expand All @@ -68,8 +73,8 @@
"name": "Name des Filters",
"name_": "Wie werden Sie diesen Filter?",
"criteria": "Filterkriterien",
"from": "Erstellt von",
"to": "Bis erstellt"
"from": "Erstellt am oder nach",
"to": "Erstellt vor"
},
"placeholders": {
"all": "Nicht angegeben"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"labels": {
"new-filter": "Add new filter",
"unnamed-filter": "Unnamed filter",
"last-day-filter": "Last 24 hours",
"today-filter": "Today",
"last-day-filter": "Yesterday",
"last-week-filter": "Last week",
"last-month-filter": "Last month",
"last-year-filter": "Last year",
Expand All @@ -74,8 +75,8 @@
"name": "Filter name",
"name_": "Please give this filter a name",
"criteria": "Filter criteria",
"from": "Created at",
"to": "Valid until"
"from": "Created after",
"to": "Created before"
},
"placeholders": {
"all": "Not specified"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"labels": {
"new-filter": "Добавить новый фильтр",
"unnamed-filter": "Фильтр по умолчанию",
"today-filter": "Сегодня",
"last-day-filter": "Вчера",
"last-week-filter": "Прошлая неделч",
"last-month-filter": "Прошлый месяц",
"last-year-filter": "Прошлый год",
"number": "Номер заказа",
"customer": "Покупатель",
"confirmed": "Подтвержден",
Expand All @@ -69,8 +74,8 @@
"name": "Название фильтра",
"name_": "Как Вы назовете этот фильтр?",
"criteria": "Критерии фильтра",
"from": "Действует с",
"to": "Действует до"
"from": "Создано с",
"to": "Создано до"
},
"placeholders": {
"all": "Не определено"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,36 +246,64 @@ function ($rootScope, $scope, $localStorage, customerOrders, bladeUtils, dialogS

function buildPredefinedFilters() {
var currentDate = new Date();
var day = 24 * 60 * 60 * 1000;
var days7 = 7 * day;
var days30 = 30 * day;
var days365 = 365 * day;
var currentDateUtcString = currentDate.toISOString();
currentDate.setHours(0, 0, 0, 0);

const lastDayStartDate = new Date(currentDate);
lastDayStartDate.setDate(currentDate.getDate() - 1);

const lastWeekStartDate = new Date(currentDate);
lastWeekStartDate.setDate(currentDate.getDate() - currentDate.getDay() - 6);

const lastWeekEndDate = new Date(currentDate);
lastWeekEndDate.setDate(currentDate.getDate() - currentDate.getDay() + 1);

const lastMonthStartDate = new Date(currentDate);
lastMonthStartDate.setMonth(currentDate.getMonth() - 1);
lastMonthStartDate.setDate(1);

const lastMonthEndDate = new Date(currentDate);
lastMonthEndDate.setDate(1);

const lastYearStartDate = new Date(currentDate);
lastYearStartDate.setFullYear(currentDate.getFullYear() - 1);
lastYearStartDate.setMonth(0);
lastYearStartDate.setDate(1);

const lastYearEndDate = new Date(currentDate);
lastYearEndDate.setFullYear(currentDate.getFullYear());
lastYearEndDate.setMonth(0);
lastYearEndDate.setDate(1);


return [
{
name: 'orders.blades.customerOrder-list.labels.today-filter',
id: 'today',
startDate: currentDate.toISOString()
},
{
name: 'orders.blades.customerOrder-list.labels.last-day-filter',
id: 'last-day',
startDate: new Date(currentDate.getTime() - day).toISOString(),
endDate: currentDateUtcString
startDate: lastDayStartDate.toISOString(),
endDate: currentDate.toISOString()
},
{
name: 'orders.blades.customerOrder-list.labels.last-week-filter',
id: 'last-week',
startDate: new Date(currentDate.getTime() - days7).toISOString(),
endDate: currentDateUtcString
startDate: lastWeekStartDate.toISOString(),
endDate: lastWeekEndDate.toISOString()
},
{
name: 'orders.blades.customerOrder-list.labels.last-month-filter',
id: 'last-month',
startDate: new Date(currentDate.getTime() - days30).toISOString(),
endDate: currentDateUtcString
startDate: lastMonthStartDate.toISOString(),
endDate: lastMonthEndDate.toISOString()
},
{
name: 'orders.blades.customerOrder-list.labels.last-year-filter',
id: 'last-year',
startDate: new Date(currentDate.getTime() - days365).toISOString(),
endDate: currentDateUtcString
startDate: lastYearStartDate.toISOString(),
endDate: lastYearEndDate.toISOString()
}
];
}
Expand Down

0 comments on commit 0cb51ff

Please sign in to comment.