asv-hlps 1.4.20 → 1.4.22

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.
@@ -7,12 +7,12 @@ const utils_1 = require("../utils");
7
7
  const infoAmountOnBl = (tob) => {
8
8
  const totalAmountWithoutTva = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
9
9
  ? 0
10
- : (0, utils_1.formatToStringCfa)((0, sale_1.getTotalAmountWithoutTvaOnSale)(tob, true));
11
- // const totalPort = formatToStringCfa(HlpSale.getTotalShipping(tob));
12
- const totalTva = (0, utils_1.formatToStringCfa)((0, sale_1.getTotalTvaOnSale)(tob, true));
10
+ : (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalAmountWithoutTvaOnSale)(tob, true));
11
+ // const totalPort = currencyFormatterCfa(HlpSale.getTotalShipping(tob));
12
+ const totalTva = (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalTvaOnSale)(tob, true));
13
13
  const totalAmountAllIncluded = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
14
14
  ? 0
15
- : (0, utils_1.formatToStringCfa)((0, sale_1.getTotalAmountAllIncludedOnSale)(tob, true));
15
+ : (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalAmountAllIncludedOnSale)(tob, true));
16
16
  const tabFooter = {
17
17
  width: "50%",
18
18
  table: {
@@ -42,10 +42,10 @@ const infoAmountOnBl = (tob) => {
42
42
  };
43
43
  exports.infoAmountOnBl = infoAmountOnBl;
44
44
  const infoAmountOnProforma = (tob) => {
45
- const totalAmountWithoutTva = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : (0, utils_1.formatToStringCfa)((0, sale_1.getTotalAmountWithoutTvaOnSale)(tob));
46
- // const totalPort = formatToStringCfa(HlpSale.getTotalShipping(tob));
47
- const totalTva = (0, utils_1.formatToStringCfa)((0, sale_1.getTotalTvaOnSale)(tob));
48
- const totalAmountAllIncluded = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : (0, utils_1.formatToStringCfa)((0, sale_1.getTotalAmountAllIncludedOnSale)(tob));
45
+ const totalAmountWithoutTva = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalAmountWithoutTvaOnSale)(tob));
46
+ // const totalPort = currencyFormatterCfa(HlpSale.getTotalShipping(tob));
47
+ const totalTva = (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalTvaOnSale)(tob));
48
+ const totalAmountAllIncluded = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalAmountAllIncludedOnSale)(tob));
49
49
  const tabFooter = {
50
50
  width: "50%",
51
51
  table: {
@@ -77,12 +77,12 @@ exports.infoAmountOnProforma = infoAmountOnProforma;
77
77
  const infoAmounOntSale = (tob) => {
78
78
  const totalAmountWithoutTva = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
79
79
  ? 0
80
- : (0, utils_1.formatToStringCfa)((0, sale_1.getTotalAmountWithoutTvaOnSale)(tob, true));
81
- const totalPort = (0, utils_1.formatToStringCfa)((0, sale_1.getTotalShippingOnSale)(tob));
82
- const totalTva = (0, utils_1.formatToStringCfa)((0, sale_1.getTotalTvaOnSale)(tob, true));
80
+ : (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalAmountWithoutTvaOnSale)(tob, true));
81
+ const totalPort = (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalShippingOnSale)(tob));
82
+ const totalTva = (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalTvaOnSale)(tob, true));
83
83
  const totalAmountAllIncluded = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
84
84
  ? 0
85
- : (0, utils_1.formatToStringCfa)((0, sale_1.getTotalAmountAllIncludedOnSale)(tob, true));
85
+ : (0, utils_1.currencyFormatterCfa)((0, sale_1.getTotalAmountAllIncludedOnSale)(tob, true));
86
86
  const tabFooter = {
87
87
  width: "50%",
88
88
  table: {
@@ -115,13 +115,13 @@ const infoAmountOnBill = (tob) => {
115
115
  const totalAmountAllAndBackInclused = (0, bill_1.getTotalAmountAllIncludedOnBill)(tob.sales);
116
116
  const totalAmountWithoutTvaAllAndBack = (0, bill_1.getTotalAmountWithoutTvaOnBill)(tob.sales);
117
117
  const totalAmountTvaAllAndBack = (0, bill_1.getTotalAmountTvaOnBill)(tob.sales);
118
- // const totalAmountWithoutTva = formatToStringCfa(HlpSale.getTotalAmountWithoutTvaOnBill(tob.sales));
119
- const totalAmountWithoutTva = (0, utils_1.formatToStringCfa)(totalAmountWithoutTvaAllAndBack);
120
- // const totalPort = formatToStringCfa(HlpSale.getTotalShipping(tob));
121
- const totalTva = (0, utils_1.formatToStringCfa)(totalAmountTvaAllAndBack);
122
- // const totalTva = formatToStringCfa(HlpSale.getTotalAmountTvaOnBill(tob.sales));
123
- // const totalAmountAllIncluded = formatToStringCfa(HlpSale.getTotalAmountOnBill(tob.sales));
124
- const totalAmountAllIncluded = (0, utils_1.formatToStringCfa)(totalAmountAllAndBackInclused);
118
+ // const totalAmountWithoutTva = currencyFormatterCfa(HlpSale.getTotalAmountWithoutTvaOnBill(tob.sales));
119
+ const totalAmountWithoutTva = (0, utils_1.currencyFormatterCfa)(totalAmountWithoutTvaAllAndBack);
120
+ // const totalPort = currencyFormatterCfa(HlpSale.getTotalShipping(tob));
121
+ const totalTva = (0, utils_1.currencyFormatterCfa)(totalAmountTvaAllAndBack);
122
+ // const totalTva = currencyFormatterCfa(HlpSale.getTotalAmountTvaOnBill(tob.sales));
123
+ // const totalAmountAllIncluded = currencyFormatterCfa(HlpSale.getTotalAmountOnBill(tob.sales));
124
+ const totalAmountAllIncluded = (0, utils_1.currencyFormatterCfa)(totalAmountAllAndBackInclused);
125
125
  const tabFooter = {
126
126
  width: "50%",
127
127
  table: {
@@ -0,0 +1,13 @@
1
+ import { SelectQueryBuilder } from "typeorm";
2
+ import OpDate from "../shared/models/OpDate";
3
+ export interface QueryPrms<T> {
4
+ id?: number;
5
+ sqb?: SelectQueryBuilder<T>;
6
+ opDate?: OpDate;
7
+ search?: string;
8
+ joker?: {
9
+ qId: string;
10
+ qProp: string | number | boolean;
11
+ };
12
+ only?: boolean;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./QueryPrms";
2
+ export * from "./QueryPrms";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./QueryPrms"), exports);
18
+ __exportStar(require("./QueryPrms"), exports);
@@ -0,0 +1,23 @@
1
+ import { SelectQueryBuilder } from "typeorm";
2
+ import OpDate from "../shared/models/OpDate";
3
+ import { QueryPrms } from "./QueryPrms";
4
+ declare class SqbPrms {
5
+ query: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, prms: QueryPrms<T>, opts?: {
6
+ qDate?: any;
7
+ qMbrId?: string;
8
+ qProductId?: string;
9
+ qSaleId?: string;
10
+ }) => void;
11
+ opDate: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, opDate: OpDate, qDate?: string) => void;
12
+ storeName: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, storeName: string) => void;
13
+ cat: <T = any>(qb: SelectQueryBuilder<T>, prms: {
14
+ cat: {
15
+ id?: number;
16
+ name?: string;
17
+ code?: string;
18
+ };
19
+ }) => void;
20
+ active: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, active: "true" | "false") => void;
21
+ }
22
+ declare const _default: SqbPrms;
23
+ export default _default;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const typeorm_1 = require("typeorm");
4
+ const typeorm_2 = require("../npms/typeorm");
5
+ class SqbPrms {
6
+ constructor() {
7
+ this.query = (qb, qStr, prms, opts) => {
8
+ var _a, _b, _c;
9
+ if (prms === null || prms === void 0 ? void 0 : prms.opDate) {
10
+ (0, typeorm_2.tormDateParams)(qb, `${(opts === null || opts === void 0 ? void 0 : opts.qDate) || qStr + ".createdAt"}`, (_a = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _a === void 0 ? void 0 : _a.eDate, (_b = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _b === void 0 ? void 0 : _b.dates, (_c = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _c === void 0 ? void 0 : _c.datesBy);
11
+ }
12
+ if (prms === null || prms === void 0 ? void 0 : prms.joker) {
13
+ qb.andWhere(`${prms.joker.qId} = :joker`, { joker: prms.joker["qProp"] });
14
+ }
15
+ if (prms === null || prms === void 0 ? void 0 : prms.search) {
16
+ asyncSearch(qb, prms.search);
17
+ }
18
+ };
19
+ this.opDate = (qb, qStr, opDate, qDate) => {
20
+ if (opDate) {
21
+ (0, typeorm_2.tormDateParams)(qb, `${qDate || qStr + ".createdAt"}`, opDate === null || opDate === void 0 ? void 0 : opDate.eDate, opDate === null || opDate === void 0 ? void 0 : opDate.dates, opDate === null || opDate === void 0 ? void 0 : opDate.datesBy);
22
+ }
23
+ };
24
+ this.storeName = (qb, qStr, storeName) => {
25
+ qb.andWhere(`${qStr}.store = :store`, { store: storeName });
26
+ };
27
+ this.cat = (qb, prms) => {
28
+ var _a, _b, _c;
29
+ if (prms === null || prms === void 0 ? void 0 : prms.cat) {
30
+ if ((_a = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _a === void 0 ? void 0 : _a.code) {
31
+ qb.andWhere("cat.code = :code", { code: prms.cat.code });
32
+ }
33
+ if ((_b = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _b === void 0 ? void 0 : _b.id) {
34
+ qb.andWhere("cat.id = :id", { id: prms.cat.id });
35
+ }
36
+ if ((_c = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _c === void 0 ? void 0 : _c.name) {
37
+ qb.andWhere("cat.name = :name", { id: prms.cat.name });
38
+ }
39
+ }
40
+ };
41
+ this.active = (qb, qStr, active) => {
42
+ if (active) {
43
+ if (active === "true") {
44
+ qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: true });
45
+ }
46
+ if (active === "false") {
47
+ qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: false });
48
+ }
49
+ }
50
+ };
51
+ }
52
+ }
53
+ const asyncSearch = (qb, search) => {
54
+ qb.andWhere(new typeorm_1.Brackets((qb) => {
55
+ qb.where("s.ref LIKE :ref", { ref: "%" + search + "%" });
56
+ qb.orWhere("e.ref LIKE :entryRef", { entryRef: "%" + search + "%" });
57
+ }));
58
+ };
59
+ exports.default = new SqbPrms();
@@ -110,7 +110,7 @@ const tabLabel = (sale) => {
110
110
  for (let j = 0; j < +sp.qtityDlvr + +sp.qtityFree; j++) {
111
111
  const name = (0, user_1.labelSteName)(sale.client.ste);
112
112
  const product = sp.product.designation;
113
- const pp = (0, utils_1.formatToStringCfa)(Math.ceil(sp.publicPrice));
113
+ const pp = (0, utils_1.currencyFormatterCfa)(Math.ceil(sp.publicPrice));
114
114
  const saleDate = (0, utils_1.dateFormatter)(sale.saleDate, "dmy", "/");
115
115
  // const saleDate = formatDateYmd(sale.saleDate, '/');
116
116
  // const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
@@ -13,6 +13,7 @@ export declare const getRandomColor: (brightness: number) => string;
13
13
  * @returns
14
14
  */
15
15
  export declare const removeDuplicateObjects: (array: any[], property?: string) => any[];
16
+ export declare const removeDuplicateValues: (array: any[]) => any[];
16
17
  export declare const duplicateObjects: (array: any[], property: string) => any[];
17
18
  export declare const toObjectDate: (fromDate: any, toDate: string) => {
18
19
  fromDate: any;
@@ -23,9 +24,7 @@ export declare const limitTo: (value: string, limit?: number, trail?: string) =>
23
24
  export declare const sleep: (ms: number) => Promise<unknown>;
24
25
  export declare const wakeUp: (sleep: any) => void;
25
26
  export declare const checkAuth: (auth?: boolean) => boolean;
26
- export declare const formatToString: (val: number, separator?: string, currency?: string) => string;
27
27
  export declare const currencyFormatter: (val: number, separator?: string, currency?: string) => string;
28
- export declare const formatToStringCfa: (val: number) => string;
29
28
  export declare const currencyFormatterCfa: (val: number) => string;
30
29
  export declare const notInSequence: (arr: number[]) => number[];
31
30
  export declare const sequencesToNumbers: (arr: any[]) => number[];
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.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateNthWeek = exports.getNthWeek = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.refGenerator = exports.removeBackSlashOccurences = exports.stringifyFormatter = 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.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
7
- exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = exports.inputChecked = void 0;
6
+ exports.inputChecked = exports.arrayMultiChecked = exports.getPeriodDateColor = exports.getColorAccordingToDate = exports.genRandomColour = exports.formatNgbDate = exports.getNbOfDaysBetweenTwoDates = exports.displayDateRangeFr = exports.reformatDates = exports.firstDayOfDate = exports.dateToString = exports.dateDiff = exports.dateNthWeek = exports.getNthWeek = exports.dateFormatter = exports.replaceSpacesWith = exports.replaceAllIn = exports.toPlural = exports.sesStorageGet = exports.sesStorageSet = exports.genSequenceRef = exports.refGenerator = exports.removeBackSlashOccurences = exports.stringifyFormatter = exports.removeString = exports.diffArraysByProp = exports.diffArraysByFunc = exports.deepClone = exports.findFirstSequenceMissing = exports.fillNumWithZero = exports.findSequencesMissing = exports.sequencesToNumbers = exports.notInSequence = exports.currencyFormatterCfa = exports.currencyFormatter = exports.checkAuth = exports.wakeUp = exports.sleep = exports.limitTo = exports.titleCase = exports.toObjectDate = exports.duplicateObjects = exports.removeDuplicateValues = exports.removeDuplicateObjects = exports.getRandomColor = exports.calPercent = exports.percentOf = exports.genDateMinutesStep = exports.formatDateFirstDayFr = exports.isEmpty = void 0;
7
+ exports.checkObjInArray = exports.arraySome = exports.winMaxHeight = exports.toggleProp = exports.roundLastNDigits = exports.removeParamKeyName = exports.countryIsoToFlag = exports.monthStringName = exports.returnBool = exports.formatAmountToString = exports.reduceTimes = exports.reduceSum = exports.sumAmount = exports.fillEndWithZero = exports.fillStartWithZero = exports.absFromSequence = exports.returnDates = exports.displayFrDatePeriode = exports.getArrayOfRandomColor = exports.randomHslColor = exports.randomHexColor = exports.genRandomNumberArray = exports.randomRgbColor = exports.randomInteger = exports.insertAtInArray = exports.isBirthday = exports.padEndWithZero = exports.padStartWithZero = exports.formatMonthYearToLocaleString = exports.calculPercent = exports.validEmail = exports.convertToCfa = exports.packAndUnit = exports.unCheckedAll = void 0;
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
10
10
  const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
@@ -135,6 +135,10 @@ const removeDuplicateObjects = (array, property = "id") => {
135
135
  return unique; */
136
136
  };
137
137
  exports.removeDuplicateObjects = removeDuplicateObjects;
138
+ const removeDuplicateValues = (array) => {
139
+ return [...new Set(array)];
140
+ };
141
+ exports.removeDuplicateValues = removeDuplicateValues;
138
142
  const duplicateObjects = (array, property) => {
139
143
  return array.filter((obj, index) => array.findIndex((item) => lodash_1.default.get(item, property) === lodash_1.default.get(obj, property)) !== index);
140
144
  };
@@ -174,23 +178,11 @@ const checkAuth = (auth = true) => {
174
178
  return auth;
175
179
  };
176
180
  exports.checkAuth = checkAuth;
177
- // -- to remove later
178
- const formatToString = (val, separator = " ", currency = "") => {
179
- // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1,');
180
- return String(val).replace(/(.)(?=(\d{3})+$)/g, "$1" + separator + "") + currency;
181
- };
182
- exports.formatToString = formatToString;
183
181
  const currencyFormatter = (val, separator = " ", currency = "") => {
184
182
  // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1,');
185
183
  return String(val).replace(/(.)(?=(\d{3})+$)/g, "$1" + separator + "") + currency;
186
184
  };
187
185
  exports.currencyFormatter = currencyFormatter;
188
- // -- to remove later
189
- const formatToStringCfa = (val) => {
190
- // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1 ') + ' CFA';
191
- return (0, exports.formatToString)(val, " ", " FCFA");
192
- };
193
- exports.formatToStringCfa = formatToStringCfa;
194
186
  const currencyFormatterCfa = (val) => {
195
187
  // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1 ') + ' CFA';
196
188
  return (0, exports.currencyFormatter)(val, " ", " FCFA");
@@ -736,9 +728,9 @@ const formatAmountToString = (amount, opt) => {
736
728
  }
737
729
  switch (opt === null || opt === void 0 ? void 0 : opt.currency) {
738
730
  case "cfa":
739
- return (0, exports.formatToStringCfa)(getAmount);
731
+ return (0, exports.currencyFormatterCfa)(getAmount);
740
732
  default:
741
- return (0, exports.formatToString)(getAmount);
733
+ return (0, exports.currencyFormatter)(getAmount);
742
734
  }
743
735
  };
744
736
  exports.formatAmountToString = formatAmountToString;
@@ -1,15 +1,15 @@
1
1
  import { getTotalAmountAllIncludedOnBill, getTotalAmountTvaOnBill, getTotalAmountWithoutTvaOnBill } from "../bills/bill";
2
2
  import { getTotalAmountAllIncludedOnSale, getTotalAmountWithoutTvaOnSale, getTotalShippingOnSale, getTotalTvaOnSale } from "../sales/sale";
3
- import { formatToStringCfa } from "../utils";
3
+ import { currencyFormatterCfa } from "../utils";
4
4
  export const infoAmountOnBl = (tob) => {
5
5
  const totalAmountWithoutTva = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
6
6
  ? 0
7
- : formatToStringCfa(getTotalAmountWithoutTvaOnSale(tob, true));
8
- // const totalPort = formatToStringCfa(HlpSale.getTotalShipping(tob));
9
- const totalTva = formatToStringCfa(getTotalTvaOnSale(tob, true));
7
+ : currencyFormatterCfa(getTotalAmountWithoutTvaOnSale(tob, true));
8
+ // const totalPort = currencyFormatterCfa(HlpSale.getTotalShipping(tob));
9
+ const totalTva = currencyFormatterCfa(getTotalTvaOnSale(tob, true));
10
10
  const totalAmountAllIncluded = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
11
11
  ? 0
12
- : formatToStringCfa(getTotalAmountAllIncludedOnSale(tob, true));
12
+ : currencyFormatterCfa(getTotalAmountAllIncludedOnSale(tob, true));
13
13
  const tabFooter = {
14
14
  width: "50%",
15
15
  table: {
@@ -38,10 +38,10 @@ export const infoAmountOnBl = (tob) => {
38
38
  return tabFooter;
39
39
  };
40
40
  export const infoAmountOnProforma = (tob) => {
41
- const totalAmountWithoutTva = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : formatToStringCfa(getTotalAmountWithoutTvaOnSale(tob));
42
- // const totalPort = formatToStringCfa(HlpSale.getTotalShipping(tob));
43
- const totalTva = formatToStringCfa(getTotalTvaOnSale(tob));
44
- const totalAmountAllIncluded = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : formatToStringCfa(getTotalAmountAllIncludedOnSale(tob));
41
+ const totalAmountWithoutTva = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : currencyFormatterCfa(getTotalAmountWithoutTvaOnSale(tob));
42
+ // const totalPort = currencyFormatterCfa(HlpSale.getTotalShipping(tob));
43
+ const totalTva = currencyFormatterCfa(getTotalTvaOnSale(tob));
44
+ const totalAmountAllIncluded = tob.isBack && tob.backChoice.toLowerCase() === "autre" ? 0 : currencyFormatterCfa(getTotalAmountAllIncludedOnSale(tob));
45
45
  const tabFooter = {
46
46
  width: "50%",
47
47
  table: {
@@ -72,12 +72,12 @@ export const infoAmountOnProforma = (tob) => {
72
72
  export const infoAmounOntSale = (tob) => {
73
73
  const totalAmountWithoutTva = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
74
74
  ? 0
75
- : formatToStringCfa(getTotalAmountWithoutTvaOnSale(tob, true));
76
- const totalPort = formatToStringCfa(getTotalShippingOnSale(tob));
77
- const totalTva = formatToStringCfa(getTotalTvaOnSale(tob, true));
75
+ : currencyFormatterCfa(getTotalAmountWithoutTvaOnSale(tob, true));
76
+ const totalPort = currencyFormatterCfa(getTotalShippingOnSale(tob));
77
+ const totalTva = currencyFormatterCfa(getTotalTvaOnSale(tob, true));
78
78
  const totalAmountAllIncluded = tob.isBack && (tob.backChoice.toLowerCase() === "autre" || tob.rejectedReason)
79
79
  ? 0
80
- : formatToStringCfa(getTotalAmountAllIncludedOnSale(tob, true));
80
+ : currencyFormatterCfa(getTotalAmountAllIncludedOnSale(tob, true));
81
81
  const tabFooter = {
82
82
  width: "50%",
83
83
  table: {
@@ -109,13 +109,13 @@ export const infoAmountOnBill = (tob) => {
109
109
  const totalAmountAllAndBackInclused = getTotalAmountAllIncludedOnBill(tob.sales);
110
110
  const totalAmountWithoutTvaAllAndBack = getTotalAmountWithoutTvaOnBill(tob.sales);
111
111
  const totalAmountTvaAllAndBack = getTotalAmountTvaOnBill(tob.sales);
112
- // const totalAmountWithoutTva = formatToStringCfa(HlpSale.getTotalAmountWithoutTvaOnBill(tob.sales));
113
- const totalAmountWithoutTva = formatToStringCfa(totalAmountWithoutTvaAllAndBack);
114
- // const totalPort = formatToStringCfa(HlpSale.getTotalShipping(tob));
115
- const totalTva = formatToStringCfa(totalAmountTvaAllAndBack);
116
- // const totalTva = formatToStringCfa(HlpSale.getTotalAmountTvaOnBill(tob.sales));
117
- // const totalAmountAllIncluded = formatToStringCfa(HlpSale.getTotalAmountOnBill(tob.sales));
118
- const totalAmountAllIncluded = formatToStringCfa(totalAmountAllAndBackInclused);
112
+ // const totalAmountWithoutTva = currencyFormatterCfa(HlpSale.getTotalAmountWithoutTvaOnBill(tob.sales));
113
+ const totalAmountWithoutTva = currencyFormatterCfa(totalAmountWithoutTvaAllAndBack);
114
+ // const totalPort = currencyFormatterCfa(HlpSale.getTotalShipping(tob));
115
+ const totalTva = currencyFormatterCfa(totalAmountTvaAllAndBack);
116
+ // const totalTva = currencyFormatterCfa(HlpSale.getTotalAmountTvaOnBill(tob.sales));
117
+ // const totalAmountAllIncluded = currencyFormatterCfa(HlpSale.getTotalAmountOnBill(tob.sales));
118
+ const totalAmountAllIncluded = currencyFormatterCfa(totalAmountAllAndBackInclused);
119
119
  const tabFooter = {
120
120
  width: "50%",
121
121
  table: {
@@ -0,0 +1,13 @@
1
+ import { SelectQueryBuilder } from "typeorm";
2
+ import OpDate from "../shared/models/OpDate";
3
+ export interface QueryPrms<T> {
4
+ id?: number;
5
+ sqb?: SelectQueryBuilder<T>;
6
+ opDate?: OpDate;
7
+ search?: string;
8
+ joker?: {
9
+ qId: string;
10
+ qProp: string | number | boolean;
11
+ };
12
+ only?: boolean;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./QueryPrms";
2
+ export * from "./QueryPrms";
@@ -0,0 +1,2 @@
1
+ export * from "./QueryPrms";
2
+ export * from "./QueryPrms";
@@ -0,0 +1,23 @@
1
+ import { SelectQueryBuilder } from "typeorm";
2
+ import OpDate from "../shared/models/OpDate";
3
+ import { QueryPrms } from "./QueryPrms";
4
+ declare class SqbPrms {
5
+ query: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, prms: QueryPrms<T>, opts?: {
6
+ qDate?: any;
7
+ qMbrId?: string;
8
+ qProductId?: string;
9
+ qSaleId?: string;
10
+ }) => void;
11
+ opDate: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, opDate: OpDate, qDate?: string) => void;
12
+ storeName: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, storeName: string) => void;
13
+ cat: <T = any>(qb: SelectQueryBuilder<T>, prms: {
14
+ cat: {
15
+ id?: number;
16
+ name?: string;
17
+ code?: string;
18
+ };
19
+ }) => void;
20
+ active: <T = any>(qb: SelectQueryBuilder<T>, qStr: string, active: "true" | "false") => void;
21
+ }
22
+ declare const _default: SqbPrms;
23
+ export default _default;
@@ -0,0 +1,57 @@
1
+ import { Brackets } from "typeorm";
2
+ import { tormDateParams } from "../npms/typeorm";
3
+ class SqbPrms {
4
+ constructor() {
5
+ this.query = (qb, qStr, prms, opts) => {
6
+ var _a, _b, _c;
7
+ if (prms === null || prms === void 0 ? void 0 : prms.opDate) {
8
+ tormDateParams(qb, `${(opts === null || opts === void 0 ? void 0 : opts.qDate) || qStr + ".createdAt"}`, (_a = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _a === void 0 ? void 0 : _a.eDate, (_b = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _b === void 0 ? void 0 : _b.dates, (_c = prms === null || prms === void 0 ? void 0 : prms.opDate) === null || _c === void 0 ? void 0 : _c.datesBy);
9
+ }
10
+ if (prms === null || prms === void 0 ? void 0 : prms.joker) {
11
+ qb.andWhere(`${prms.joker.qId} = :joker`, { joker: prms.joker["qProp"] });
12
+ }
13
+ if (prms === null || prms === void 0 ? void 0 : prms.search) {
14
+ asyncSearch(qb, prms.search);
15
+ }
16
+ };
17
+ this.opDate = (qb, qStr, opDate, qDate) => {
18
+ if (opDate) {
19
+ tormDateParams(qb, `${qDate || qStr + ".createdAt"}`, opDate === null || opDate === void 0 ? void 0 : opDate.eDate, opDate === null || opDate === void 0 ? void 0 : opDate.dates, opDate === null || opDate === void 0 ? void 0 : opDate.datesBy);
20
+ }
21
+ };
22
+ this.storeName = (qb, qStr, storeName) => {
23
+ qb.andWhere(`${qStr}.store = :store`, { store: storeName });
24
+ };
25
+ this.cat = (qb, prms) => {
26
+ var _a, _b, _c;
27
+ if (prms === null || prms === void 0 ? void 0 : prms.cat) {
28
+ if ((_a = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _a === void 0 ? void 0 : _a.code) {
29
+ qb.andWhere("cat.code = :code", { code: prms.cat.code });
30
+ }
31
+ if ((_b = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _b === void 0 ? void 0 : _b.id) {
32
+ qb.andWhere("cat.id = :id", { id: prms.cat.id });
33
+ }
34
+ if ((_c = prms === null || prms === void 0 ? void 0 : prms.cat) === null || _c === void 0 ? void 0 : _c.name) {
35
+ qb.andWhere("cat.name = :name", { id: prms.cat.name });
36
+ }
37
+ }
38
+ };
39
+ this.active = (qb, qStr, active) => {
40
+ if (active) {
41
+ if (active === "true") {
42
+ qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: true });
43
+ }
44
+ if (active === "false") {
45
+ qb.andWhere(`${qStr}.isActive = :isActive`, { isActive: false });
46
+ }
47
+ }
48
+ };
49
+ }
50
+ }
51
+ const asyncSearch = (qb, search) => {
52
+ qb.andWhere(new Brackets((qb) => {
53
+ qb.where("s.ref LIKE :ref", { ref: "%" + search + "%" });
54
+ qb.orWhere("e.ref LIKE :entryRef", { entryRef: "%" + search + "%" });
55
+ }));
56
+ };
57
+ export default new SqbPrms();
@@ -1,6 +1,6 @@
1
1
  import { unitPriceByClientCat } from "../products/product";
2
2
  import { labelSteName } from "../users/user";
3
- import { dateFormatter, formatToStringCfa, removeBackSlashOccurences } from "../utils";
3
+ import { currencyFormatterCfa, dateFormatter, removeBackSlashOccurences } from "../utils";
4
4
  export const getNbProductsOnSale = (sale) => {
5
5
  return sale.saleProducts.length || 0;
6
6
  };
@@ -91,7 +91,7 @@ export const tabLabel = (sale) => {
91
91
  for (let j = 0; j < +sp.qtityDlvr + +sp.qtityFree; j++) {
92
92
  const name = labelSteName(sale.client.ste);
93
93
  const product = sp.product.designation;
94
- const pp = formatToStringCfa(Math.ceil(sp.publicPrice));
94
+ const pp = currencyFormatterCfa(Math.ceil(sp.publicPrice));
95
95
  const saleDate = dateFormatter(sale.saleDate, "dmy", "/");
96
96
  // const saleDate = formatDateYmd(sale.saleDate, '/');
97
97
  // const saleDate = moment(sale.saleDate ).format('DD/MM/YYYY');
@@ -13,6 +13,7 @@ export declare const getRandomColor: (brightness: number) => string;
13
13
  * @returns
14
14
  */
15
15
  export declare const removeDuplicateObjects: (array: any[], property?: string) => any[];
16
+ export declare const removeDuplicateValues: (array: any[]) => any[];
16
17
  export declare const duplicateObjects: (array: any[], property: string) => any[];
17
18
  export declare const toObjectDate: (fromDate: any, toDate: string) => {
18
19
  fromDate: any;
@@ -23,9 +24,7 @@ export declare const limitTo: (value: string, limit?: number, trail?: string) =>
23
24
  export declare const sleep: (ms: number) => Promise<unknown>;
24
25
  export declare const wakeUp: (sleep: any) => void;
25
26
  export declare const checkAuth: (auth?: boolean) => boolean;
26
- export declare const formatToString: (val: number, separator?: string, currency?: string) => string;
27
27
  export declare const currencyFormatter: (val: number, separator?: string, currency?: string) => string;
28
- export declare const formatToStringCfa: (val: number) => string;
29
28
  export declare const currencyFormatterCfa: (val: number) => string;
30
29
  export declare const notInSequence: (arr: number[]) => number[];
31
30
  export declare const sequencesToNumbers: (arr: any[]) => number[];
package/lib/esm/utils.js CHANGED
@@ -121,6 +121,9 @@ export const removeDuplicateObjects = (array, property = "id") => {
121
121
 
122
122
  return unique; */
123
123
  };
124
+ export const removeDuplicateValues = (array) => {
125
+ return [...new Set(array)];
126
+ };
124
127
  export const duplicateObjects = (array, property) => {
125
128
  return array.filter((obj, index) => array.findIndex((item) => lodash.get(item, property) === lodash.get(obj, property)) !== index);
126
129
  };
@@ -153,20 +156,10 @@ export const wakeUp = (sleep) => {
153
156
  export const checkAuth = (auth = true) => {
154
157
  return auth;
155
158
  };
156
- // -- to remove later
157
- export const formatToString = (val, separator = " ", currency = "") => {
158
- // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1,');
159
- return String(val).replace(/(.)(?=(\d{3})+$)/g, "$1" + separator + "") + currency;
160
- };
161
159
  export const currencyFormatter = (val, separator = " ", currency = "") => {
162
160
  // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1,');
163
161
  return String(val).replace(/(.)(?=(\d{3})+$)/g, "$1" + separator + "") + currency;
164
162
  };
165
- // -- to remove later
166
- export const formatToStringCfa = (val) => {
167
- // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1 ') + ' CFA';
168
- return formatToString(val, " ", " FCFA");
169
- };
170
163
  export const currencyFormatterCfa = (val) => {
171
164
  // return String(val).replace(/(.)(?=(\d{3})+$)/g, '$1 ') + ' CFA';
172
165
  return currencyFormatter(val, " ", " FCFA");
@@ -654,9 +647,9 @@ export const formatAmountToString = (amount, opt) => {
654
647
  }
655
648
  switch (opt === null || opt === void 0 ? void 0 : opt.currency) {
656
649
  case "cfa":
657
- return formatToStringCfa(getAmount);
650
+ return currencyFormatterCfa(getAmount);
658
651
  default:
659
- return formatToString(getAmount);
652
+ return currencyFormatter(getAmount);
660
653
  }
661
654
  };
662
655
  export const returnBool = (tob = true) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",