law-common 11.0.1-beta.0 → 11.0.1-beta.2

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.
@@ -160,4 +160,6 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
160
160
  get billingProfileName(): string;
161
161
  get billingProfileCode(): BillingProfileCode;
162
162
  get poNumber(): Nullable<string>;
163
+ get creditNoteTransactions(): BillingTransactionEntityModel[] | undefined;
164
+ get adjustedCreditNoteTransactions(): BillingTransactionEntityModel[] | undefined;
163
165
  }
@@ -462,6 +462,14 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
462
462
  get poNumber() {
463
463
  return this.billingProfileParticulars.poNumber;
464
464
  }
465
+ get creditNoteTransactions() {
466
+ var _a;
467
+ return (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE);
468
+ }
469
+ get adjustedCreditNoteTransactions() {
470
+ var _a;
471
+ return (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.ADJUST_AGAINST_CREDIT_NOTE);
472
+ }
465
473
  }
466
474
  exports.BillingEntityModel = BillingEntityModel;
467
475
  BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES = ["invoice"];
@@ -77,4 +77,9 @@ export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT
77
77
  get addressLineTwo(): string;
78
78
  get city(): string;
79
79
  get state(): string;
80
+ get creditNoteTransactions(): import("./billing-transaction.model").BillingTransactionEntityModel[];
81
+ get adjustedCreditNoteTransactions(): import("./billing-transaction.model").BillingTransactionEntityModel[];
82
+ get totalCreditNoteAmount(): number;
83
+ get totalCreditNoteAmountAdjusted(): number;
84
+ get totalCreditNoteAmountPendingForAdjustment(): number;
80
85
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClientEntityModel = void 0;
4
+ const utils_1 = require("../../utils");
4
5
  const code_util_1 = require("../../utils/code.util");
5
6
  const document_validate_util_1 = require("../../utils/document-validate.util");
6
7
  const relation_type_enum_1 = require("../enums/relation-type.enum");
@@ -104,6 +105,25 @@ class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
104
105
  var _a, _b;
105
106
  return (_b = (_a = this.parsedAddress) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : "";
106
107
  }
108
+ get creditNoteTransactions() {
109
+ return this.projects.flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; }).flatMap((billing) => { var _a; return (_a = billing.creditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
110
+ }
111
+ get adjustedCreditNoteTransactions() {
112
+ return this.projects.flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; }).flatMap((billing) => { var _a; return (_a = billing.adjustedCreditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
113
+ }
114
+ get totalCreditNoteAmount() {
115
+ const creditNoteTransactions = this.projects.flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; }).flatMap((billing) => { var _a; return (_a = billing.creditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
116
+ return (0, utils_1.sumNormalised)(creditNoteTransactions, "amount");
117
+ }
118
+ get totalCreditNoteAmountAdjusted() {
119
+ const adjustedTransactions = this.projects
120
+ .flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; })
121
+ .flatMap((billing) => { var _a; return (_a = billing.adjustedCreditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
122
+ return (0, utils_1.sumNormalised)(adjustedTransactions, "amount");
123
+ }
124
+ get totalCreditNoteAmountPendingForAdjustment() {
125
+ return this.totalCreditNoteAmount - this.totalCreditNoteAmountAdjusted;
126
+ }
107
127
  }
108
128
  exports.ClientEntityModel = ClientEntityModel;
109
129
  ClientEntityModel.CLIENT_ENTITY_DOCUMENT_TYPES = ["pan", "tan", "gst"];
@@ -5,6 +5,7 @@ import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
5
5
  import { IProjectEntity, IProjectUserDto, UsageNotificationThresholdEnum } from "../interface/project.entity.interface";
6
6
  import { RelationConfigs } from "../interface/relation-config.interface";
7
7
  import { BaseEntityModel } from "./base.entity.model";
8
+ import { BillingEntityModel } from "./billing.entity.model";
8
9
  import { ClientEntityModel } from "./client.entity.model";
9
10
  import { ProjectUserMappingEntityModel } from "./project-user-mapping.entity.model";
10
11
  import { UserEntityModel } from "./user.entity.model";
@@ -34,10 +35,11 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
34
35
  userMappings?: (UserEntityModel & ProjectUserMappingEntityModel)[];
35
36
  projectUserMappings?: ProjectUserMappingEntityModel[];
36
37
  client: ClientEntityModel;
38
+ billings?: BillingEntityModel[];
37
39
  static fromEntity(entity: IProjectEntity): ProjectEntityModel;
38
- static relationConfigs: RelationConfigs<[EntityEnum.PROJECT_USER_MAPPING, EntityEnum.CLIENT], EntityEnum.PROJECT>;
40
+ static relationConfigs: RelationConfigs<[EntityEnum.PROJECT_USER_MAPPING, EntityEnum.BILLING, EntityEnum.CLIENT], EntityEnum.PROJECT>;
39
41
  populateUsers(users: UserEntityModel[], projectUserMapping: ProjectUserMappingEntityModel[]): void;
40
- getRelationConfigs(): [import("../interface/relation-config.interface").IRelationConfig<EntityEnum.PROJECT_USER_MAPPING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.CLIENT, EntityEnum.PROJECT>];
42
+ getRelationConfigs(): [import("../interface/relation-config.interface").IRelationConfig<EntityEnum.PROJECT_USER_MAPPING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.BILLING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.CLIENT, EntityEnum.PROJECT>];
41
43
  isForeignCurrencyProjoect(): boolean;
42
44
  get parsedBillingRate(): any;
43
45
  isHourlyProject(): boolean;
@@ -47,4 +49,5 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
47
49
  get clientName(): string;
48
50
  get clientGSTNumber(): string;
49
51
  get clientVendorCode(): string;
52
+ get settledBillings(): BillingEntityModel[] | undefined;
50
53
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectEntityModel = void 0;
4
4
  const enums_1 = require("../../enums");
5
+ const billing_status_enum_1 = require("../enums/billing.status.enum");
5
6
  const project_revenue_split_enum_1 = require("../enums/project-revenue-split.enum");
6
7
  const project_entity_enum_1 = require("../enums/project.entity.enum");
7
8
  const relation_type_enum_1 = require("../enums/relation-type.enum");
@@ -29,6 +30,7 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
29
30
  this.clientQuoteId = null;
30
31
  this.users = [];
31
32
  this.client = {};
33
+ this.billings = [];
32
34
  }
33
35
  static fromEntity(entity) {
34
36
  const result = new ProjectEntityModel(entity_utils_interface_1.EntityEnum.PROJECT);
@@ -119,6 +121,10 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
119
121
  var _a;
120
122
  return (_a = this.client.vendorCode) !== null && _a !== void 0 ? _a : "";
121
123
  }
124
+ get settledBillings() {
125
+ var _a;
126
+ return (_a = this.billings) === null || _a === void 0 ? void 0 : _a.filter((billing) => billing.status === billing_status_enum_1.BillingStatusEnum.SETTLED);
127
+ }
122
128
  }
123
129
  exports.ProjectEntityModel = ProjectEntityModel;
124
130
  ProjectEntityModel.relationConfigs = [
@@ -131,6 +137,15 @@ ProjectEntityModel.relationConfigs = [
131
137
  key: "id",
132
138
  },
133
139
  },
140
+ {
141
+ name: entity_utils_interface_1.EntityEnum.BILLING,
142
+ relation: relation_type_enum_1.RelationType.MANY,
143
+ key: "billings",
144
+ mapKeyConfig: {
145
+ relationKey: "projectId",
146
+ key: "id",
147
+ },
148
+ },
134
149
  {
135
150
  name: entity_utils_interface_1.EntityEnum.CLIENT,
136
151
  relation: relation_type_enum_1.RelationType.ONE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "11.0.1-beta.0",
3
+ "version": "11.0.1-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [