law-common 10.18.1-beta.0 → 10.18.1-beta.10
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/dist/src/api/index.d.ts +1 -0
- package/dist/src/api/index.js +1 -0
- package/dist/src/api/interface/project-user-mapping.entity.api.d.ts +3 -0
- package/dist/src/api/interface/project-user-mapping.entity.api.js +2 -0
- package/dist/src/entities/enums/relation-type.enum.d.ts +4 -0
- package/dist/src/entities/enums/relation-type.enum.js +8 -0
- package/dist/src/entities/index.d.ts +16 -0
- package/dist/src/entities/index.js +16 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +17 -0
- package/dist/src/entities/interface/relation-config.interface.d.ts +16 -0
- package/dist/src/entities/interface/relation-config.interface.js +2 -0
- package/dist/src/entities/model/bank.entity.model.d.ts +2 -2
- package/dist/src/entities/model/bank.entity.model.js +6 -6
- package/dist/src/entities/model/base.entity.model.d.ts +8 -0
- package/dist/src/entities/model/base.entity.model.js +69 -0
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.d.ts +25 -0
- package/dist/src/entities/model/billing-reimbursement-expense.entity.model.js +35 -0
- package/dist/src/entities/model/billing.entity.model.d.ts +79 -0
- package/dist/src/entities/model/billing.entity.model.js +228 -0
- package/dist/src/entities/model/client.entity.model.d.ts +35 -0
- package/dist/src/entities/model/client.entity.model.js +50 -0
- package/dist/src/entities/model/configuration.model.d.ts +8 -9
- package/dist/src/entities/model/configuration.model.js +10 -5
- package/dist/src/entities/model/designation.entity.model.d.ts +5 -5
- package/dist/src/entities/model/designation.entity.model.js +21 -8
- package/dist/src/entities/model/entity.model.interface.d.ts +8 -0
- package/dist/src/entities/model/entity.model.interface.js +69 -0
- package/dist/src/entities/model/holiday.entity.model.d.ts +1 -19
- package/dist/src/entities/model/holiday.entity.model.js +42 -29
- package/dist/src/entities/model/leave.entity.model.d.ts +5 -5
- package/dist/src/entities/model/leave.entity.model.js +4 -1
- package/dist/src/entities/model/project-user-mapping.entity.model.d.ts +26 -0
- package/dist/src/entities/model/project-user-mapping.entity.model.js +49 -0
- package/dist/src/entities/model/project.entity.model.d.ts +40 -0
- package/dist/src/entities/model/project.entity.model.js +105 -0
- package/dist/src/entities/model/reimbursement-expense.entity.model.d.ts +27 -0
- package/dist/src/entities/model/reimbursement-expense.entity.model.js +43 -0
- package/dist/src/entities/model/reimbursement.entity.model.d.ts +32 -0
- package/dist/src/entities/model/reimbursement.entity.model.js +34 -0
- package/dist/src/entities/model/task.entity.model.d.ts +14 -0
- package/dist/src/entities/model/task.entity.model.js +23 -0
- package/dist/src/entities/model/timesheet.entity.model.d.ts +18 -0
- package/dist/src/entities/model/timesheet.entity.model.js +25 -0
- package/dist/src/entities/model/user.entity.model.d.ts +43 -0
- package/dist/src/entities/model/user.entity.model.js +30 -0
- package/dist/src/model/entities/timesheet.model.d.ts +2 -0
- package/dist/src/model/entities/timesheet.model.js +5 -0
- package/package.json +1 -1
package/dist/src/api/index.d.ts
CHANGED
|
@@ -82,3 +82,4 @@ export * from "./interface/cron-job.entity.response";
|
|
|
82
82
|
export * from "./interface/to-do.entity.api";
|
|
83
83
|
export * from "./interface/billing-reimbursement-expense.api";
|
|
84
84
|
export * from "./interface/billing-reimbursement-expense-history.api";
|
|
85
|
+
export * from "./interface/project-user-mapping.entity.api";
|
package/dist/src/api/index.js
CHANGED
|
@@ -98,3 +98,4 @@ __exportStar(require("./interface/cron-job.entity.response"), exports);
|
|
|
98
98
|
__exportStar(require("./interface/to-do.entity.api"), exports);
|
|
99
99
|
__exportStar(require("./interface/billing-reimbursement-expense.api"), exports);
|
|
100
100
|
__exportStar(require("./interface/billing-reimbursement-expense-history.api"), exports);
|
|
101
|
+
__exportStar(require("./interface/project-user-mapping.entity.api"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelationType = void 0;
|
|
4
|
+
var RelationType;
|
|
5
|
+
(function (RelationType) {
|
|
6
|
+
RelationType["ONE"] = "one";
|
|
7
|
+
RelationType["MANY"] = "many";
|
|
8
|
+
})(RelationType || (exports.RelationType = RelationType = {}));
|
|
@@ -79,3 +79,19 @@ export * from "./interface/billing-reimbursement-expense.entity.interface";
|
|
|
79
79
|
export * from "./enums/billing-reimbursement-expense-change-status.enum";
|
|
80
80
|
export * from "./interface/billing-reimbursement-expense-history.entity.interface";
|
|
81
81
|
export * from "./enums/billing-reimburement-expense-impact.enum";
|
|
82
|
+
export * from "./model/bank.entity.model";
|
|
83
|
+
export * from "./model/base.entity.model";
|
|
84
|
+
export * from "./model/billing-reimbursement-expense.entity.model";
|
|
85
|
+
export * from "./model/billing.entity.model";
|
|
86
|
+
export * from "./model/entity.model.interface";
|
|
87
|
+
export * from "./model/project-user-mapping.entity.model";
|
|
88
|
+
export * from "./model/project.entity.model";
|
|
89
|
+
export * from "./model/reimbursement-expense.entity.model";
|
|
90
|
+
export * from "./model/reimbursement.entity.model";
|
|
91
|
+
export * from "./model/task.entity.model";
|
|
92
|
+
export * from "./model/user.entity.model";
|
|
93
|
+
export * from "./model/client.entity.model";
|
|
94
|
+
export * from "./model/configuration.model";
|
|
95
|
+
export * from "./model/designation.entity.model";
|
|
96
|
+
export * from "./model/timesheet.entity.model";
|
|
97
|
+
export * from "./model/user.entity.model";
|
|
@@ -96,3 +96,19 @@ __exportStar(require("./interface/billing-reimbursement-expense.entity.interface
|
|
|
96
96
|
__exportStar(require("./enums/billing-reimbursement-expense-change-status.enum"), exports);
|
|
97
97
|
__exportStar(require("./interface/billing-reimbursement-expense-history.entity.interface"), exports);
|
|
98
98
|
__exportStar(require("./enums/billing-reimburement-expense-impact.enum"), exports);
|
|
99
|
+
__exportStar(require("./model/bank.entity.model"), exports);
|
|
100
|
+
__exportStar(require("./model/base.entity.model"), exports);
|
|
101
|
+
__exportStar(require("./model/billing-reimbursement-expense.entity.model"), exports);
|
|
102
|
+
__exportStar(require("./model/billing.entity.model"), exports);
|
|
103
|
+
__exportStar(require("./model/entity.model.interface"), exports);
|
|
104
|
+
__exportStar(require("./model/project-user-mapping.entity.model"), exports);
|
|
105
|
+
__exportStar(require("./model/project.entity.model"), exports);
|
|
106
|
+
__exportStar(require("./model/reimbursement-expense.entity.model"), exports);
|
|
107
|
+
__exportStar(require("./model/reimbursement.entity.model"), exports);
|
|
108
|
+
__exportStar(require("./model/task.entity.model"), exports);
|
|
109
|
+
__exportStar(require("./model/user.entity.model"), exports);
|
|
110
|
+
__exportStar(require("./model/client.entity.model"), exports);
|
|
111
|
+
__exportStar(require("./model/configuration.model"), exports);
|
|
112
|
+
__exportStar(require("./model/designation.entity.model"), exports);
|
|
113
|
+
__exportStar(require("./model/timesheet.entity.model"), exports);
|
|
114
|
+
__exportStar(require("./model/user.entity.model"), exports);
|
|
@@ -3,6 +3,14 @@ import { ConvertToArray } from "../../misc";
|
|
|
3
3
|
import { Modify } from "../../misc/interface/modify.interface";
|
|
4
4
|
import { EntitySearchConstraintTypeEnum } from "../enums/entity_search_constraint_type.enum";
|
|
5
5
|
import { HistoryOperationEnum } from "../enums/history_operation.enum";
|
|
6
|
+
import { BillingReimbursementExpneseEntityModel } from "../model/billing-reimbursement-expense.entity.model";
|
|
7
|
+
import { BillingEntityModel } from "../model/billing.entity.model";
|
|
8
|
+
import { ClientEntityModel } from "../model/client.entity.model";
|
|
9
|
+
import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
|
|
10
|
+
import { ProjectEntityModel } from "../model/project.entity.model";
|
|
11
|
+
import { ReimbursementExpenseEntityModel } from "../model/reimbursement-expense.entity.model";
|
|
12
|
+
import { ReimbursementEntityModel } from "../model/reimbursement.entity.model";
|
|
13
|
+
import { UserEntityModel } from "../model/user.entity.model";
|
|
6
14
|
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
7
15
|
import { IBankEntity } from "./bank.entity.interface";
|
|
8
16
|
import { IBankHistoryEntity } from "./bank_history.entity.interface";
|
|
@@ -267,3 +275,12 @@ export declare enum VirtualEntityEnum {
|
|
|
267
275
|
}
|
|
268
276
|
export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
|
|
269
277
|
export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
|
|
278
|
+
export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : 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 : UserEntityModel;
|
|
279
|
+
export type EntityMap = {
|
|
280
|
+
[key in EntityEnum]: EnumToModel<key>[];
|
|
281
|
+
};
|
|
282
|
+
export type EntityIndexMap = {
|
|
283
|
+
[key in EntityEnum]: {
|
|
284
|
+
[id: number]: EnumToModel<key>;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RelationType } from "../enums/relation-type.enum";
|
|
2
|
+
import { EntityEnum, EnumEntityType, VirtualEntityEnum } from "./entity.utils.interface";
|
|
3
|
+
type SourcePath<T> = (keyof T & string) | `${string}.${string}`;
|
|
4
|
+
export type IRelationConfig<T extends EntityEnum | VirtualEntityEnum, K extends EnumEntityType<EntityEnum | VirtualEntityEnum>> = {
|
|
5
|
+
name: T;
|
|
6
|
+
relation: RelationType;
|
|
7
|
+
key: string;
|
|
8
|
+
mapKeyConfig: {
|
|
9
|
+
relationKey: SourcePath<EnumEntityType<T>>;
|
|
10
|
+
key: keyof K;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type RelationConfigs<T extends readonly (EntityEnum | VirtualEntityEnum)[], E extends EnumEntityType<EntityEnum>> = {
|
|
14
|
+
[K in keyof T]: T[K] extends EntityEnum | VirtualEntityEnum ? IRelationConfig<T[K], E> : never;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IBankApiEntity } from "../../api";
|
|
2
2
|
import { BankStatusEnum } from "../enums/bank_status.enum";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class BankEntityModel implements IBankApiEntity {
|
|
4
4
|
id: number;
|
|
5
5
|
accountName: string;
|
|
6
6
|
organizationId: number;
|
|
@@ -16,5 +16,5 @@ export declare class BankEntity implements IBankApiEntity {
|
|
|
16
16
|
updatedBy: number;
|
|
17
17
|
createdOn: string;
|
|
18
18
|
updatedOn: string;
|
|
19
|
-
static fromApiEntity(apiEntity: IBankApiEntity):
|
|
19
|
+
static fromApiEntity(apiEntity: IBankApiEntity): BankEntityModel;
|
|
20
20
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BankEntityModel = void 0;
|
|
4
4
|
const bank_status_enum_1 = require("../enums/bank_status.enum");
|
|
5
|
-
class
|
|
5
|
+
class BankEntityModel {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.id = 0;
|
|
8
8
|
this.accountName = "";
|
|
@@ -15,13 +15,13 @@ class BankEntity {
|
|
|
15
15
|
this.status = bank_status_enum_1.BankStatusEnum.CREATE_APPROVAL;
|
|
16
16
|
this.createdBy = 0;
|
|
17
17
|
this.updatedBy = 0;
|
|
18
|
-
this.createdOn =
|
|
19
|
-
this.updatedOn =
|
|
18
|
+
this.createdOn = "";
|
|
19
|
+
this.updatedOn = "";
|
|
20
20
|
}
|
|
21
21
|
static fromApiEntity(apiEntity) {
|
|
22
|
-
const entity = new
|
|
22
|
+
const entity = new BankEntityModel();
|
|
23
23
|
Object.assign(entity, apiEntity);
|
|
24
24
|
return entity;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
exports.
|
|
27
|
+
exports.BankEntityModel = BankEntityModel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntityEnum, EntityIndexMap } from "../interface/entity.utils.interface";
|
|
2
|
+
export declare abstract class BaseEntityModel<T extends EntityEnum> {
|
|
3
|
+
protected entityName: T;
|
|
4
|
+
constructor(entityName: T);
|
|
5
|
+
abstract getRelationConfigs(): any[];
|
|
6
|
+
populateRelationsByIndex(entityIndexMap: EntityIndexMap): void;
|
|
7
|
+
static populateRelationsForEntities(entityIndexMap: EntityIndexMap, entityType: EntityEnum): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseEntityModel = void 0;
|
|
4
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
5
|
+
class BaseEntityModel {
|
|
6
|
+
constructor(entityName) {
|
|
7
|
+
this.entityName = entityName;
|
|
8
|
+
}
|
|
9
|
+
populateRelationsByIndex(entityIndexMap) {
|
|
10
|
+
for (const relationConfig of this.getRelationConfigs() || []) {
|
|
11
|
+
if (relationConfig.relation === relation_type_enum_1.RelationType.ONE) {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const relatedEntities = entityIndexMap[relationConfig.name] || {};
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
let foundRelatedEntities = [];
|
|
16
|
+
if (relationConfig.mapKeyConfig.key.includes(".")) {
|
|
17
|
+
const [parentKey, childKey] = relationConfig.mapKeyConfig.key.split(".");
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (this[parentKey] && this[parentKey][childKey]) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
foundRelatedEntities = [relatedEntities[this[parentKey][childKey]]];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
foundRelatedEntities = relatedEntities[
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
this[relationConfig.mapKeyConfig.key]]
|
|
28
|
+
? // @ts-ignore
|
|
29
|
+
[relatedEntities[this[relationConfig.mapKeyConfig.key]]]
|
|
30
|
+
: [];
|
|
31
|
+
}
|
|
32
|
+
if (foundRelatedEntities.length > 1) {
|
|
33
|
+
throw new Error(`Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
|
|
34
|
+
}
|
|
35
|
+
if (foundRelatedEntities.length === 0) {
|
|
36
|
+
console.warn(`No related entity found for ${relationConfig.name} with ${relationConfig.mapKeyConfig.key
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
}=${this[relationConfig.mapKeyConfig.foreignKey]}`);
|
|
39
|
+
}
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
this[relationConfig.key] = foundRelatedEntities[0];
|
|
42
|
+
}
|
|
43
|
+
else if (relationConfig.relation === relation_type_enum_1.RelationType.MANY) {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
this[relationConfig.key] = [];
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
const relatedEntities = entityIndexMap[relationConfig.name] || {};
|
|
48
|
+
for (const relatedEntity of Object.values(relatedEntities)) {
|
|
49
|
+
if (
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
relatedEntity[relationConfig.mapKeyConfig.relationKey] ===
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
this[relationConfig.mapKeyConfig.key]) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
this[relationConfig.key].push(relatedEntity);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static populateRelationsForEntities(entityIndexMap, entityType) {
|
|
62
|
+
for (const key of Object.keys(entityIndexMap[entityType] || {})) {
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
const entity = entityIndexMap[entityType][key];
|
|
65
|
+
entity.populateRelationsByIndex(entityIndexMap);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.BaseEntityModel = BaseEntityModel;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IBillingReimbursementExpenseApiEntity } from "../../api";
|
|
2
|
+
import { BillingReimbursementExpenseImpactEnum } from "../enums/billing-reimburement-expense-impact.enum";
|
|
3
|
+
import { BillingReimbursementExpenseChangedStatusEnum } from "../enums/billing-reimbursement-expense-change-status.enum";
|
|
4
|
+
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
5
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
6
|
+
export declare class BillingReimbursementExpneseEntityModel extends BaseEntityModel<EntityEnum.BILLING_REIMBURSEMENT_EXPENSE> implements IBillingReimbursementExpenseApiEntity {
|
|
7
|
+
id: number;
|
|
8
|
+
billingId: number;
|
|
9
|
+
userId: number;
|
|
10
|
+
reimbursementExpenseId: number;
|
|
11
|
+
projectId: number;
|
|
12
|
+
expenseType: string;
|
|
13
|
+
totalAmount: number;
|
|
14
|
+
expenseIncurredDate: string;
|
|
15
|
+
changedStatus: BillingReimbursementExpenseChangedStatusEnum;
|
|
16
|
+
amendmentPurpose?: string;
|
|
17
|
+
impact?: BillingReimbursementExpenseImpactEnum;
|
|
18
|
+
updatedBy: number;
|
|
19
|
+
createdBy: number;
|
|
20
|
+
createdOn: string;
|
|
21
|
+
updatedOn: string;
|
|
22
|
+
static relationConfigs: never[];
|
|
23
|
+
getRelationConfigs(): any[];
|
|
24
|
+
static fromApiEntity(apiEntity: IBillingReimbursementExpenseApiEntity): BillingReimbursementExpneseEntityModel;
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingReimbursementExpneseEntityModel = void 0;
|
|
4
|
+
const billing_reimbursement_expense_change_status_enum_1 = require("../enums/billing-reimbursement-expense-change-status.enum");
|
|
5
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
6
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
7
|
+
class BillingReimbursementExpneseEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.id = 0;
|
|
11
|
+
this.billingId = 0;
|
|
12
|
+
this.userId = 0;
|
|
13
|
+
this.reimbursementExpenseId = 0;
|
|
14
|
+
this.projectId = 0;
|
|
15
|
+
this.expenseType = "";
|
|
16
|
+
this.totalAmount = 0;
|
|
17
|
+
this.expenseIncurredDate = "";
|
|
18
|
+
this.changedStatus = billing_reimbursement_expense_change_status_enum_1.BillingReimbursementExpenseChangedStatusEnum.UNCHANGED;
|
|
19
|
+
this.amendmentPurpose = "";
|
|
20
|
+
this.updatedBy = 0;
|
|
21
|
+
this.createdBy = 0;
|
|
22
|
+
this.createdOn = "";
|
|
23
|
+
this.updatedOn = "";
|
|
24
|
+
}
|
|
25
|
+
getRelationConfigs() {
|
|
26
|
+
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
27
|
+
}
|
|
28
|
+
static fromApiEntity(apiEntity) {
|
|
29
|
+
const entity = new BillingReimbursementExpneseEntityModel(entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE);
|
|
30
|
+
Object.assign(entity, apiEntity);
|
|
31
|
+
return entity;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.BillingReimbursementExpneseEntityModel = BillingReimbursementExpneseEntityModel;
|
|
35
|
+
BillingReimbursementExpneseEntityModel.relationConfigs = [];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { IBillingApiEntity, IBillingFlowConfig } from "../../api";
|
|
2
|
+
import { CurrencyEnum } from "../../enums";
|
|
3
|
+
import { BillingTypeEnum } from "../enums/billing-type.enum";
|
|
4
|
+
import { BillingActionsEnum } from "../enums/billing.action.enum";
|
|
5
|
+
import { BillingStatusEnum } from "../enums/billing.status.enum";
|
|
6
|
+
import { BillingInvoiceTypeEnum } from "../enums/billing_invoice_type.enum";
|
|
7
|
+
import { PaymentStatusEnum } from "../enums/payment_status.enum";
|
|
8
|
+
import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
|
|
9
|
+
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
10
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
11
|
+
import { BillingReimbursementExpneseEntityModel } from "./billing-reimbursement-expense.entity.model";
|
|
12
|
+
import { ClientEntityModel } from "./client.entity.model";
|
|
13
|
+
import { ProjectEntityModel } from "./project.entity.model";
|
|
14
|
+
import { ReimbursementExpenseEntityModel } from "./reimbursement-expense.entity.model";
|
|
15
|
+
import { UserEntityModel } from "./user.entity.model";
|
|
16
|
+
export interface BillingActions {
|
|
17
|
+
label: string;
|
|
18
|
+
value: BillingActionsEnum;
|
|
19
|
+
}
|
|
20
|
+
export declare enum BillingStatusCategoryEnumForUI {
|
|
21
|
+
INTERNAL_REVIEW_STATUS = "INTERNAL_REVIEW_STATUS",
|
|
22
|
+
CLIENT_REVIEW_STATUS = "CLIENT_REVIEW_STATUS",
|
|
23
|
+
PAYMENT_STATUS = "PAYMENT_STATUS"
|
|
24
|
+
}
|
|
25
|
+
export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLING> implements IBillingApiEntity {
|
|
26
|
+
id: number;
|
|
27
|
+
startDate: string;
|
|
28
|
+
endDate: string;
|
|
29
|
+
projectId: number;
|
|
30
|
+
totalAmount: number;
|
|
31
|
+
totalMinutes: number;
|
|
32
|
+
invoiceNumber: string;
|
|
33
|
+
paymentStatus: PaymentStatusEnum;
|
|
34
|
+
status: BillingStatusEnum;
|
|
35
|
+
writeoffAmount: number;
|
|
36
|
+
totalAmountPaid: number;
|
|
37
|
+
tdsAmount: number;
|
|
38
|
+
creditNoteAmount: number;
|
|
39
|
+
invoiceEntityId: number;
|
|
40
|
+
invoiceEntityType: BillingInvoiceTypeEnum;
|
|
41
|
+
invoicePdfUrl?: string | null;
|
|
42
|
+
invoiceContactName: string;
|
|
43
|
+
bankId: number;
|
|
44
|
+
conversionRate?: number;
|
|
45
|
+
particulars: string;
|
|
46
|
+
currency: CurrencyEnum;
|
|
47
|
+
createdBy: number;
|
|
48
|
+
updatedBy: number;
|
|
49
|
+
createdOn: string;
|
|
50
|
+
updatedOn: string;
|
|
51
|
+
type: BillingTypeEnum;
|
|
52
|
+
project?: ProjectEntityModel;
|
|
53
|
+
client?: ClientEntityModel;
|
|
54
|
+
updatedByUser?: UserEntityModel;
|
|
55
|
+
billOverdue?: boolean;
|
|
56
|
+
billingIdReimbursementExpense?: BillingReimbursementExpneseEntityModel[];
|
|
57
|
+
reimbursementExpense?: ReimbursementExpenseEntityModel[];
|
|
58
|
+
static relationConfigs: RelationConfigs<[
|
|
59
|
+
EntityEnum.PROJECT,
|
|
60
|
+
EntityEnum.CLIENT,
|
|
61
|
+
EntityEnum.USER,
|
|
62
|
+
EntityEnum.REIMBURSEMENT_EXPENSE,
|
|
63
|
+
EntityEnum.BILLING_REIMBURSEMENT_EXPENSE
|
|
64
|
+
], EnumEntityType<EntityEnum.BILLING>>;
|
|
65
|
+
static fromApiEntity(apiEntity: IBillingApiEntity): BillingEntityModel;
|
|
66
|
+
getStatusCategory(): BillingStatusCategoryEnumForUI;
|
|
67
|
+
getStatusLabel(): string;
|
|
68
|
+
getTotalAmountInINR(): number;
|
|
69
|
+
getDateRange(): string;
|
|
70
|
+
getBillDate(): Date;
|
|
71
|
+
mapOverdue(configValue: string | undefined): void;
|
|
72
|
+
mapStatusCategory(status: BillingStatusEnum): BillingStatusCategoryEnumForUI;
|
|
73
|
+
mapStatusLabel(status: BillingStatusEnum): string;
|
|
74
|
+
formatDate(dateStr: string, includeYear?: boolean): string;
|
|
75
|
+
getAvailableAction(currentUserPermissions: string[], billingConfigFlow: IBillingFlowConfig, getUpdateActionVisibility: (bill: BillingEntityModel) => {
|
|
76
|
+
[key: string]: () => boolean;
|
|
77
|
+
}): BillingActionsEnum[];
|
|
78
|
+
getRelationConfigs(): any;
|
|
79
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingEntityModel = exports.BillingStatusCategoryEnumForUI = void 0;
|
|
4
|
+
const enums_1 = require("../../enums");
|
|
5
|
+
const billing_type_enum_1 = require("../enums/billing-type.enum");
|
|
6
|
+
const billing_status_enum_1 = require("../enums/billing.status.enum");
|
|
7
|
+
const billing_invoice_type_enum_1 = require("../enums/billing_invoice_type.enum");
|
|
8
|
+
const payment_status_enum_1 = require("../enums/payment_status.enum");
|
|
9
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
10
|
+
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
11
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
12
|
+
var BillingStatusCategoryEnumForUI;
|
|
13
|
+
(function (BillingStatusCategoryEnumForUI) {
|
|
14
|
+
BillingStatusCategoryEnumForUI["INTERNAL_REVIEW_STATUS"] = "INTERNAL_REVIEW_STATUS";
|
|
15
|
+
BillingStatusCategoryEnumForUI["CLIENT_REVIEW_STATUS"] = "CLIENT_REVIEW_STATUS";
|
|
16
|
+
BillingStatusCategoryEnumForUI["PAYMENT_STATUS"] = "PAYMENT_STATUS";
|
|
17
|
+
})(BillingStatusCategoryEnumForUI || (exports.BillingStatusCategoryEnumForUI = BillingStatusCategoryEnumForUI = {}));
|
|
18
|
+
class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.id = 0;
|
|
22
|
+
this.startDate = "";
|
|
23
|
+
this.endDate = "";
|
|
24
|
+
this.projectId = 0;
|
|
25
|
+
this.totalAmount = 0;
|
|
26
|
+
this.totalMinutes = 0;
|
|
27
|
+
this.invoiceNumber = "";
|
|
28
|
+
this.paymentStatus = payment_status_enum_1.PaymentStatusEnum.PENDING;
|
|
29
|
+
this.status = billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL;
|
|
30
|
+
this.writeoffAmount = 0;
|
|
31
|
+
this.totalAmountPaid = 0;
|
|
32
|
+
this.tdsAmount = 0;
|
|
33
|
+
this.creditNoteAmount = 0;
|
|
34
|
+
this.invoiceEntityId = 0;
|
|
35
|
+
this.invoiceEntityType = billing_invoice_type_enum_1.BillingInvoiceTypeEnum.CLIENT;
|
|
36
|
+
this.invoiceContactName = "";
|
|
37
|
+
this.bankId = 0;
|
|
38
|
+
this.particulars = "";
|
|
39
|
+
this.currency = enums_1.CurrencyEnum.INR;
|
|
40
|
+
this.createdBy = 0;
|
|
41
|
+
this.updatedBy = 0;
|
|
42
|
+
this.createdOn = "";
|
|
43
|
+
this.updatedOn = "";
|
|
44
|
+
this.type = billing_type_enum_1.BillingTypeEnum.INVOICE;
|
|
45
|
+
}
|
|
46
|
+
static fromApiEntity(apiEntity) {
|
|
47
|
+
const entity = new BillingEntityModel(entity_utils_interface_1.EntityEnum.BILLING);
|
|
48
|
+
Object.assign(entity, apiEntity);
|
|
49
|
+
return entity;
|
|
50
|
+
}
|
|
51
|
+
getStatusCategory() {
|
|
52
|
+
return this.mapStatusCategory(this.status);
|
|
53
|
+
}
|
|
54
|
+
getStatusLabel() {
|
|
55
|
+
return this.mapStatusLabel(this.status);
|
|
56
|
+
}
|
|
57
|
+
getTotalAmountInINR() {
|
|
58
|
+
return Number(this.conversionRate) > 0
|
|
59
|
+
? Number(this.totalAmount) * Number(this.conversionRate)
|
|
60
|
+
: Number(this.totalAmount);
|
|
61
|
+
}
|
|
62
|
+
getDateRange() {
|
|
63
|
+
return `${this.formatDate(this.startDate)} - ${this.formatDate(this.endDate, true)}`;
|
|
64
|
+
}
|
|
65
|
+
getBillDate() {
|
|
66
|
+
return new Date(this.createdOn);
|
|
67
|
+
}
|
|
68
|
+
mapOverdue(configValue) {
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
let overdue = false;
|
|
71
|
+
if (configValue !== undefined &&
|
|
72
|
+
this.mapStatusCategory(this.status) ===
|
|
73
|
+
BillingStatusCategoryEnumForUI.PAYMENT_STATUS &&
|
|
74
|
+
this.status !== billing_status_enum_1.BillingStatusEnum.SETTLED) {
|
|
75
|
+
const overdueDays = (_d = (_b = (_a = this.project) === null || _a === void 0 ? void 0 : _a.billingOverdueDays) !== null && _b !== void 0 ? _b : (_c = this.client) === null || _c === void 0 ? void 0 : _c.billingOverdueDays) !== null && _d !== void 0 ? _d : Number(configValue);
|
|
76
|
+
const dueDate = new Date(this.createdOn);
|
|
77
|
+
dueDate.setDate(dueDate.getDate() + overdueDays);
|
|
78
|
+
overdue = dueDate < new Date();
|
|
79
|
+
}
|
|
80
|
+
this.billOverdue = overdue;
|
|
81
|
+
}
|
|
82
|
+
mapStatusCategory(status) {
|
|
83
|
+
// Define mapping sets
|
|
84
|
+
const categories = {
|
|
85
|
+
[BillingStatusCategoryEnumForUI.INTERNAL_REVIEW_STATUS]: [
|
|
86
|
+
billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
87
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL,
|
|
88
|
+
billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
89
|
+
billing_status_enum_1.BillingStatusEnum.CANCELLED,
|
|
90
|
+
],
|
|
91
|
+
[BillingStatusCategoryEnumForUI.CLIENT_REVIEW_STATUS]: [
|
|
92
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
|
|
93
|
+
billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
94
|
+
billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
|
|
95
|
+
],
|
|
96
|
+
[BillingStatusCategoryEnumForUI.PAYMENT_STATUS]: [
|
|
97
|
+
billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
|
|
98
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT,
|
|
99
|
+
billing_status_enum_1.BillingStatusEnum.SETTLED,
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
// Validation: check if any status exists in more than one category
|
|
103
|
+
const statusMap = new Map();
|
|
104
|
+
for (const [category, statuses] of Object.entries(categories)) {
|
|
105
|
+
for (const s of statuses) {
|
|
106
|
+
const existing = statusMap.get(s) || [];
|
|
107
|
+
existing.push(category);
|
|
108
|
+
statusMap.set(s, existing);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (const [s, cats] of statusMap) {
|
|
112
|
+
if (cats.length > 1) {
|
|
113
|
+
console.error(`Duplicate mapping: ${s} exists in categories ${cats.join(", ")}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Now do actual mapping
|
|
117
|
+
for (const [category, statuses] of Object.entries(categories)) {
|
|
118
|
+
if (statuses.includes(status)) {
|
|
119
|
+
return category;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
throw new Error(`Unhandled Billing Status: ${status}`);
|
|
123
|
+
}
|
|
124
|
+
mapStatusLabel(status) {
|
|
125
|
+
switch (status) {
|
|
126
|
+
case billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL:
|
|
127
|
+
return "Pending Internal Approval";
|
|
128
|
+
case billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES:
|
|
129
|
+
return "Requested Changes";
|
|
130
|
+
case billing_status_enum_1.BillingStatusEnum.CANCELLED:
|
|
131
|
+
return "Cancelled";
|
|
132
|
+
case billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED:
|
|
133
|
+
return "Approved Internally";
|
|
134
|
+
case billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW:
|
|
135
|
+
return "Pending Client Review";
|
|
136
|
+
case billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL:
|
|
137
|
+
return "Client Approved Revision";
|
|
138
|
+
case billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION:
|
|
139
|
+
return "Client Rejected Revision";
|
|
140
|
+
case billing_status_enum_1.BillingStatusEnum.INVOICE_SENT:
|
|
141
|
+
return "Invoice Sent";
|
|
142
|
+
case billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT:
|
|
143
|
+
return "Pending Payment";
|
|
144
|
+
case billing_status_enum_1.BillingStatusEnum.SETTLED:
|
|
145
|
+
return "Settled";
|
|
146
|
+
default:
|
|
147
|
+
return status;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
formatDate(dateStr, includeYear = false) {
|
|
151
|
+
const year = dateStr.slice(0, 4);
|
|
152
|
+
const month = parseInt(dateStr.slice(4, 6), 10) - 1;
|
|
153
|
+
const day = dateStr.slice(6, 8);
|
|
154
|
+
return new Date(+year, month, +day).toLocaleDateString("en-IN", Object.assign({ day: "numeric", month: "short" }, (includeYear && { year: "numeric" })));
|
|
155
|
+
}
|
|
156
|
+
getAvailableAction(currentUserPermissions, billingConfigFlow, getUpdateActionVisibility) {
|
|
157
|
+
const currentBillingStatusActionConfig = billingConfigFlow[this.status];
|
|
158
|
+
if (currentBillingStatusActionConfig) {
|
|
159
|
+
const actionVisibilityConfig = getUpdateActionVisibility(this);
|
|
160
|
+
return Object.entries(currentBillingStatusActionConfig.actions)
|
|
161
|
+
.filter(([_, actionConfig]) => {
|
|
162
|
+
const actionPermissions = actionConfig.permissions.filter((item) => item != "BILLING_VIEW_PDF") || [];
|
|
163
|
+
const commonPermissions = actionPermissions.filter((actionPermission) => currentUserPermissions.includes(actionPermission));
|
|
164
|
+
if (commonPermissions.length === 0) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
if (commonPermissions.length > 1) {
|
|
168
|
+
throw new Error("Multiple permissions found for an action");
|
|
169
|
+
}
|
|
170
|
+
if (!actionVisibilityConfig[commonPermissions[0]]) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
return commonPermissions.some((permission) => actionVisibilityConfig[permission] &&
|
|
174
|
+
actionVisibilityConfig[permission]());
|
|
175
|
+
})
|
|
176
|
+
.map(([actionKey, actionConfig]) => actionKey);
|
|
177
|
+
}
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
getRelationConfigs() {
|
|
181
|
+
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.BillingEntityModel = BillingEntityModel;
|
|
185
|
+
BillingEntityModel.relationConfigs = [
|
|
186
|
+
{
|
|
187
|
+
name: entity_utils_interface_1.EntityEnum.PROJECT,
|
|
188
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
189
|
+
key: "project",
|
|
190
|
+
mapKeyConfig: {
|
|
191
|
+
relationKey: "id",
|
|
192
|
+
key: "projectId",
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: entity_utils_interface_1.EntityEnum.CLIENT,
|
|
197
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
198
|
+
key: "client",
|
|
199
|
+
mapKeyConfig: {
|
|
200
|
+
relationKey: "id",
|
|
201
|
+
key: "project.clientId",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: entity_utils_interface_1.EntityEnum.USER,
|
|
206
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
207
|
+
key: "updatedByUser",
|
|
208
|
+
mapKeyConfig: {
|
|
209
|
+
relationKey: "id",
|
|
210
|
+
key: "updatedBy",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE,
|
|
215
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
216
|
+
key: "reimbursementExpense",
|
|
217
|
+
mapKeyConfig: { relationKey: "projectId", key: "projectId" },
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE,
|
|
221
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
222
|
+
key: "billingIdReimbursementExpense",
|
|
223
|
+
mapKeyConfig: {
|
|
224
|
+
relationKey: "billingId",
|
|
225
|
+
key: "id",
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IClientApiEntity } from "../../api";
|
|
2
|
+
import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
|
|
3
|
+
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
4
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
5
|
+
import { ProjectEntityModel } from "./project.entity.model";
|
|
6
|
+
export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT> implements IClientApiEntity {
|
|
7
|
+
createdOn: string;
|
|
8
|
+
updatedOn: string;
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
primaryContactName: string;
|
|
13
|
+
primaryContact: string;
|
|
14
|
+
primaryEmail: string;
|
|
15
|
+
secondaryContactName?: string;
|
|
16
|
+
secondaryEmail?: string;
|
|
17
|
+
address?: string;
|
|
18
|
+
secondaryContact?: string;
|
|
19
|
+
country?: string;
|
|
20
|
+
industry?: string;
|
|
21
|
+
zipCode?: string;
|
|
22
|
+
organizationId: number;
|
|
23
|
+
reference?: string;
|
|
24
|
+
createdBy: number;
|
|
25
|
+
updatedBy: number;
|
|
26
|
+
projectIds?: number[];
|
|
27
|
+
billingOverdueDays: number;
|
|
28
|
+
projects: ProjectEntityModel[];
|
|
29
|
+
getRelationConfigs(): any;
|
|
30
|
+
static relationConfigs: RelationConfigs<[
|
|
31
|
+
EntityEnum.PROJECT
|
|
32
|
+
], EnumEntityType<EntityEnum.CLIENT>>;
|
|
33
|
+
static fromApiEntity(apiEntity: IClientApiEntity): ClientEntityModel;
|
|
34
|
+
populateProjectIds(projects: ProjectEntityModel[]): ClientEntityModel;
|
|
35
|
+
}
|