law-common 10.13.1-beta.2 → 10.13.1-beta.4

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.
@@ -24,6 +24,7 @@ export interface IBillingEntity extends IAuditColumnEntity {
24
24
  invoicePdfUrl?: string | null;
25
25
  invoiceContactName: string;
26
26
  bankId: number;
27
+ conversionRate?: number;
27
28
  }
28
29
  export interface IBillingEntityFilterDto extends IEntityFilterData<IBillingEntity> {
29
30
  }
@@ -173,3 +173,19 @@ export declare function transformDate<T extends {
173
173
  }>(obj: T): Modify<T, {
174
174
  date: string;
175
175
  }>;
176
+ /**
177
+ * Checks if two decimal numbers are approximately equal within a given tolerance.
178
+ *
179
+ * @param {number} firstValue - The first number to compare.
180
+ * @param {number} secondValue - The second number to compare.
181
+ * @param {number} allowedDifference - The maximum difference allowed for the numbers
182
+ * to be considered equal.
183
+ *
184
+ * @returns {boolean} Returns `true` if the numbers are within the allowed difference;
185
+ * otherwise, returns `false`.
186
+ *
187
+ * @example
188
+ * areDecimalNumbersEqual(5483.86, 5483.87, 0.5); // true
189
+ * areDecimalNumbersEqual(5483.86, 5484.5, 0.5); // false
190
+ */
191
+ export declare function areDecimalNumbersEqual(firstValue: number, secondValue: number, allowedDifference?: number): boolean;
@@ -31,6 +31,7 @@ exports.numberToWordsIndian = numberToWordsIndian;
31
31
  exports.minutesToHoursMinutes = minutesToHoursMinutes;
32
32
  exports.createKeyLabelMap = createKeyLabelMap;
33
33
  exports.transformDate = transformDate;
34
+ exports.areDecimalNumbersEqual = areDecimalNumbersEqual;
34
35
  const util_constants_1 = require("../constants/util.constants");
35
36
  function groupByFunction(list, keyGetter) {
36
37
  const map = new Map();
@@ -374,3 +375,24 @@ function createKeyLabelMap() {
374
375
  function transformDate(obj) {
375
376
  return Object.assign(Object.assign({}, obj), { date: obj.date.toISOString() });
376
377
  }
378
+ /**
379
+ * Checks if two decimal numbers are approximately equal within a given tolerance.
380
+ *
381
+ * @param {number} firstValue - The first number to compare.
382
+ * @param {number} secondValue - The second number to compare.
383
+ * @param {number} allowedDifference - The maximum difference allowed for the numbers
384
+ * to be considered equal.
385
+ *
386
+ * @returns {boolean} Returns `true` if the numbers are within the allowed difference;
387
+ * otherwise, returns `false`.
388
+ *
389
+ * @example
390
+ * areDecimalNumbersEqual(5483.86, 5483.87, 0.5); // true
391
+ * areDecimalNumbersEqual(5483.86, 5484.5, 0.5); // false
392
+ */
393
+ function areDecimalNumbersEqual(firstValue, secondValue, allowedDifference = 0.5) {
394
+ // Calculate the absolute difference between both values
395
+ const actualDifference = Math.abs(firstValue - secondValue);
396
+ // Return true if the actual difference is less than or equal to the allowed difference
397
+ return actualDifference <= allowedDifference;
398
+ }
@@ -34,4 +34,5 @@ export declare class DateCodeModel {
34
34
  isSame(dateCodeModel: DateCodeModel): boolean;
35
35
  getWeekday(): Weekday;
36
36
  getDateInIST(): Date;
37
+ static getDaysInCurrentMonth(): number;
37
38
  }
@@ -98,8 +98,8 @@ class DateCodeModel {
98
98
  }
99
99
  const dateRange = startModel.getRange(endModel);
100
100
  const excludeDayPredicates = (dateModel) => !dateModel.isDayPresent(excludeDays);
101
- const excludeDatePredicates = (dateModel) => !excludeDateCodes.some(d => d.isSame(dateModel));
102
- return dateRange.filter((dateModel => excludeDayPredicates(dateModel) && excludeDatePredicates(dateModel))).length;
101
+ const excludeDatePredicates = (dateModel) => !excludeDateCodes.some((d) => d.isSame(dateModel));
102
+ return dateRange.filter((dateModel) => excludeDayPredicates(dateModel) && excludeDatePredicates(dateModel)).length;
103
103
  }
104
104
  static getByPredicates(models, includePredicates, excludePredicates) {
105
105
  return models.filter((model) => includePredicates.every((predicate) => predicate(model)) &&
@@ -209,5 +209,10 @@ class DateCodeModel {
209
209
  billDateIST.setHours(nowIST.getHours(), nowIST.getMinutes(), nowIST.getSeconds(), nowIST.getMilliseconds());
210
210
  return billDateIST;
211
211
  }
212
+ static getDaysInCurrentMonth() {
213
+ const today = new Date();
214
+ const lastDay = (0, date_fns_1.lastDayOfMonth)(today); // Gives last day of current month
215
+ return lastDay.getDate(); // Number of days in that month
216
+ }
212
217
  }
213
218
  exports.DateCodeModel = DateCodeModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.13.1-beta.2",
3
+ "version": "10.13.1-beta.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [