law-common 10.72.9 → 10.72.13

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/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -1,4 +1,4 @@
1
- import { BillingActionsEnum, BillingEntityModel, BillingStatusEnum, EntityModelRelationHelper, IBillingEntity, IBillingProfileEntity, IBillingReimbursementExpenseEntity, IBillingTimesheetEntity, IDesignationEntity, IProjectEntity, IUserEntity } from "../../entities";
1
+ import { BillingActionsEnum, BillingStatusEnum, EntityModelRelationHelper, IBillingEntity, IBillingReimbursementExpenseEntity, IBillingTimesheetEntity, IProjectEntity, IUserEntity } from "../../entities";
2
2
  import { IUpdateBillingDto } from "./billing.update.dto.interface";
3
3
  export type IBillingEntityResponse = {
4
4
  billing: IBillingEntity;
@@ -33,8 +33,5 @@ export type IBillingFlowContextData = {
33
33
  };
34
34
  export interface IBillingExportContext {
35
35
  currentUser: IUserEntity;
36
- billingEntity: BillingEntityModel;
37
36
  billingEntityModelRelationHelper: EntityModelRelationHelper;
38
- billingProfileEntity: IBillingProfileEntity[];
39
- designationEntites: IDesignationEntity[];
40
37
  }
@@ -1,5 +1,12 @@
1
+ import { BillingStatusEnum } from "../entities";
1
2
  export declare const billingPrefixCompanyName = "ALC";
2
3
  export declare const billingSequenceSeperator = "-";
3
4
  export declare const billingSequenceSeperatorForCurrentFy = "/";
4
5
  export declare const currentFY = "2526";
5
6
  export declare const PROHIBITED_CHARS = "\\ / : * ? \" < > | . , ; = # % & { } $ ! ' @ ` ~ ^ [ ] ( ) +";
7
+ export declare enum BillingTemplateTitle {
8
+ PROFORMA_INVOICE = "PROFORMA INVOICE",
9
+ INVOICE = "INVOICE",
10
+ DRAFT_INVOICE = "DRAFT INVOICE"
11
+ }
12
+ export declare const proFormaInvoiceStatuses: BillingStatusEnum[];
@@ -1,8 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROHIBITED_CHARS = exports.currentFY = exports.billingSequenceSeperatorForCurrentFy = exports.billingSequenceSeperator = exports.billingPrefixCompanyName = void 0;
3
+ exports.proFormaInvoiceStatuses = exports.BillingTemplateTitle = exports.PROHIBITED_CHARS = exports.currentFY = exports.billingSequenceSeperatorForCurrentFy = exports.billingSequenceSeperator = exports.billingPrefixCompanyName = void 0;
4
+ const entities_1 = require("../entities");
4
5
  exports.billingPrefixCompanyName = "ALC";
5
6
  exports.billingSequenceSeperator = "-";
6
7
  exports.billingSequenceSeperatorForCurrentFy = "/";
7
8
  exports.currentFY = "2526";
8
9
  exports.PROHIBITED_CHARS = `\\ / : * ? " < > | . , ; = # % & { } $ ! ' @ \` ~ ^ [ ] ( ) +`;
10
+ var BillingTemplateTitle;
11
+ (function (BillingTemplateTitle) {
12
+ BillingTemplateTitle["PROFORMA_INVOICE"] = "PROFORMA INVOICE";
13
+ BillingTemplateTitle["INVOICE"] = "INVOICE";
14
+ BillingTemplateTitle["DRAFT_INVOICE"] = "DRAFT INVOICE";
15
+ })(BillingTemplateTitle || (exports.BillingTemplateTitle = BillingTemplateTitle = {}));
16
+ exports.proFormaInvoiceStatuses = [
17
+ entities_1.BillingStatusEnum.PENDING_APPROVAL,
18
+ entities_1.BillingStatusEnum.REQUEST_CHANGES,
19
+ entities_1.BillingStatusEnum.INTERNAL_APPROVED,
20
+ entities_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
21
+ entities_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
22
+ entities_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
23
+ ];
@@ -0,0 +1,39 @@
1
+ import { IEntityServiceResponse } from "./entity.utils.interface";
2
+ export declare enum AggregationOperation {
3
+ SUM = "sum",
4
+ MAX = "max",
5
+ MIN = "min",
6
+ COUNT = "count",
7
+ AVG = "avg"
8
+ }
9
+ export declare enum RetainEntities {
10
+ YES = "yes",
11
+ NO = "no"
12
+ }
13
+ export type NumericKeys<T> = {
14
+ [K in keyof T]: T[K] extends number ? K : never;
15
+ }[keyof T];
16
+ export type AggregationFields<T> = {
17
+ [K in NumericKeys<T> as `sum_${string & K}`]?: number;
18
+ } & {
19
+ [K in NumericKeys<T> as `avg_${string & K}`]?: number;
20
+ } & {
21
+ [K in keyof T as `max_${string & K}`]?: number;
22
+ } & {
23
+ [K in keyof T as `min_${string & K}`]?: number;
24
+ } & {
25
+ [K in keyof T as `count_${string & K}`]?: number;
26
+ };
27
+ export interface IEntityAggregationConfig<T> {
28
+ retainEntities: boolean;
29
+ groupingBy: (keyof T)[];
30
+ sum?: NumericKeys<T>[];
31
+ max?: (keyof T)[];
32
+ min?: (keyof T)[];
33
+ count?: (keyof T)[];
34
+ avg?: NumericKeys<T>[];
35
+ }
36
+ export interface IBaseEntityServiceResponseWithAggregation<T> {
37
+ baseEntities: (T & AggregationFields<T>)[] | T[];
38
+ relatedEntities?: IEntityServiceResponse;
39
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RetainEntities = exports.AggregationOperation = void 0;
4
+ var AggregationOperation;
5
+ (function (AggregationOperation) {
6
+ AggregationOperation["SUM"] = "sum";
7
+ AggregationOperation["MAX"] = "max";
8
+ AggregationOperation["MIN"] = "min";
9
+ AggregationOperation["COUNT"] = "count";
10
+ AggregationOperation["AVG"] = "avg";
11
+ })(AggregationOperation || (exports.AggregationOperation = AggregationOperation = {}));
12
+ var RetainEntities;
13
+ (function (RetainEntities) {
14
+ RetainEntities["YES"] = "yes";
15
+ RetainEntities["NO"] = "no";
16
+ })(RetainEntities || (exports.RetainEntities = RetainEntities = {}));
@@ -71,6 +71,7 @@ import { WebsiteNewsletterSubscriptionEntityModel } from "../model/website_newsl
71
71
  import { WorkFromHomeEntityModel } from "../model/work-from-home.entity.model";
72
72
  import { WorkFromHomeHistoryEntityModel } from "../model/work_from_home_history.entity.model";
73
73
  import { IAddressBookEntity } from "./address-book.entity.interface";
74
+ import { AggregationFields, IEntityAggregationConfig } from "./aggregation.utils";
74
75
  import { IBankEntity } from "./bank.entity.interface";
75
76
  import { IBankHistoryEntity } from "./bank_history.entity.interface";
76
77
  import { IBillingReimbursementExpenseHistoryEntity } from "./billing-reimbursement-expense-history.entity.interface";
@@ -248,12 +249,18 @@ export type IBaseEntityServiceResponse<T> = {
248
249
  baseEntities: T[];
249
250
  relatedEntities?: IEntityServiceResponse;
250
251
  virtualEntities?: IEntityServiceResponse;
252
+ aggregateEntities?: {
253
+ [key in EntityEnum | VirtualEntityEnum]?: any[];
254
+ };
251
255
  };
252
256
  export type IBaseEntityApiResponse<T> = {
253
257
  baseEntities: T[];
254
258
  relatedEntities?: {
255
259
  [K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
256
260
  };
261
+ aggregateEntities?: {
262
+ [key in EntityEnum | VirtualEntityEnum]?: AggregationFields<EnumToModel<key>>[];
263
+ };
257
264
  };
258
265
  export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_HISTORY ? IBillingHistoryEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.BILLING_TIMESHEET_HISTORY ? IBillingTimesheetHistoryEntity : T extends EntityEnum.BILLING_REIMBURESMENT_EXPENSE_HISTORY ? IBillingReimbursementExpenseHistoryEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? IBillingTransactionHistoryEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.REIMBURSEMENT_HISTORY ? IReimbursementHistoryEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.CLIENT_INTRODUCING_MAPPING ? IClientIntroducingMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : T extends EntityEnum.ADDRESS_BOOK ? IAddressBookEntity : T extends EntityEnum.STATE ? IStateEntity : T extends EntityEnum.GST_RATE ? IGstRateEntity : T extends EntityEnum.ORGANIZATION_TYPE ? IOrganizationTypeEntity : T extends EntityEnum.TDS_RATE ? ITdsRateEntity : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? IOrganizationTypeTdsRateMappingEntity : T extends EntityEnum.VOUCHER_TYPE ? IVoucherTypeEntity : T extends EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING ? ITdsRateVoucherTypeMappingEntity : T extends EntityEnum.EXPENSE_HEAD ? IExpenseHeadEntity : T extends EntityEnum.DOCUMENT_UPLOAD ? IDocumentUploadEntity : T extends EntityEnum.VENDOR ? IVendorEntity : T extends EntityEnum.VENDOR_INVOICE ? IVendorInvoiceEntity : T extends EntityEnum.VENDOR_INVOICE_HISTORY ? IVendorInvoiceHistoryEntity : T extends EntityEnum.VENDOR_INVOICE_HISTORY ? IVendorInvoiceHistoryEntity : T extends EntityEnum.VENDOR_INVOICE_ITEM ? IVendorInvoiceItemEntity : T extends EntityEnum.VENDOR_INVOICE_ITEM_HISTORY ? IVendorInvoiceItemHistoryEntity : T extends EntityEnum.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityEnum.WEBSITE_LEAD ? IWebsiteLeadEntity : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? IWebsiteNewsletterSubscriptionEntity : T extends EntityEnum.CLIENT_QUOTE ? IClientQuoteEntity : T extends EntityEnum.CLIENT_QUOTE_RATE ? IClientQuoteRateEntity : T extends EntityEnum.BILLING_PROFILE ? IBillingProfileEntity : T extends EntityEnum.PROJECT_REVENUE_SPLIT_MAPPING ? IProjectRevenueSplitMappingEntity : T extends EntityEnum.VENDOR_INVOICE_ITEM_HISTORY ? IVendorInvoiceItemHistoryEntity : T extends EntityEnum.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityEnum.WEBSITE_LEAD ? IWebsiteLeadEntity : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? IWebsiteNewsletterSubscriptionEntity : T extends EntityEnum.CLIENT_QUOTE ? IClientQuoteEntity : T extends EntityEnum.CLIENT_QUOTE_RATE ? IClientQuoteRateEntity : never) & {
259
266
  id: number;
@@ -299,6 +306,7 @@ export type IEntityFilterData<T extends EnumEntityType<EntityEnum | VirtualEntit
299
306
  virtualRelations?: ISearchIncludeEntity<VirtualEntityEnum>[];
300
307
  orderBy?: Partial<Record<keyof T, ColumnOrderBy>>;
301
308
  limit?: number;
309
+ aggregation?: IEntityAggregationConfig<T>;
302
310
  };
303
311
  export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
304
312
  id?: number[];
@@ -332,6 +340,7 @@ export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
332
340
  virtualRelations?: ISearchIncludeEntity<EntityRelations[VirtualEntityEnum]>[];
333
341
  orderBy?: Partial<Record<keyof EnumEntityType<T>, ColumnOrderBy>>;
334
342
  limit?: number;
343
+ aggregation?: IEntityAggregationConfig<EnumEntityType<T>>;
335
344
  };
336
345
  export type IEntityHistoryParsed = {
337
346
  parsedData: any;
@@ -382,6 +391,10 @@ export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByC
382
391
  export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.BILLING_HISTORY ? BillingHistoryEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.INTERMEDIARY_BANK ? IntermediaryBankEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.BILLING_REIMBURESMENT_EXPENSE_HISTORY ? BillingReimbursementExpenseHistoryEntityModel : T extends EntityEnum.LEAVE ? LeaveEntityModel : T extends EntityEnum.WORK_FROM_HOME ? WorkFromHomeEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : T extends EntityEnum.CLIENT_AFFILIATE ? ClientAffiliateEntityModel : T extends EntityEnum.BANK ? BankEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationEntityModel : T extends EntityEnum.TASK ? TaskEntityModel : T extends EntityEnum.BILLING_TIMESHEET ? BillingTimesheetEntityModel : T extends EntityEnum.BILLING_TIMESHEET_HISTORY ? BillingTimesheetHistoryEntityModel : T extends EntityEnum.TIMESHEET ? TimesheetEntityModel : T extends EntityEnum.TIMESHEET_HISTORY ? TimesheetHistoryEntityModel : T extends EntityEnum.COUNTRY ? CountryEntityModel : T extends EntityEnum.BILLING_TRANSACTION ? BillingTransactionEntityModel : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? BillingTransactionHistoryEntityModel : T extends EntityEnum.ADDRESS_BOOK ? AddressBookEntityModel : T extends EntityEnum.STATE ? StateEntityModel : T extends EntityEnum.GST_RATE ? GstRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE ? OrganizationTypeEntityModel : T extends EntityEnum.TDS_RATE ? TdsRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? OrganizationTypeTdsRateMappingEntityModel : T extends EntityEnum.VOUCHER_TYPE ? VoucherTypeEntityModel : T extends EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING ? TdsRateVoucherTypeMappingEntityModel : T extends EntityEnum.ORGANIZATION ? OrganizationEntityModel : T extends EntityEnum.INDUSTRY ? IndustryEntityModel : T extends EntityEnum.EXPENSE_TYPE ? ExpenseTypeEntityModel : T extends EntityEnum.DESIGNATION ? DesignationEntityModel : T extends EntityEnum.RATE ? RateEntityModel : T extends EntityEnum.ROLE ? RoleEntityModel : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? RolePermissionMappingEntityModel : T extends EntityEnum.PERMISSION ? PermissionEntityModel : T extends EntityEnum.EXPENSE_HEAD ? ExpenseHeadEntityModel : T extends EntityEnum.DOCUMENT_UPLOAD ? DocumentUploadEntityModel : T extends EntityEnum.VENDOR ? VendorEntityModel : T extends EntityEnum.VENDOR_INVOICE ? VendorInvoiceEntityModel : T extends EntityEnum.VENDOR_INVOICE_HISTORY ? VendorInvoiceHistoryEntityModel : T extends EntityEnum.OFFICE_LOCATION ? OfficeLocationEntityModel : T extends EntityEnum.VENDOR_INVOICE_ITEM ? VendorInvoiceItemEntityModel : T extends EntityEnum.VENDOR_INVOICE_ITEM_HISTORY ? VendorInvoiceItemHistoryEntityModel : T extends EntityEnum.VENDOR_HISTORY ? VendorHistoryEntityModel : T extends EntityEnum.WEBSITE_LEAD ? WebsiteLeadEntityModel : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? WebsiteNewsletterSubscriptionEntityModel : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? WorkFromHomeHistoryEntityModel : T extends EntityEnum.LEAVE_HISTORY ? LeaveHistoryEntityModel : T extends EntityEnum.BANK_HISTORY ? BankHistoryEntityModel : T extends EntityEnum.REIMBURSEMENT_HISTORY ? ReimbursementHistoryEntityModel : T extends EntityEnum.CLIENT_USER_MAPPING ? ClientUserMappingEntityModel : T extends EntityEnum.CLIENT_INTRODUCING_MAPPING ? ClientIntroducingMappingEntityModel : T extends EntityEnum.HOLIDAY_LIST ? HolidayListEntityModel : T extends EntityEnum.CRON_JOBS ? CronJobsEntityModel : T extends EntityEnum.TO_DO_LIST ? ToDoListEntityModel : T extends EntityEnum.CLIENT_QUOTE ? ClientQuoteEntityModel : T extends EntityEnum.CLIENT_QUOTE_RATE ? ClientQuoteRateEntityModel : T extends EntityEnum.BILLING_PROFILE ? BillingProfileEntityModel : T extends EntityEnum.PROJECT_REVENUE_SPLIT_MAPPING ? ProjectRevenueSplitMappingEntityModel : T extends EntityEnum.WEBSITE_LEAD ? WebsiteLeadEntityModel : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? WebsiteNewsletterSubscriptionEntityModel : T extends EntityEnum.CLIENT_QUOTE ? ClientQuoteEntityModel : T extends EntityEnum.CLIENT_QUOTE_RATE ? ClientQuoteRateEntityModel : T extends EntityEnum.DESIGNATION ? DesignationEntityModel : T extends EntityEnum.RATE ? RateEntityModel : UserEntityModel;
383
392
  export type EntityMap = {
384
393
  [key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
394
+ } & {
395
+ aggregateEntities?: {
396
+ [key in EntityEnum | VirtualEntityEnum]: AggregationFields<EnumToModel<key>>[];
397
+ };
385
398
  };
386
399
  export type EntityIndexMap = {
387
400
  [key in EntityEnum | VirtualEntityEnum]: {
@@ -1,4 +1,5 @@
1
- import { IBillingFlowConfig } from "../../api";
1
+ import { IBillingFlowConfig, IBillingParticulars } from "../../api";
2
+ import { BillingTemplateTitle } from "../../constants";
2
3
  import { CurrencyEnum } from "../../enums";
3
4
  import { IDtoValidationError, Result } from "../../misc";
4
5
  import { DeleteDocumentDetails, DocumentFields } from "../../utils";
@@ -68,6 +69,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
68
69
  isProjectComplete?: boolean;
69
70
  static readonly BILLING_ENTITY_DOCUMENT_TYPES: readonly ["invoice"];
70
71
  static validateDocumentNoDocumentFile(data: DocumentFields<typeof BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES>, deleteDetails?: DeleteDocumentDetails<typeof BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES>): Result<void, IDtoValidationError[]>;
72
+ get bankFromBillingBankId(): BankEntityModel | undefined;
71
73
  get intermediaryBanks(): import("./intermediary-bank.entity.model").IntermediaryBankEntityModel[] | undefined;
72
74
  get reimbursements(): ReimbursementEntityModel[];
73
75
  static relationConfigs: RelationConfigs<[
@@ -109,6 +111,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
109
111
  validateAdvanceBillingId(adjustedBillingTransactions: IBillingTransactionEntity[]): void;
110
112
  getApprovedBillingTransactionsTotalAmount(): number;
111
113
  getCurrentBillingBillingProfile(billingProfiles: BillingProfileEntityModel[]): BillingProfileEntityModel[];
114
+ get billingProfileParticulars(): IBillingParticulars;
112
115
  static getLatestBillingEntityModel(billingEntityModels: BillingEntityModel[]): BillingEntityModel | void;
113
116
  static getNextInvoiceNumber(params: {
114
117
  type: BillingInvoiceNumberPrefixEnum;
@@ -147,4 +150,10 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
147
150
  get projectName(): string;
148
151
  getActiveBillingTransactions(): BillingTransactionEntityModel[] | undefined;
149
152
  hasActiveTranansactions(): boolean | undefined;
153
+ isClientInvoice(): boolean;
154
+ get clientAffiliate(): import("./client-affiliate.entity.model").ClientAffiliateEntityModel | undefined;
155
+ get isForeignBilling(): boolean;
156
+ get isForeignCurrencyProject(): boolean;
157
+ get isProformaInvoice(): boolean;
158
+ get title(): BillingTemplateTitle;
150
159
  }
@@ -52,6 +52,10 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
52
52
  static validateDocumentNoDocumentFile(data, deleteDetails) {
53
53
  return (0, utils_1.validateDocumentPairs)(BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES, data, deleteDetails);
54
54
  }
55
+ get bankFromBillingBankId() {
56
+ var _a;
57
+ return (_a = this.bank) === null || _a === void 0 ? void 0 : _a.find((b) => b.id === this.bankId);
58
+ }
55
59
  get intermediaryBanks() {
56
60
  const thisBank = this.bank;
57
61
  if (thisBank)
@@ -260,9 +264,12 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
260
264
  return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING, billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING].includes(entity.status))) !== null && _b !== void 0 ? _b : [], "amount");
261
265
  }
262
266
  getCurrentBillingBillingProfile(billingProfiles) {
263
- const billingParticularsOfCurrentBilling = JSON.parse(this.particulars);
267
+ const billingParticularsOfCurrentBilling = this.billingProfileParticulars;
264
268
  return billingProfiles.filter((profile) => profile.name === billingParticularsOfCurrentBilling.name);
265
269
  }
270
+ get billingProfileParticulars() {
271
+ return JSON.parse(this.particulars);
272
+ }
266
273
  static getLatestBillingEntityModel(billingEntityModels) {
267
274
  if (billingEntityModels.length === 0)
268
275
  return;
@@ -415,6 +422,35 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
415
422
  const billTransactions = this.getActiveBillingTransactions();
416
423
  return billTransactions && billTransactions.length > 0;
417
424
  }
425
+ isClientInvoice() {
426
+ return this.invoiceEntityType === billing_invoice_type_enum_1.BillingInvoiceTypeEnum.CLIENT;
427
+ }
428
+ get clientAffiliate() {
429
+ var _a, _b;
430
+ return (_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.clientAffiliates) === null || _b === void 0 ? void 0 : _b.find((affiliate) => affiliate.id === this.invoiceEntityId);
431
+ }
432
+ get isForeignBilling() {
433
+ var _a;
434
+ if (this.isClientInvoice()) {
435
+ return ((_a = this.client) === null || _a === void 0 ? void 0 : _a.country) !== undefined && this.client.country !== "India";
436
+ }
437
+ const affiliate = this.clientAffiliate;
438
+ return (affiliate === null || affiliate === void 0 ? void 0 : affiliate.country) !== undefined && affiliate.country !== "India";
439
+ }
440
+ get isForeignCurrencyProject() {
441
+ var _a, _b;
442
+ return (_b = (_a = this.project) === null || _a === void 0 ? void 0 : _a.isForeignCurrencyProjoect()) !== null && _b !== void 0 ? _b : false;
443
+ }
444
+ get isProformaInvoice() {
445
+ return this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE;
446
+ }
447
+ get title() {
448
+ return this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE
449
+ ? constants_1.BillingTemplateTitle.PROFORMA_INVOICE
450
+ : constants_1.proFormaInvoiceStatuses.includes(this.status)
451
+ ? constants_1.BillingTemplateTitle.DRAFT_INVOICE
452
+ : constants_1.BillingTemplateTitle.INVOICE;
453
+ }
418
454
  }
419
455
  exports.BillingEntityModel = BillingEntityModel;
420
456
  BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES = ["invoice"];
@@ -1,4 +1,4 @@
1
- import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IApiEntity, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
2
2
  import { BaseEntityModel } from "./base.entity.model";
3
3
  export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
4
4
  export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
@@ -12,11 +12,7 @@ export declare const entityEnumToEntityModel: {
12
12
  export declare function entityMapToModels(entityMap: EntityMap): void;
13
13
  export declare function parseEntities<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap: EntityMap): EntityMap;
14
14
  export declare function entityMapToEntityIndexMap(entityMap: EntityMap, entityRelationsFor: EntityEnum[]): EntityIndexMap;
15
- export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: {
16
- [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
17
- }): {
18
- [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
19
- };
15
+ export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: EntityMap): EntityMap;
20
16
  export declare function removeEntityById(entityIndexMap: EntityIndexMap, entity: EntityEnum, id: number): void;
21
17
  export declare class EntityModelRelationHelper {
22
18
  private entityMap;
@@ -217,6 +217,14 @@ function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
217
217
  relatedEntities[entityName], entityName, entityMap);
218
218
  }
219
219
  }
220
+ if (json["aggregateEntities"]) {
221
+ if (!entityMap["aggregateEntities"]) {
222
+ entityMap["aggregateEntities"] = {};
223
+ }
224
+ for (const entityName in json["aggregateEntities"]) {
225
+ entityMap["aggregateEntities"][entityName] = json["aggregateEntities"][entityName];
226
+ }
227
+ }
220
228
  return entityMap;
221
229
  }
222
230
  function removeEntityById(entityIndexMap, entity, id) {
@@ -36,4 +36,5 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
36
36
  static relationConfigs: RelationConfigs<[EntityEnum.PROJECT_USER_MAPPING, EntityEnum.CLIENT], EntityEnum.PROJECT>;
37
37
  populateUsers(users: UserEntityModel[], projectUserMapping: ProjectUserMappingEntityModel[]): void;
38
38
  getRelationConfigs(): [import("../interface/relation-config.interface").IRelationConfig<EntityEnum.PROJECT_USER_MAPPING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.CLIENT, EntityEnum.PROJECT>];
39
+ isForeignCurrencyProjoect(): boolean;
39
40
  }
@@ -86,6 +86,9 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
86
86
  getRelationConfigs() {
87
87
  return ProjectEntityModel.relationConfigs;
88
88
  }
89
+ isForeignCurrencyProjoect() {
90
+ return this.currency !== enums_1.CurrencyEnum.INR;
91
+ }
89
92
  }
90
93
  exports.ProjectEntityModel = ProjectEntityModel;
91
94
  ProjectEntityModel.relationConfigs = [
package/dist/src/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
37
  };
@@ -149,12 +149,12 @@ export declare function getEnumNames(enumType: object): string[];
149
149
  export declare function getFilterByPermission<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
150
150
  [key: string]: IEntityFilterData<T>;
151
151
  }, propertyName: keyof T, userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): {
152
- [x: string]: any;
152
+ [propertyName]: any;
153
153
  };
154
154
  export declare function getFilterByPermissionFn<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
155
155
  [key: string]: () => Promise<IEntityFilterData<T>>;
156
156
  }, propertyName: keyof T, userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): Promise<{
157
- [x: string]: any;
157
+ [propertyName]: any;
158
158
  }>;
159
159
  export declare function getPropertyFilterByPermissionFn<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
160
160
  [key: string]: () => Promise<IEntityFilterData<T>>;
@@ -3,9 +3,10 @@ export declare function formatString(input: string): string;
3
3
  * Converts a string to Title Case.
4
4
  *
5
5
  * Examples:
6
- * - "APPROVE" => "Approve"
7
- * - "PENDING_REVIEW" => "Pending Review"
8
- * - "in_progress" => "In Progress"
6
+ * - "APPROVE" => "Approve"
7
+ * - "PENDING_REVIEW" => "Pending Review"
8
+ * - "in_progress" => "In Progress"
9
+ * - "DRAFT INVOICE" => "Draft Invoice"
9
10
  *
10
11
  * @param {string} input - The string to convert.
11
12
  * @returns {string} - The string in Title Case.
@@ -20,9 +20,10 @@ function formatString(input) {
20
20
  * Converts a string to Title Case.
21
21
  *
22
22
  * Examples:
23
- * - "APPROVE" => "Approve"
24
- * - "PENDING_REVIEW" => "Pending Review"
25
- * - "in_progress" => "In Progress"
23
+ * - "APPROVE" => "Approve"
24
+ * - "PENDING_REVIEW" => "Pending Review"
25
+ * - "in_progress" => "In Progress"
26
+ * - "DRAFT INVOICE" => "Draft Invoice"
26
27
  *
27
28
  * @param {string} input - The string to convert.
28
29
  * @returns {string} - The string in Title Case.
@@ -30,11 +31,11 @@ function formatString(input) {
30
31
  function toTitleCase(input) {
31
32
  if (!input)
32
33
  return "";
33
- // Replace underscores or hyphens with spaces, then split into words
34
- const words = input.replace(/[_-]+/g, " ").split(" ");
35
- // Capitalize first letter of each word
36
- const titleCased = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
37
- return titleCased;
34
+ return input
35
+ .replace(/[_-]+/g, " ")
36
+ .split(/\s+/) // split by one or more spaces
37
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
38
+ .join(" ");
38
39
  }
39
40
  /**
40
41
  * Converts a camelCase or PascalCase string into a human-readable
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.72.9",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rm -rf dist",
11
- "build": "npm run clean && tsc",
12
- "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
13
- "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
- "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
- "publish:major": "npm version major && git push && npm run build && npm publish",
16
- "link": "npm run build && npm link",
17
- "test": "jest",
18
- "format": "prettier --write .",
19
- "check-format": "prettier --check .",
20
- "pull:link": "git pull && npm run link"
21
- },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "devDependencies": {
26
- "@types/jest": "^29.5.13",
27
- "@types/lodash": "^4.17.21",
28
- "@types/node": "^22.6.1",
29
- "jest": "^29.7.0",
30
- "prettier": "3.8.1",
31
- "ts-jest": "^29.2.5",
32
- "ts-node": "^10.9.2",
33
- "typescript": "^5.6.2"
34
- },
35
- "dependencies": {
36
- "@types/express": "^5.0.0",
37
- "@types/multer": "^1.4.12",
38
- "date-fns": "^4.1.0",
39
- "lodash": "4.17.21"
40
- }
41
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "10.72.13",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rm -rf dist",
11
+ "build": "npm run clean && tsc",
12
+ "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
13
+ "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
+ "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
+ "publish:major": "npm version major && git push && npm run build && npm publish",
16
+ "link": "npm run build && npm link",
17
+ "test": "jest",
18
+ "format": "prettier --write .",
19
+ "check-format": "prettier --check .",
20
+ "pull:link": "git pull && npm run link"
21
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "devDependencies": {
26
+ "@types/jest": "^29.5.13",
27
+ "@types/lodash": "^4.17.21",
28
+ "@types/node": "^22.6.1",
29
+ "jest": "^29.7.0",
30
+ "prettier": "3.8.1",
31
+ "ts-jest": "^29.2.5",
32
+ "ts-node": "^10.9.2",
33
+ "typescript": "^5.6.2"
34
+ },
35
+ "dependencies": {
36
+ "@types/express": "^5.0.0",
37
+ "@types/multer": "^1.4.12",
38
+ "date-fns": "^4.1.0",
39
+ "lodash": "4.17.21"
40
+ }
41
+ }