law-common 10.72.4-beta.0 → 10.72.6

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.
@@ -1,4 +1,4 @@
1
- import { BillingActionsEnum, BillingStatusEnum, IBillingEntity, IBillingReimbursementExpenseEntity, IBillingTimesheetEntity, IProjectEntity, IUserEntity } from "../../entities";
1
+ import { BillingActionsEnum, BillingEntityModel, BillingStatusEnum, EntityModelRelationHelper, IBillingEntity, IBillingProfileEntity, IBillingReimbursementExpenseEntity, IBillingTimesheetEntity, IDesignationEntity, IProjectEntity, IUserEntity } from "../../entities";
2
2
  import { IUpdateBillingDto } from "./billing.update.dto.interface";
3
3
  export type IBillingEntityResponse = {
4
4
  billing: IBillingEntity;
@@ -31,3 +31,10 @@ export type IBillingFlowContextData = {
31
31
  currentBilling?: IBillingEntity;
32
32
  dto?: IUpdateBillingDto;
33
33
  };
34
+ export interface IBillingExportContext {
35
+ currentUser: IUserEntity;
36
+ billingEntity: BillingEntityModel;
37
+ billingEntityModelRelationHelper: EntityModelRelationHelper;
38
+ billingProfileEntity: IBillingProfileEntity[];
39
+ designationEntites: IDesignationEntity[];
40
+ }
@@ -2,3 +2,4 @@ export declare const billingPrefixCompanyName = "ALC";
2
2
  export declare const billingSequenceSeperator = "-";
3
3
  export declare const billingSequenceSeperatorForCurrentFy = "/";
4
4
  export declare const currentFY = "2526";
5
+ export declare const PROHIBITED_CHARS = "\\ / : * ? \" < > | . , ; = # % & { } $ ! ' @ ` ~ ^ [ ] ( ) +";
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.currentFY = exports.billingSequenceSeperatorForCurrentFy = exports.billingSequenceSeperator = exports.billingPrefixCompanyName = void 0;
3
+ exports.PROHIBITED_CHARS = exports.currentFY = exports.billingSequenceSeperatorForCurrentFy = exports.billingSequenceSeperator = exports.billingPrefixCompanyName = void 0;
4
4
  exports.billingPrefixCompanyName = "ALC";
5
5
  exports.billingSequenceSeperator = "-";
6
6
  exports.billingSequenceSeperatorForCurrentFy = "/";
7
7
  exports.currentFY = "2526";
8
+ exports.PROHIBITED_CHARS = `\\ / : * ? " < > | . , ; = # % & { } $ ! ' @ \` ~ ^ [ ] ( ) +`;
@@ -70,7 +70,6 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
70
70
  static validateDocumentNoDocumentFile(data: DocumentFields<typeof BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES>, deleteDetails?: DeleteDocumentDetails<typeof BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES>): Result<void, IDtoValidationError[]>;
71
71
  get intermediaryBanks(): import("./intermediary-bank.entity.model").IntermediaryBankEntityModel[] | undefined;
72
72
  get reimbursements(): ReimbursementEntityModel[];
73
- get summarryFolderName(): string;
74
73
  static relationConfigs: RelationConfigs<[
75
74
  EntityEnum.PROJECT,
76
75
  EntityEnum.CLIENT,
@@ -133,7 +132,19 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
133
132
  latestBilling?: IBillingEntity;
134
133
  }): string;
135
134
  getBillingTimesheetUserIds(): number[];
136
- get invoiceFileName(): "Proforma Invoice.pdf" | "Draft Invoice.pdf" | "Invoice.pdf";
137
- get timesheetSummarryFileName(): string;
138
- get OPESummarryFileName(): string;
135
+ getTimestamp(): string;
136
+ summarryFolderName(timestamp: string): string;
137
+ invoiceFileName(timestamp: string): string;
138
+ timesheetSummarryFileName(timestamp: string): string;
139
+ OPESummarryFileName(timestamp: string): string;
140
+ getFileNames(timestamp: string): {
141
+ invoiceFileName: string;
142
+ timesheetSummaryFileName: string;
143
+ opeSummaryFileName: string;
144
+ };
145
+ get billingPhase(): string;
146
+ get clientName(): string;
147
+ get projectName(): string;
148
+ getActiveBillingTransactions(): BillingTransactionEntityModel[] | undefined;
149
+ hasActiveTranansactions(): boolean | undefined;
139
150
  }
@@ -61,28 +61,6 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
61
61
  var _a, _b;
62
62
  return (_b = (_a = this.reimbursementExpenses) === null || _a === void 0 ? void 0 : _a.map((expense) => expense.reimbursement).filter(utils_1.isDefined)) !== null && _b !== void 0 ? _b : [];
63
63
  }
64
- get summarryFolderName() {
65
- // Folder Name
66
- // <Invoice | Proforma Invoice | Draft Invoice> - <InvoiceNo | ProjectName> - YYMMDD HHMM
67
- // File
68
- // Proforma Invoice | Invoice | Draft Invoice.pdf
69
- // Timesheet.pdf
70
- // OPE.pdf
71
- var _a, _b, _c;
72
- const timestamp = utils_1.DateCodeModel.getCurrentTimestampCode();
73
- let prefix;
74
- if (this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE) {
75
- prefix = "Proforma Invoice";
76
- }
77
- else if (!this.invoiceNumber) {
78
- prefix = "Draft Invoice";
79
- }
80
- else {
81
- prefix = "Invoice";
82
- }
83
- const identifier = (_c = (_a = this.invoiceNumber) !== null && _a !== void 0 ? _a : (_b = this.project) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : "";
84
- return `${prefix} - ${identifier} - ${timestamp}`;
85
- }
86
64
  static fromEntity(entity) {
87
65
  const result = new BillingEntityModel(entity_utils_interface_1.EntityEnum.BILLING);
88
66
  Object.assign(result, entity);
@@ -388,26 +366,54 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
388
366
  var _a, _b;
389
367
  return (_b = (_a = this.billingTimesheets) === null || _a === void 0 ? void 0 : _a.map((timesheet) => timesheet.userId)) !== null && _b !== void 0 ? _b : [];
390
368
  }
391
- get invoiceFileName() {
392
- // File
393
- // Proforma Invoice | Invoice | Draft Invoice.pdf
394
- // Timesheet.pdf
395
- // OPE.pdf
369
+ getTimestamp() {
370
+ const now = new Date();
371
+ const ist = new Date(now.getTime() + 5.5 * 60 * 60 * 1000);
372
+ return (`${String(ist.getDate()).padStart(2, "0")}${String(ist.getMonth() + 1).padStart(2, "0")}${ist.getFullYear()}` +
373
+ `_${String(ist.getHours()).padStart(2, "0")}${String(ist.getMinutes()).padStart(2, "0")}${String(ist.getSeconds()).padStart(2, "0")}`);
374
+ }
375
+ summarryFolderName(timestamp) {
376
+ return `${this.billingPhase}_${this.clientName}_${this.projectName} _ ${timestamp}`;
377
+ }
378
+ invoiceFileName(timestamp) {
379
+ return `${this.billingPhase}_Invoice_${this.clientName}_${this.projectName}_${timestamp}.pdf`;
380
+ }
381
+ timesheetSummarryFileName(timestamp) {
382
+ return `${this.billingPhase}_Timesheet_Summary_${this.clientName}_${this.projectName}_${timestamp}.pdf`;
383
+ }
384
+ OPESummarryFileName(timestamp) {
385
+ return `${this.billingPhase}_OPE_${this.clientName}_${this.projectName}_${timestamp}.pdf`;
386
+ }
387
+ getFileNames(timestamp) {
388
+ return {
389
+ invoiceFileName: this.invoiceFileName(timestamp),
390
+ timesheetSummaryFileName: this.timesheetSummarryFileName(timestamp),
391
+ opeSummaryFileName: this.OPESummarryFileName(timestamp),
392
+ };
393
+ }
394
+ get billingPhase() {
396
395
  if (this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE) {
397
- return "Proforma Invoice.pdf";
398
- }
399
- else if (!this.invoiceNumber) {
400
- return "Draft Invoice.pdf";
396
+ return "Proforma";
401
397
  }
402
398
  else {
403
- return "Invoice.pdf";
399
+ return this.invoiceNumber ? "Final" : "Draft";
404
400
  }
405
401
  }
406
- get timesheetSummarryFileName() {
407
- return "Timesheet.pdf";
402
+ get clientName() {
403
+ var _a, _b;
404
+ return (0, utils_1.sanitizeName)((_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "");
405
+ }
406
+ get projectName() {
407
+ var _a, _b;
408
+ return (0, utils_1.sanitizeName)((_b = (_a = this.project) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "");
409
+ }
410
+ getActiveBillingTransactions() {
411
+ var _a;
412
+ return (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => transaction.status !== billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED);
408
413
  }
409
- get OPESummarryFileName() {
410
- return "OPE.pdf";
414
+ hasActiveTranansactions() {
415
+ const billTransactions = this.getActiveBillingTransactions();
416
+ return billTransactions && billTransactions.length > 0;
411
417
  }
412
418
  }
413
419
  exports.BillingEntityModel = BillingEntityModel;
@@ -442,3 +442,4 @@ export declare function removeDuplicatesByKey<T, K extends keyof T>(items: T[],
442
442
  * Preserves the exact type of the key (string[] or number[]).
443
443
  */
444
444
  export declare function getUniqueValuesByKey<T, K extends keyof T>(items: T[], key: K): T[K][];
445
+ export declare function sanitizeName(name: string): string;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.groupByFunction = groupByFunction;
13
4
  exports.groupByOneToOneFunction = groupByOneToOneFunction;
@@ -48,8 +39,10 @@ exports.sumNormalised = sumNormalised;
48
39
  exports.isDefined = isDefined;
49
40
  exports.removeDuplicatesByKey = removeDuplicatesByKey;
50
41
  exports.getUniqueValuesByKey = getUniqueValuesByKey;
42
+ exports.sanitizeName = sanitizeName;
51
43
  const date_fns_1 = require("date-fns");
52
44
  const lodash_1 = require("lodash");
45
+ const constants_1 = require("../constants");
53
46
  const util_constants_1 = require("../constants/util.constants");
54
47
  const error_key_enum_1 = require("../enums/error.key.enum");
55
48
  const exceptions_1 = require("../exceptions");
@@ -321,43 +314,39 @@ function getFilterByPermission(permissionFilterConfig, propertyName, userPermiss
321
314
  : dtoFilter,
322
315
  };
323
316
  }
324
- function getFilterByPermissionFn(permissionFilterConfig_1, propertyName_1, userPermission_1, filterDto_1) {
325
- return __awaiter(this, arguments, void 0, function* (permissionFilterConfig, propertyName, userPermission, filterDto, emptyValue = []) {
326
- const filterData = yield permissionFilterConfig[userPermission]();
317
+ async function getFilterByPermissionFn(permissionFilterConfig, propertyName, userPermission, filterDto, emptyValue = []) {
318
+ const filterData = await permissionFilterConfig[userPermission]();
319
+ const dtoFilter = filterDto[propertyName];
320
+ const permissionFilter = filterData[propertyName];
321
+ const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
322
+ const isPermissionFilterIdPresent = permissionFilter && permissionFilter.length > 0;
323
+ return {
324
+ [propertyName]: isPermissionFilterIdPresent
325
+ ? isDtoFilterIdPresent
326
+ ? arrayIntersection(permissionFilter, dtoFilter).length > 0
327
+ ? arrayIntersection(permissionFilter, dtoFilter)
328
+ : emptyValue
329
+ : permissionFilter
330
+ : dtoFilter,
331
+ };
332
+ }
333
+ async function getPropertyFilterByPermissionFn(permissionFilterConfig, propertyNames, userPermission, filterDto, emptyValue = []) {
334
+ const filterData = await permissionFilterConfig[userPermission]();
335
+ const result = {};
336
+ for (const propertyName of propertyNames) {
327
337
  const dtoFilter = filterDto[propertyName];
328
338
  const permissionFilter = filterData[propertyName];
329
339
  const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
330
340
  const isPermissionFilterIdPresent = permissionFilter && permissionFilter.length > 0;
331
- return {
332
- [propertyName]: isPermissionFilterIdPresent
333
- ? isDtoFilterIdPresent
334
- ? arrayIntersection(permissionFilter, dtoFilter).length > 0
335
- ? arrayIntersection(permissionFilter, dtoFilter)
336
- : emptyValue
337
- : permissionFilter
338
- : dtoFilter,
339
- };
340
- });
341
- }
342
- function getPropertyFilterByPermissionFn(permissionFilterConfig_1, propertyNames_1, userPermission_1, filterDto_1) {
343
- return __awaiter(this, arguments, void 0, function* (permissionFilterConfig, propertyNames, userPermission, filterDto, emptyValue = []) {
344
- const filterData = yield permissionFilterConfig[userPermission]();
345
- const result = {};
346
- for (const propertyName of propertyNames) {
347
- const dtoFilter = filterDto[propertyName];
348
- const permissionFilter = filterData[propertyName];
349
- const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
350
- const isPermissionFilterIdPresent = permissionFilter && permissionFilter.length > 0;
351
- result[propertyName] = isPermissionFilterIdPresent
352
- ? isDtoFilterIdPresent
353
- ? arrayIntersection(permissionFilter, dtoFilter).length > 0
354
- ? arrayIntersection(permissionFilter, dtoFilter)
355
- : emptyValue
356
- : permissionFilter
357
- : dtoFilter;
358
- }
359
- return result;
360
- });
341
+ result[propertyName] = isPermissionFilterIdPresent
342
+ ? isDtoFilterIdPresent
343
+ ? arrayIntersection(permissionFilter, dtoFilter).length > 0
344
+ ? arrayIntersection(permissionFilter, dtoFilter)
345
+ : emptyValue
346
+ : permissionFilter
347
+ : dtoFilter;
348
+ }
349
+ return result;
361
350
  }
362
351
  /**
363
352
  * Sets a property value on an object with proper TypeScript type safety.
@@ -810,3 +799,6 @@ function removeDuplicatesByKey(items, key) {
810
799
  function getUniqueValuesByKey(items, key) {
811
800
  return [...new Set(items.map((item) => item[key]))];
812
801
  }
802
+ function sanitizeName(name) {
803
+ return name.replace(constants_1.PROHIBITED_CHARS, " ").replace(/\s+/g, " ").trim();
804
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.72.4-beta.0",
3
+ "version": "10.72.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [