rez_core 5.0.192 → 5.0.193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -899,22 +899,22 @@ export class FilterService {
|
|
|
899
899
|
// convert to number when needed
|
|
900
900
|
const numVal = Number(val);
|
|
901
901
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
902
|
+
const subtractBusinessDays = (days: number): string => {
|
|
903
|
+
let d = new Date();
|
|
904
|
+
let count = 0;
|
|
905
905
|
|
|
906
|
-
|
|
907
|
-
|
|
906
|
+
while (count < days) {
|
|
907
|
+
d.setDate(d.getDate() - 1);
|
|
908
908
|
|
|
909
|
-
|
|
909
|
+
const day = d.getDay(); // 0 = Sunday, 6 = Saturday
|
|
910
910
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
911
|
+
if (day !== 0 && day !== 6) {
|
|
912
|
+
count++;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
915
|
|
|
916
|
-
|
|
917
|
-
|
|
916
|
+
return d.toISOString().split('T')[0];
|
|
917
|
+
};
|
|
918
918
|
|
|
919
919
|
switch (op) {
|
|
920
920
|
// BASIC COMPARISONS
|
|
@@ -965,7 +965,6 @@ export class FilterService {
|
|
|
965
965
|
params: {},
|
|
966
966
|
};
|
|
967
967
|
|
|
968
|
-
// DAY OFFSET LOGIC (ALWAYS ADJUST -1 DAY)
|
|
969
968
|
// DAY OFFSET LOGIC – NEW RULE:
|
|
970
969
|
// +N → future date (today + N)
|
|
971
970
|
// -N → past date (today - |N|)
|
|
@@ -992,7 +991,7 @@ export class FilterService {
|
|
|
992
991
|
})();
|
|
993
992
|
|
|
994
993
|
return {
|
|
995
|
-
query: `${dateColumn}
|
|
994
|
+
query: `${dateColumn} <= :${key}`,
|
|
996
995
|
params: { [key]: dayBefore },
|
|
997
996
|
};
|
|
998
997
|
}
|
|
@@ -1106,111 +1105,43 @@ export class FilterService {
|
|
|
1106
1105
|
throw new BadRequestException('Value must be a number');
|
|
1107
1106
|
}
|
|
1108
1107
|
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
const calcDate = (() => {
|
|
1112
|
-
let d = new Date();
|
|
1113
|
-
let count = 0;
|
|
1114
|
-
|
|
1115
|
-
if (numVal >= 0) {
|
|
1116
|
-
// POSITIVE → move forward
|
|
1117
|
-
while (count < abs) {
|
|
1118
|
-
d.setDate(d.getDate() + 1);
|
|
1119
|
-
if (![0, 6].includes(d.getDay())) count++;
|
|
1120
|
-
}
|
|
1121
|
-
} else {
|
|
1122
|
-
// NEGATIVE → move backward
|
|
1123
|
-
while (count < abs) {
|
|
1124
|
-
d.setDate(d.getDate() - 1);
|
|
1125
|
-
if (![0, 6].includes(d.getDay())) count++;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
return d.toISOString().split('T')[0];
|
|
1130
|
-
})();
|
|
1108
|
+
const targetDate = subtractBusinessDays(numVal);
|
|
1131
1109
|
|
|
1132
1110
|
return {
|
|
1133
1111
|
query: `${dateColumn} <= :${key} AND EXTRACT(DOW FROM ${dateColumn}) NOT IN (0, 6)`,
|
|
1134
|
-
params: { [key]:
|
|
1112
|
+
params: { [key]: targetDate },
|
|
1135
1113
|
};
|
|
1136
1114
|
}
|
|
1137
1115
|
|
|
1138
1116
|
case 'is_after_business_days': {
|
|
1139
1117
|
if (isNaN(numVal)) {
|
|
1140
|
-
throw new BadRequestException(
|
|
1118
|
+
throw new BadRequestException(
|
|
1119
|
+
'Value must be a number for is_after_business_days',
|
|
1120
|
+
);
|
|
1141
1121
|
}
|
|
1142
1122
|
|
|
1143
|
-
const
|
|
1144
|
-
|
|
1145
|
-
const calcDate = (() => {
|
|
1123
|
+
const businessAfter = (() => {
|
|
1146
1124
|
let d = new Date();
|
|
1147
1125
|
let count = 0;
|
|
1148
1126
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
if (![0, 6].includes(d.getDay())) count++;
|
|
1154
|
-
}
|
|
1155
|
-
} else {
|
|
1156
|
-
// NEGATIVE → move backward
|
|
1157
|
-
while (count < abs) {
|
|
1158
|
-
d.setDate(d.getDate() - 1);
|
|
1159
|
-
if (![0, 6].includes(d.getDay())) count++;
|
|
1160
|
-
}
|
|
1127
|
+
while (count < numVal) {
|
|
1128
|
+
d.setDate(d.getDate() + 1);
|
|
1129
|
+
const day = d.getDay(); // 0=Sun, 6=Sat
|
|
1130
|
+
if (day !== 0 && day !== 6) count++;
|
|
1161
1131
|
}
|
|
1162
1132
|
|
|
1133
|
+
// DB shift -1 day
|
|
1134
|
+
d.setDate(d.getDate() - 1);
|
|
1135
|
+
|
|
1163
1136
|
return d.toISOString().split('T')[0];
|
|
1164
1137
|
})();
|
|
1165
1138
|
|
|
1166
1139
|
return {
|
|
1167
1140
|
query: `${dateColumn} > :${key}`,
|
|
1168
|
-
params: { [key]:
|
|
1141
|
+
params: { [key]: businessAfter },
|
|
1169
1142
|
};
|
|
1170
1143
|
}
|
|
1171
1144
|
|
|
1172
|
-
// case 'is_before_business_days': {
|
|
1173
|
-
// if (isNaN(numVal)) {
|
|
1174
|
-
// throw new BadRequestException('Value must be a number');
|
|
1175
|
-
// }
|
|
1176
|
-
|
|
1177
|
-
// const targetDate = subtractBusinessDays(numVal);
|
|
1178
|
-
|
|
1179
|
-
// return {
|
|
1180
|
-
// query: `${dateColumn} <= :${key} AND EXTRACT(DOW FROM ${dateColumn}) NOT IN (0, 6)`,
|
|
1181
|
-
// params: { [key]: targetDate },
|
|
1182
|
-
// };
|
|
1183
|
-
// }
|
|
1184
|
-
|
|
1185
|
-
// case 'is_after_business_days': {
|
|
1186
|
-
// if (isNaN(numVal)) {
|
|
1187
|
-
// throw new BadRequestException(
|
|
1188
|
-
// 'Value must be a number for is_after_business_days',
|
|
1189
|
-
// );
|
|
1190
|
-
// }
|
|
1191
|
-
|
|
1192
|
-
// const businessAfter = (() => {
|
|
1193
|
-
// let d = new Date();
|
|
1194
|
-
// let count = 0;
|
|
1195
|
-
|
|
1196
|
-
// while (count < numVal) {
|
|
1197
|
-
// d.setDate(d.getDate() + 1);
|
|
1198
|
-
// const day = d.getDay(); // 0=Sun, 6=Sat
|
|
1199
|
-
// if (day !== 0 && day !== 6) count++;
|
|
1200
|
-
// }
|
|
1201
|
-
|
|
1202
|
-
// // DB shift -1 day
|
|
1203
|
-
// d.setDate(d.getDate() - 1);
|
|
1204
|
-
|
|
1205
|
-
// return d.toISOString().split('T')[0];
|
|
1206
|
-
// })();
|
|
1207
|
-
|
|
1208
|
-
// return {
|
|
1209
|
-
// query: `${dateColumn} > :${key}`,
|
|
1210
|
-
// params: { [key]: businessAfter },
|
|
1211
|
-
// };
|
|
1212
|
-
// }
|
|
1213
|
-
|
|
1214
1145
|
// IN LAST DAY (range: today to N days before)
|
|
1215
1146
|
case 'in_last_day': {
|
|
1216
1147
|
if (isNaN(numVal)) {
|