asv-hlps 1.3.32 → 1.3.34

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.
@@ -0,0 +1,6 @@
1
+ import { IParam } from "../models/shared/IParam";
2
+ declare class HlpQBuilder {
3
+ userWhereParams(qb: any, prms: IParam): void;
4
+ }
5
+ declare const _default: HlpQBuilder;
6
+ export default _default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class HlpQBuilder {
4
+ // userWhereParams(qb: SelectQueryBuilder<any>, prms: IParam) {
5
+ userWhereParams(qb, prms) {
6
+ var _a, _b, _c, _d, _e, _f, _g, _h;
7
+ if (prms === null || prms === void 0 ? void 0 : prms.steId) {
8
+ qb.andWhere("ste.id = :id", { id: prms.steId });
9
+ }
10
+ if (prms === null || prms === void 0 ? void 0 : prms.clientId) {
11
+ // qb.andWhere("u.clientId = :clientId", { clientId: prms.clientId })
12
+ qb.andWhere("u.id = :clientId", { clientId: prms.clientId });
13
+ }
14
+ if (prms === null || prms === void 0 ? void 0 : prms.roleCode) {
15
+ qb.andWhere("LOWER(role.code) = :roleCode", { roleCode: prms.roleCode });
16
+ }
17
+ if ((_a = prms === null || prms === void 0 ? void 0 : prms.steGrpCodes) === null || _a === void 0 ? void 0 : _a.ins) {
18
+ qb.andWhere("LOWER(steGrp.code) IN (:...steGrpCodes)", { steGrpCodes: prms.steGrpCodes.ins }).andWhere("role.code = :role", {
19
+ role: "ceo",
20
+ });
21
+ }
22
+ if ((_b = prms === null || prms === void 0 ? void 0 : prms.steGrpCodes) === null || _b === void 0 ? void 0 : _b.notIns) {
23
+ qb.andWhere("LOWER(steGrp.code) NOT IN (:...steGrpCodes)", { steGrpCodes: prms.steGrpCodes.notIns });
24
+ }
25
+ if ((_c = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _c === void 0 ? void 0 : _c.ins) {
26
+ qb.andWhere("LOWER(grp.code) IN (:...grpCodes)", { grpCodes: prms.grpCodes.ins });
27
+ }
28
+ if ((_d = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _d === void 0 ? void 0 : _d.notIns) {
29
+ qb.andWhere("LOWER(grp.code) NOT IN (:...grpCodes)", { grpCodes: prms.grpCodes.notIns });
30
+ }
31
+ if ((_e = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _e === void 0 ? void 0 : _e.steId) {
32
+ qb.andWhere("LOWER(ste.id) = :grpCodesSteId", { grpCodesSteId: prms.grpCodes.steId });
33
+ }
34
+ if ((_f = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _f === void 0 ? void 0 : _f.steName) {
35
+ qb.orWhere("LOWER(ste.name) = :grpCodesSteName", { grpCodesSteName: prms.grpCodes.steName });
36
+ }
37
+ if ((_g = prms === null || prms === void 0 ? void 0 : prms.roleCodes) === null || _g === void 0 ? void 0 : _g.ins) {
38
+ qb.andWhere("LOWER(role.code) IN (:...roleCodes)", { roleCodes: prms.roleCodes.ins });
39
+ }
40
+ if ((_h = prms === null || prms === void 0 ? void 0 : prms.roleCodes) === null || _h === void 0 ? void 0 : _h.notIns) {
41
+ qb.andWhere("LOWER(role.code) NOT IN (:...roleCodes)", { roleCodes: prms.roleCodes.notIns });
42
+ }
43
+ }
44
+ }
45
+ exports.default = new HlpQBuilder();
@@ -0,0 +1 @@
1
+ export { default as HlpQBuilder } from "./hlpQbuilder";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HlpQBuilder = void 0;
7
+ var hlpQbuilder_1 = require("./hlpQbuilder");
8
+ Object.defineProperty(exports, "HlpQBuilder", { enumerable: true, get: function () { return __importDefault(hlpQbuilder_1).default; } });
@@ -21,6 +21,7 @@ import "./sale";
21
21
  import "./services/authService";
22
22
  import "./user";
23
23
  import "./utils";
24
+ export * from "./back-end";
24
25
  export * from "./bill";
25
26
  export * from "./bootstrap";
26
27
  export * from "./core/estates/index";
@@ -35,4 +36,4 @@ export * from "./react-utils";
35
36
  export * from "./sale";
36
37
  export * from "./user";
37
38
  export * from "./utils";
38
- export { AuthParam, getAuth, AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe, };
39
+ export { AmountOnBillPipe, AmountOnListBillPipe, AuthParam, AuthService, HlpEntry, HlpProduct, StockPipe, StorageService, getAuth, };
package/lib/cjs/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.AmountOnBillPipe = exports.AmountOnListBillPipe = exports.StockPipe = exports.HlpEntry = exports.HlpProduct = exports.StorageService = exports.AuthService = exports.getAuth = void 0;
20
+ exports.getAuth = exports.StorageService = exports.StockPipe = exports.HlpProduct = exports.HlpEntry = exports.AuthService = exports.AmountOnListBillPipe = exports.AmountOnBillPipe = void 0;
21
21
  const auth_1 = require("./auth");
22
22
  Object.defineProperty(exports, "getAuth", { enumerable: true, get: function () { return auth_1.getAuth; } });
23
23
  const hlpEntry_1 = require("./helpers/hlpEntry");
@@ -54,6 +54,7 @@ require("./services/authService");
54
54
  require("./user");
55
55
  require("./utils");
56
56
  // export * from "./auth";
57
+ __exportStar(require("./back-end"), exports);
57
58
  __exportStar(require("./bill"), exports);
58
59
  __exportStar(require("./bootstrap"), exports);
59
60
  __exportStar(require("./core/estates/index"), exports);
@@ -0,0 +1,7 @@
1
+ export declare enum EDate {
2
+ CURRENT_DATE = "currentDate",
3
+ CURRENT_MONTH = "currentMonth",
4
+ SUB_CURRENT_MONTH = "subCurrentMonth",
5
+ CURRENT_YEAR = "currentYear",
6
+ SUB_CURRENT_YEAR = "subCurrentYear"
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EDate = void 0;
4
+ var EDate;
5
+ (function (EDate) {
6
+ EDate["CURRENT_DATE"] = "currentDate";
7
+ EDate["CURRENT_MONTH"] = "currentMonth";
8
+ EDate["SUB_CURRENT_MONTH"] = "subCurrentMonth";
9
+ EDate["CURRENT_YEAR"] = "currentYear";
10
+ EDate["SUB_CURRENT_YEAR"] = "subCurrentYear";
11
+ })(EDate || (exports.EDate = EDate = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum EPayMethod {
2
+ CASH = "esp\u00E8ces",
3
+ TRANSFER = "virement",
4
+ BANKCHECK = "ch\u00E8que"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EPayMethod = void 0;
4
+ var EPayMethod;
5
+ (function (EPayMethod) {
6
+ EPayMethod["CASH"] = "esp\u00E8ces";
7
+ EPayMethod["TRANSFER"] = "virement";
8
+ EPayMethod["BANKCHECK"] = "ch\u00E8que";
9
+ })(EPayMethod || (exports.EPayMethod = EPayMethod = {}));
@@ -0,0 +1,26 @@
1
+ import { EDate } from "./EDate";
2
+ export interface IInOrNot {
3
+ ins?: string[];
4
+ notIns?: string[];
5
+ steId?: number;
6
+ steName?: string;
7
+ }
8
+ export interface IParam {
9
+ steId?: number;
10
+ userId?: number;
11
+ clientId?: number;
12
+ code?: string;
13
+ role?: string;
14
+ steName?: string;
15
+ steNames?: string[];
16
+ steGrpCodes?: IInOrNot;
17
+ grpCodes?: IInOrNot;
18
+ roleCodes?: IInOrNot;
19
+ roleCode?: string;
20
+ opDate?: EDate;
21
+ store?: string;
22
+ dates?: any;
23
+ storeName?: string;
24
+ grpByYear?: boolean;
25
+ grpByYearMonth?: boolean;
26
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +1,8 @@
1
+ import { ConfigType, OpUnitType, QUnitType } from "dayjs";
1
2
  import "dayjs/locale/fr";
2
3
  export declare const genDateMinutesStep: (step: number, lang?: string) => string[];
3
4
  export declare const percentOf: (nbr: number, percentage: number) => number;
4
5
  export declare const calPercent: (nbr: number, percentage: number) => number;
5
- export declare const displayDateRangeFr: (getFromDate?: any, getToDate?: any) => string;
6
- export declare const getNbOfDaysBetweenTwoDates: (date1: Date, date2: Date) => number;
7
6
  export declare const getRandomColor: (brightness: number) => string;
8
7
  /**
9
8
  * remove duplicates from array by crietere (key)
@@ -25,10 +24,6 @@ export declare const formatToString: (val: number, separator?: string, currency?
25
24
  export declare const currencyFormatter: (val: number, separator?: string, currency?: string) => string;
26
25
  export declare const formatToStringCfa: (val: number) => string;
27
26
  export declare const currencyFormatterCfa: (val: number) => string;
28
- export declare const reformatDates: (fromDate: any, toDate: any) => {
29
- fromDate: any;
30
- toDate: any;
31
- };
32
27
  export declare const notInSequence: (arr: number[]) => number[];
33
28
  export declare const sequencesToNumbers: (arr: any[]) => number[];
34
29
  export declare const findSequencesMissing: (arr: any[]) => number[];
@@ -44,7 +39,15 @@ export declare const sesStorageSet: (key: string, val: any) => void;
44
39
  export declare const sesStorageGet: (key: string) => any;
45
40
  export declare const replaceAllIn: (text: string, regex?: RegExp, toChar?: string) => string;
46
41
  export declare const replaceSpacesWith: (text: string, toChar?: string) => string;
42
+ export declare const dateFormatter: (date: Date | string, format?: "y" | "ym" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
43
+ export declare const dateDiff: (date1: ConfigType, unit?: QUnitType | OpUnitType, date2?: Date) => number;
47
44
  export declare const dateToString: (date: Date | any) => string;
45
+ export declare const reformatDates: (fromDate: any, toDate: any) => {
46
+ fromDate: any;
47
+ toDate: any;
48
+ };
49
+ export declare const displayDateRangeFr: (getFromDate?: any, getToDate?: any) => string;
50
+ export declare const getNbOfDaysBetweenTwoDates: (date1: Date, date2: Date) => number;
48
51
  export declare const formatNgbDate: (date: any) => {
49
52
  fromDate: string;
50
53
  toDate: string;
@@ -90,7 +93,6 @@ export declare const returnBool: (tob?: boolean) => boolean;
90
93
  export declare const monthStringName: (date: string | Date, format?: "MMM" | "MMMM", options?: {
91
94
  en?: true;
92
95
  }) => string;
93
- export declare const dateFormatter: (date: Date | string, format?: "y" | "ym" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
94
96
  export declare const countryIsoToFlag: (code: string) => string;
95
97
  export declare const removeParamKeyName: (params: any, name?: string) => any;
96
98
  export declare const roundLastNDigits: (num: number, digits?: number) => number | false;
package/lib/cjs/utils.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.dateToString = exports.replaceSpacesWith = exports.replaceAllIn = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeBackSlashOccurences = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.reformatDates = exports.currencyFormatterCfa = exports.formatToStringCfa = exports.currencyFormatter = exports.formatToString = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateObjects = exports.getRandomColor = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = void 0;
7
- exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.dateFormatter = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = void 0;
6
+ exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.dateToString = exports.dateDiff = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.removeBackSlashOccurences = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.formatToStringCfa = exports.currencyFormatter = exports.formatToString = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = void 0;
7
+ exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = void 0;
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
10
10
  const lodash_1 = __importDefault(require("lodash"));
@@ -86,18 +86,6 @@ const calPercent = (nbr, percentage) => {
86
86
  return nbr + (nbr * percentage) / 100;
87
87
  };
88
88
  exports.calPercent = calPercent;
89
- const displayDateRangeFr = (getFromDate, getToDate) => {
90
- const fromDate = !getFromDate ? new Date() : getFromDate;
91
- const toDate = !getToDate ? fromDate : getToDate;
92
- return (0, exports.dateFormatter)(new Date(fromDate), "dmy", "/") + " au " + (0, exports.dateFormatter)(new Date(toDate), "dmy", "/");
93
- };
94
- exports.displayDateRangeFr = displayDateRangeFr;
95
- const getNbOfDaysBetweenTwoDates = (date1, date2) => {
96
- const day = 1000 * 60 * 60 * 24;
97
- const diff = Math.abs(date2.getTime() - date1.getTime());
98
- return Math.ceil(diff / day);
99
- };
100
- exports.getNbOfDaysBetweenTwoDates = getNbOfDaysBetweenTwoDates;
101
89
  const getRandomColor = (brightness) => {
102
90
  // Six levels of brightness from 0 to 5, 0 being the darkest
103
91
  const rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
@@ -196,14 +184,6 @@ const currencyFormatterCfa = (val) => {
196
184
  };
197
185
  exports.currencyFormatterCfa = currencyFormatterCfa;
198
186
  // const = reformatDates(fromDate: string, toDate: string) => {
199
- const reformatDates = (fromDate, toDate) => {
200
- if (fromDate === undefined || fromDate === null) {
201
- return null;
202
- }
203
- toDate = !toDate ? fromDate : toDate;
204
- return { fromDate, toDate };
205
- };
206
- exports.reformatDates = reformatDates;
207
187
  const notInSequence = (arr) => {
208
188
  const [min, max] = [Math.min(...arr), Math.max(...arr)];
209
189
  // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
@@ -302,10 +282,66 @@ const replaceSpacesWith = (text, toChar = "_") => {
302
282
  return text.replace(/\s/g, toChar) || text;
303
283
  };
304
284
  exports.replaceSpacesWith = replaceSpacesWith;
285
+ /* start: dates -------------------------------------- */
286
+ const dateFormatter = (date, format = "dmy", separator = "/") => {
287
+ switch (format) {
288
+ case "y":
289
+ return (0, dayjs_1.default)(date).format("YYYY");
290
+ case "ym":
291
+ return (0, dayjs_1.default)(date).format(`YYYY${separator}MM`);
292
+ case "ymd":
293
+ return (0, dayjs_1.default)(date).format(`YYYY${separator}MM${separator}DD`);
294
+ case "md":
295
+ return (0, dayjs_1.default)(date).format(`MM${separator}DD`);
296
+ case "dmy":
297
+ return (0, dayjs_1.default)(date).format(`DD${separator}MM${separator}YYYY`);
298
+ case "dmy-hm":
299
+ return (0, dayjs_1.default)(date).format(`DD${separator}MM${separator}YYYY HH:mm`);
300
+ case "dmyfr":
301
+ return (0, dayjs_1.default)(date).locale("fr").format("dddd DD MMMM YYYY");
302
+ case "myfr":
303
+ return (0, dayjs_1.default)(date).locale("fr").format("MMMM YYYY");
304
+ case "mfr-short":
305
+ return (0, dayjs_1.default)(date).locale("fr").format("MMM");
306
+ case "mfr-long":
307
+ return (0, dayjs_1.default)(date).locale("fr").format("MMMM");
308
+ case "ago":
309
+ return (0, dayjs_1.default)(date).locale("fr").fromNow(true);
310
+ default:
311
+ return (0, dayjs_1.default)(date).format(`DD/MM/YYYY`);
312
+ // return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
313
+ }
314
+ };
315
+ exports.dateFormatter = dateFormatter;
316
+ const dateDiff = (date1, unit = "year", date2 = new Date()) => {
317
+ return (0, dayjs_1.default)(date2).diff(date1, unit);
318
+ };
319
+ exports.dateDiff = dateDiff;
305
320
  const dateToString = (date) => {
306
321
  return date.year + "-" + ("0" + date.month).slice(-2) + "-" + ("0" + date.day).slice(-2);
307
322
  };
308
323
  exports.dateToString = dateToString;
324
+ const reformatDates = (fromDate, toDate) => {
325
+ if (fromDate === undefined || fromDate === null) {
326
+ return null;
327
+ }
328
+ toDate = !toDate ? fromDate : toDate;
329
+ return { fromDate, toDate };
330
+ };
331
+ exports.reformatDates = reformatDates;
332
+ const displayDateRangeFr = (getFromDate, getToDate) => {
333
+ const fromDate = !getFromDate ? new Date() : getFromDate;
334
+ const toDate = !getToDate ? fromDate : getToDate;
335
+ return (0, exports.dateFormatter)(new Date(fromDate), "dmy", "/") + " au " + (0, exports.dateFormatter)(new Date(toDate), "dmy", "/");
336
+ };
337
+ exports.displayDateRangeFr = displayDateRangeFr;
338
+ const getNbOfDaysBetweenTwoDates = (date1, date2) => {
339
+ const day = 1000 * 60 * 60 * 24;
340
+ const diff = Math.abs(date2.getTime() - date1.getTime());
341
+ return Math.ceil(diff / day);
342
+ };
343
+ exports.getNbOfDaysBetweenTwoDates = getNbOfDaysBetweenTwoDates;
344
+ /* end: dates ---------------------------------------- */
309
345
  // export const formatNgbDate = (date: DateSelected) => {
310
346
  const formatNgbDate = (date) => {
311
347
  const fromDate = date.fromDate ? (0, exports.dateToString)(date.fromDate) : null;
@@ -624,36 +660,6 @@ const monthStringName = (date, format = "MMM", options) => {
624
660
  return (0, dayjs_1.default)(date).locale("fr").format(format);
625
661
  };
626
662
  exports.monthStringName = monthStringName;
627
- const dateFormatter = (date, format = "dmy", separator = "/") => {
628
- switch (format) {
629
- case "y":
630
- return (0, dayjs_1.default)(date).format("YYYY");
631
- case "ym":
632
- return (0, dayjs_1.default)(date).format(`YYYY${separator}MM`);
633
- case "ymd":
634
- return (0, dayjs_1.default)(date).format(`YYYY${separator}MM${separator}DD`);
635
- case "md":
636
- return (0, dayjs_1.default)(date).format(`MM${separator}DD`);
637
- case "dmy":
638
- return (0, dayjs_1.default)(date).format(`DD${separator}MM${separator}YYYY`);
639
- case "dmy-hm":
640
- return (0, dayjs_1.default)(date).format(`DD${separator}MM${separator}YYYY HH:mm`);
641
- case "dmyfr":
642
- return (0, dayjs_1.default)(date).locale("fr").format("dddd DD MMMM YYYY");
643
- case "myfr":
644
- return (0, dayjs_1.default)(date).locale("fr").format("MMMM YYYY");
645
- case "mfr-short":
646
- return (0, dayjs_1.default)(date).locale("fr").format("MMM");
647
- case "mfr-long":
648
- return (0, dayjs_1.default)(date).locale("fr").format("MMMM");
649
- case "ago":
650
- return (0, dayjs_1.default)(date).locale("fr").fromNow(true);
651
- default:
652
- return (0, dayjs_1.default)(date).format(`DD/MM/YYYY`);
653
- // return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
654
- }
655
- };
656
- exports.dateFormatter = dateFormatter;
657
663
  const countryIsoToFlag = (code) => {
658
664
  return code
659
665
  .split("")
@@ -0,0 +1,6 @@
1
+ import { IParam } from "../models/shared/IParam";
2
+ declare class HlpQBuilder {
3
+ userWhereParams(qb: any, prms: IParam): void;
4
+ }
5
+ declare const _default: HlpQBuilder;
6
+ export default _default;
@@ -0,0 +1,43 @@
1
+ class HlpQBuilder {
2
+ // userWhereParams(qb: SelectQueryBuilder<any>, prms: IParam) {
3
+ userWhereParams(qb, prms) {
4
+ var _a, _b, _c, _d, _e, _f, _g, _h;
5
+ if (prms === null || prms === void 0 ? void 0 : prms.steId) {
6
+ qb.andWhere("ste.id = :id", { id: prms.steId });
7
+ }
8
+ if (prms === null || prms === void 0 ? void 0 : prms.clientId) {
9
+ // qb.andWhere("u.clientId = :clientId", { clientId: prms.clientId })
10
+ qb.andWhere("u.id = :clientId", { clientId: prms.clientId });
11
+ }
12
+ if (prms === null || prms === void 0 ? void 0 : prms.roleCode) {
13
+ qb.andWhere("LOWER(role.code) = :roleCode", { roleCode: prms.roleCode });
14
+ }
15
+ if ((_a = prms === null || prms === void 0 ? void 0 : prms.steGrpCodes) === null || _a === void 0 ? void 0 : _a.ins) {
16
+ qb.andWhere("LOWER(steGrp.code) IN (:...steGrpCodes)", { steGrpCodes: prms.steGrpCodes.ins }).andWhere("role.code = :role", {
17
+ role: "ceo",
18
+ });
19
+ }
20
+ if ((_b = prms === null || prms === void 0 ? void 0 : prms.steGrpCodes) === null || _b === void 0 ? void 0 : _b.notIns) {
21
+ qb.andWhere("LOWER(steGrp.code) NOT IN (:...steGrpCodes)", { steGrpCodes: prms.steGrpCodes.notIns });
22
+ }
23
+ if ((_c = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _c === void 0 ? void 0 : _c.ins) {
24
+ qb.andWhere("LOWER(grp.code) IN (:...grpCodes)", { grpCodes: prms.grpCodes.ins });
25
+ }
26
+ if ((_d = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _d === void 0 ? void 0 : _d.notIns) {
27
+ qb.andWhere("LOWER(grp.code) NOT IN (:...grpCodes)", { grpCodes: prms.grpCodes.notIns });
28
+ }
29
+ if ((_e = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _e === void 0 ? void 0 : _e.steId) {
30
+ qb.andWhere("LOWER(ste.id) = :grpCodesSteId", { grpCodesSteId: prms.grpCodes.steId });
31
+ }
32
+ if ((_f = prms === null || prms === void 0 ? void 0 : prms.grpCodes) === null || _f === void 0 ? void 0 : _f.steName) {
33
+ qb.orWhere("LOWER(ste.name) = :grpCodesSteName", { grpCodesSteName: prms.grpCodes.steName });
34
+ }
35
+ if ((_g = prms === null || prms === void 0 ? void 0 : prms.roleCodes) === null || _g === void 0 ? void 0 : _g.ins) {
36
+ qb.andWhere("LOWER(role.code) IN (:...roleCodes)", { roleCodes: prms.roleCodes.ins });
37
+ }
38
+ if ((_h = prms === null || prms === void 0 ? void 0 : prms.roleCodes) === null || _h === void 0 ? void 0 : _h.notIns) {
39
+ qb.andWhere("LOWER(role.code) NOT IN (:...roleCodes)", { roleCodes: prms.roleCodes.notIns });
40
+ }
41
+ }
42
+ }
43
+ export default new HlpQBuilder();
@@ -0,0 +1 @@
1
+ export { default as HlpQBuilder } from "./hlpQbuilder";
@@ -0,0 +1 @@
1
+ export { default as HlpQBuilder } from "./hlpQbuilder";
@@ -21,6 +21,7 @@ import "./sale";
21
21
  import "./services/authService";
22
22
  import "./user";
23
23
  import "./utils";
24
+ export * from "./back-end";
24
25
  export * from "./bill";
25
26
  export * from "./bootstrap";
26
27
  export * from "./core/estates/index";
@@ -35,4 +36,4 @@ export * from "./react-utils";
35
36
  export * from "./sale";
36
37
  export * from "./user";
37
38
  export * from "./utils";
38
- export { AuthParam, getAuth, AuthService, StorageService, HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe, };
39
+ export { AmountOnBillPipe, AmountOnListBillPipe, AuthParam, AuthService, HlpEntry, HlpProduct, StockPipe, StorageService, getAuth, };
package/lib/esm/index.js CHANGED
@@ -26,6 +26,7 @@ import "./services/authService";
26
26
  import "./user";
27
27
  import "./utils";
28
28
  // export * from "./auth";
29
+ export * from "./back-end";
29
30
  export * from "./bill";
30
31
  export * from "./bootstrap";
31
32
  export * from "./core/estates/index";
@@ -41,6 +42,6 @@ export * from "./sale";
41
42
  export * from "./user";
42
43
  export * from "./utils";
43
44
  // export * from "./helpers/hlpProduct";
44
- export { getAuth, AuthService, StorageService,
45
+ export { AmountOnBillPipe, AmountOnListBillPipe, AuthService, HlpEntry,
45
46
  // CapacitorStorageService,
46
- HlpProduct, HlpEntry, StockPipe, AmountOnListBillPipe, AmountOnBillPipe, };
47
+ HlpProduct, StockPipe, StorageService, getAuth, };
@@ -0,0 +1,7 @@
1
+ export declare enum EDate {
2
+ CURRENT_DATE = "currentDate",
3
+ CURRENT_MONTH = "currentMonth",
4
+ SUB_CURRENT_MONTH = "subCurrentMonth",
5
+ CURRENT_YEAR = "currentYear",
6
+ SUB_CURRENT_YEAR = "subCurrentYear"
7
+ }
@@ -0,0 +1,8 @@
1
+ export var EDate;
2
+ (function (EDate) {
3
+ EDate["CURRENT_DATE"] = "currentDate";
4
+ EDate["CURRENT_MONTH"] = "currentMonth";
5
+ EDate["SUB_CURRENT_MONTH"] = "subCurrentMonth";
6
+ EDate["CURRENT_YEAR"] = "currentYear";
7
+ EDate["SUB_CURRENT_YEAR"] = "subCurrentYear";
8
+ })(EDate || (EDate = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum EPayMethod {
2
+ CASH = "esp\u00E8ces",
3
+ TRANSFER = "virement",
4
+ BANKCHECK = "ch\u00E8que"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var EPayMethod;
2
+ (function (EPayMethod) {
3
+ EPayMethod["CASH"] = "esp\u00E8ces";
4
+ EPayMethod["TRANSFER"] = "virement";
5
+ EPayMethod["BANKCHECK"] = "ch\u00E8que";
6
+ })(EPayMethod || (EPayMethod = {}));
@@ -0,0 +1,26 @@
1
+ import { EDate } from "./EDate";
2
+ export interface IInOrNot {
3
+ ins?: string[];
4
+ notIns?: string[];
5
+ steId?: number;
6
+ steName?: string;
7
+ }
8
+ export interface IParam {
9
+ steId?: number;
10
+ userId?: number;
11
+ clientId?: number;
12
+ code?: string;
13
+ role?: string;
14
+ steName?: string;
15
+ steNames?: string[];
16
+ steGrpCodes?: IInOrNot;
17
+ grpCodes?: IInOrNot;
18
+ roleCodes?: IInOrNot;
19
+ roleCode?: string;
20
+ opDate?: EDate;
21
+ store?: string;
22
+ dates?: any;
23
+ storeName?: string;
24
+ grpByYear?: boolean;
25
+ grpByYearMonth?: boolean;
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,8 @@
1
+ import { ConfigType, OpUnitType, QUnitType } from "dayjs";
1
2
  import "dayjs/locale/fr";
2
3
  export declare const genDateMinutesStep: (step: number, lang?: string) => string[];
3
4
  export declare const percentOf: (nbr: number, percentage: number) => number;
4
5
  export declare const calPercent: (nbr: number, percentage: number) => number;
5
- export declare const displayDateRangeFr: (getFromDate?: any, getToDate?: any) => string;
6
- export declare const getNbOfDaysBetweenTwoDates: (date1: Date, date2: Date) => number;
7
6
  export declare const getRandomColor: (brightness: number) => string;
8
7
  /**
9
8
  * remove duplicates from array by crietere (key)
@@ -25,10 +24,6 @@ export declare const formatToString: (val: number, separator?: string, currency?
25
24
  export declare const currencyFormatter: (val: number, separator?: string, currency?: string) => string;
26
25
  export declare const formatToStringCfa: (val: number) => string;
27
26
  export declare const currencyFormatterCfa: (val: number) => string;
28
- export declare const reformatDates: (fromDate: any, toDate: any) => {
29
- fromDate: any;
30
- toDate: any;
31
- };
32
27
  export declare const notInSequence: (arr: number[]) => number[];
33
28
  export declare const sequencesToNumbers: (arr: any[]) => number[];
34
29
  export declare const findSequencesMissing: (arr: any[]) => number[];
@@ -44,7 +39,15 @@ export declare const sesStorageSet: (key: string, val: any) => void;
44
39
  export declare const sesStorageGet: (key: string) => any;
45
40
  export declare const replaceAllIn: (text: string, regex?: RegExp, toChar?: string) => string;
46
41
  export declare const replaceSpacesWith: (text: string, toChar?: string) => string;
42
+ export declare const dateFormatter: (date: Date | string, format?: "y" | "ym" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
43
+ export declare const dateDiff: (date1: ConfigType, unit?: QUnitType | OpUnitType, date2?: Date) => number;
47
44
  export declare const dateToString: (date: Date | any) => string;
45
+ export declare const reformatDates: (fromDate: any, toDate: any) => {
46
+ fromDate: any;
47
+ toDate: any;
48
+ };
49
+ export declare const displayDateRangeFr: (getFromDate?: any, getToDate?: any) => string;
50
+ export declare const getNbOfDaysBetweenTwoDates: (date1: Date, date2: Date) => number;
48
51
  export declare const formatNgbDate: (date: any) => {
49
52
  fromDate: string;
50
53
  toDate: string;
@@ -90,7 +93,6 @@ export declare const returnBool: (tob?: boolean) => boolean;
90
93
  export declare const monthStringName: (date: string | Date, format?: "MMM" | "MMMM", options?: {
91
94
  en?: true;
92
95
  }) => string;
93
- export declare const dateFormatter: (date: Date | string, format?: "y" | "ym" | "ymd" | "dmy" | "ago" | "md" | "dmy-hm" | "dmyfr" | "myfr" | "mfr-short" | "mfr-long", separator?: "/" | "" | "-") => string;
94
96
  export declare const countryIsoToFlag: (code: string) => string;
95
97
  export declare const removeParamKeyName: (params: any, name?: string) => any;
96
98
  export declare const roundLastNDigits: (num: number, digits?: number) => number | false;
package/lib/esm/utils.js CHANGED
@@ -76,16 +76,6 @@ export const calPercent = (nbr, percentage) => {
76
76
  }
77
77
  return nbr + (nbr * percentage) / 100;
78
78
  };
79
- export const displayDateRangeFr = (getFromDate, getToDate) => {
80
- const fromDate = !getFromDate ? new Date() : getFromDate;
81
- const toDate = !getToDate ? fromDate : getToDate;
82
- return dateFormatter(new Date(fromDate), "dmy", "/") + " au " + dateFormatter(new Date(toDate), "dmy", "/");
83
- };
84
- export const getNbOfDaysBetweenTwoDates = (date1, date2) => {
85
- const day = 1000 * 60 * 60 * 24;
86
- const diff = Math.abs(date2.getTime() - date1.getTime());
87
- return Math.ceil(diff / day);
88
- };
89
79
  export const getRandomColor = (brightness) => {
90
80
  // Six levels of brightness from 0 to 5, 0 being the darkest
91
81
  const rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
@@ -172,13 +162,6 @@ export const currencyFormatterCfa = (val) => {
172
162
  return currencyFormatter(val, " ", " FCFA");
173
163
  };
174
164
  // const = reformatDates(fromDate: string, toDate: string) => {
175
- export const reformatDates = (fromDate, toDate) => {
176
- if (fromDate === undefined || fromDate === null) {
177
- return null;
178
- }
179
- toDate = !toDate ? fromDate : toDate;
180
- return { fromDate, toDate };
181
- };
182
165
  export const notInSequence = (arr) => {
183
166
  const [min, max] = [Math.min(...arr), Math.max(...arr)];
184
167
  // let out = Array.from(Array(max - min), (v, i) => i + min).filter((i) => !arr.includes(i));
@@ -262,9 +245,60 @@ export const replaceAllIn = (text, regex = / /g, toChar = "_") => {
262
245
  export const replaceSpacesWith = (text, toChar = "_") => {
263
246
  return text.replace(/\s/g, toChar) || text;
264
247
  };
248
+ /* start: dates -------------------------------------- */
249
+ export const dateFormatter = (date, format = "dmy", separator = "/") => {
250
+ switch (format) {
251
+ case "y":
252
+ return dayjs(date).format("YYYY");
253
+ case "ym":
254
+ return dayjs(date).format(`YYYY${separator}MM`);
255
+ case "ymd":
256
+ return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
257
+ case "md":
258
+ return dayjs(date).format(`MM${separator}DD`);
259
+ case "dmy":
260
+ return dayjs(date).format(`DD${separator}MM${separator}YYYY`);
261
+ case "dmy-hm":
262
+ return dayjs(date).format(`DD${separator}MM${separator}YYYY HH:mm`);
263
+ case "dmyfr":
264
+ return dayjs(date).locale("fr").format("dddd DD MMMM YYYY");
265
+ case "myfr":
266
+ return dayjs(date).locale("fr").format("MMMM YYYY");
267
+ case "mfr-short":
268
+ return dayjs(date).locale("fr").format("MMM");
269
+ case "mfr-long":
270
+ return dayjs(date).locale("fr").format("MMMM");
271
+ case "ago":
272
+ return dayjs(date).locale("fr").fromNow(true);
273
+ default:
274
+ return dayjs(date).format(`DD/MM/YYYY`);
275
+ // return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
276
+ }
277
+ };
278
+ export const dateDiff = (date1, unit = "year", date2 = new Date()) => {
279
+ return dayjs(date2).diff(date1, unit);
280
+ };
265
281
  export const dateToString = (date) => {
266
282
  return date.year + "-" + ("0" + date.month).slice(-2) + "-" + ("0" + date.day).slice(-2);
267
283
  };
284
+ export const reformatDates = (fromDate, toDate) => {
285
+ if (fromDate === undefined || fromDate === null) {
286
+ return null;
287
+ }
288
+ toDate = !toDate ? fromDate : toDate;
289
+ return { fromDate, toDate };
290
+ };
291
+ export const displayDateRangeFr = (getFromDate, getToDate) => {
292
+ const fromDate = !getFromDate ? new Date() : getFromDate;
293
+ const toDate = !getToDate ? fromDate : getToDate;
294
+ return dateFormatter(new Date(fromDate), "dmy", "/") + " au " + dateFormatter(new Date(toDate), "dmy", "/");
295
+ };
296
+ export const getNbOfDaysBetweenTwoDates = (date1, date2) => {
297
+ const day = 1000 * 60 * 60 * 24;
298
+ const diff = Math.abs(date2.getTime() - date1.getTime());
299
+ return Math.ceil(diff / day);
300
+ };
301
+ /* end: dates ---------------------------------------- */
268
302
  // export const formatNgbDate = (date: DateSelected) => {
269
303
  export const formatNgbDate = (date) => {
270
304
  const fromDate = date.fromDate ? dateToString(date.fromDate) : null;
@@ -552,35 +586,6 @@ export const monthStringName = (date, format = "MMM", options) => {
552
586
  }
553
587
  return dayjs(date).locale("fr").format(format);
554
588
  };
555
- export const dateFormatter = (date, format = "dmy", separator = "/") => {
556
- switch (format) {
557
- case "y":
558
- return dayjs(date).format("YYYY");
559
- case "ym":
560
- return dayjs(date).format(`YYYY${separator}MM`);
561
- case "ymd":
562
- return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
563
- case "md":
564
- return dayjs(date).format(`MM${separator}DD`);
565
- case "dmy":
566
- return dayjs(date).format(`DD${separator}MM${separator}YYYY`);
567
- case "dmy-hm":
568
- return dayjs(date).format(`DD${separator}MM${separator}YYYY HH:mm`);
569
- case "dmyfr":
570
- return dayjs(date).locale("fr").format("dddd DD MMMM YYYY");
571
- case "myfr":
572
- return dayjs(date).locale("fr").format("MMMM YYYY");
573
- case "mfr-short":
574
- return dayjs(date).locale("fr").format("MMM");
575
- case "mfr-long":
576
- return dayjs(date).locale("fr").format("MMMM");
577
- case "ago":
578
- return dayjs(date).locale("fr").fromNow(true);
579
- default:
580
- return dayjs(date).format(`DD/MM/YYYY`);
581
- // return dayjs(date).format(`YYYY${separator}MM${separator}DD`);
582
- }
583
- };
584
589
  export const countryIsoToFlag = (code) => {
585
590
  return code
586
591
  .split("")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.3.32",
3
+ "version": "1.3.34",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -32,6 +32,7 @@
32
32
  "lodash": "^4.17.21",
33
33
  "pdfmake": "^0.2.7",
34
34
  "randomatic": "^3.1.1",
35
+ "typeorm": "^0.3.17",
35
36
  "yup": "^1.3.2"
36
37
  }
37
38
  }