law-common 11.0.1-beta.6 → 11.0.1-beta.8
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/entities/enums/billing-transaction-status.enum.d.ts +1 -2
- package/dist/src/entities/enums/billing-transaction-status.enum.js +1 -1
- package/dist/src/entities/enums/billing.action.enum.js +2 -0
- package/dist/src/entities/enums/billing.transaction.enum.d.ts +1 -2
- package/dist/src/entities/enums/billing.transaction.enum.js +1 -1
- package/dist/src/entities/flow-configs/billing-transaction.flow.config.js +17 -17
- package/dist/src/entities/interface/entity.utils.interface.d.ts +6 -0
- package/dist/src/entities/model/billing-transaction.model.d.ts +0 -4
- package/dist/src/entities/model/billing-transaction.model.js +17 -11
- package/dist/src/entities/model/billing.entity.model.d.ts +2 -1
- package/dist/src/entities/model/billing.entity.model.js +29 -10
- package/dist/src/entities/model/client.entity.model.d.ts +1 -10
- package/dist/src/entities/model/client.entity.model.js +22 -21
- package/dist/src/entities/model/project.entity.model.d.ts +0 -1
- package/dist/src/entities/model/project.entity.model.js +4 -5
- package/package.json +2 -2
|
@@ -2,6 +2,5 @@ export declare enum BillingTransactionStatusEnum {
|
|
|
2
2
|
APPROVED = "approved",
|
|
3
3
|
REJECTED = "rejected",
|
|
4
4
|
WRITEOFF_APPROVAL_PENDING = "writeoff_approval_pending",
|
|
5
|
-
CREDITNOTE_APPROVAL_PENDING = "creditnote_approval_pending"
|
|
6
|
-
ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING = "adjust_against_credit_note_approval_pending"
|
|
5
|
+
CREDITNOTE_APPROVAL_PENDING = "creditnote_approval_pending"
|
|
7
6
|
}
|
|
@@ -7,5 +7,5 @@ var BillingTransactionStatusEnum;
|
|
|
7
7
|
BillingTransactionStatusEnum["REJECTED"] = "rejected";
|
|
8
8
|
BillingTransactionStatusEnum["WRITEOFF_APPROVAL_PENDING"] = "writeoff_approval_pending";
|
|
9
9
|
BillingTransactionStatusEnum["CREDITNOTE_APPROVAL_PENDING"] = "creditnote_approval_pending";
|
|
10
|
-
|
|
10
|
+
// ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING = "adjust_against_credit_note_approval_pending",
|
|
11
11
|
})(BillingTransactionStatusEnum || (exports.BillingTransactionStatusEnum = BillingTransactionStatusEnum = {}));
|
|
@@ -19,6 +19,7 @@ var BillingActionsEnum;
|
|
|
19
19
|
BillingActionsEnum["WRITE_OFF"] = "writeOff";
|
|
20
20
|
BillingActionsEnum["TDS"] = "tds";
|
|
21
21
|
BillingActionsEnum["PDF_VIEW"] = "pdfView";
|
|
22
|
+
// ADJUST_AGAINST_CREDIT_NOTE = "adjustAgainstCreditNote",
|
|
22
23
|
// PDF_GENERATE = "pdfGenerate",
|
|
23
24
|
// PDF_DELETE = "pdfDelete",
|
|
24
25
|
})(BillingActionsEnum || (exports.BillingActionsEnum = BillingActionsEnum = {}));
|
|
@@ -40,6 +41,7 @@ var BillingActionsEnum;
|
|
|
40
41
|
// [BillingActionsEnum.PDF_DELETE]: "Pdf Delete",
|
|
41
42
|
// [BillingActionsEnum.PDF_GENERATE]: "Pdf Generate",
|
|
42
43
|
[BillingActionsEnum.PDF_VIEW]: "Pdf View",
|
|
44
|
+
// [BillingActionsEnum.ADJUST_AGAINST_CREDIT_NOTE]: "Adjust Against Credit Note",
|
|
43
45
|
};
|
|
44
46
|
function getLabel(action) {
|
|
45
47
|
if (!Object.values(BillingActionsEnum).includes(action)) {
|
|
@@ -3,8 +3,7 @@ export declare enum BillingTransactionType {
|
|
|
3
3
|
WRITE_OFF = "WRITE_OFF",
|
|
4
4
|
CREDIT_NOTE = "CREDIT_NOTE",
|
|
5
5
|
RECEIPT = "RECEIPT",
|
|
6
|
-
REFUND = "REFUND"
|
|
7
|
-
ADJUST_AGAINST_CREDIT_NOTE = "ADJUST_AGAINST_CREDIT_NOTE"
|
|
6
|
+
REFUND = "REFUND"
|
|
8
7
|
}
|
|
9
8
|
export declare namespace BillingTransactionType {
|
|
10
9
|
function getNames(): string[];
|
|
@@ -10,7 +10,7 @@ var BillingTransactionType;
|
|
|
10
10
|
BillingTransactionType["CREDIT_NOTE"] = "CREDIT_NOTE";
|
|
11
11
|
BillingTransactionType["RECEIPT"] = "RECEIPT";
|
|
12
12
|
BillingTransactionType["REFUND"] = "REFUND";
|
|
13
|
-
|
|
13
|
+
// ADJUST_AGAINST_CREDIT_NOTE = "ADJUST_AGAINST_CREDIT_NOTE",
|
|
14
14
|
})(BillingTransactionType || (exports.BillingTransactionType = BillingTransactionType = {}));
|
|
15
15
|
(function (BillingTransactionType) {
|
|
16
16
|
function getNames() {
|
|
@@ -45,22 +45,22 @@ exports.billingTransactionFlowConfig = {
|
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
|
-
[
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
48
|
+
// [BillingTransactionStatusEnum.ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING]: {
|
|
49
|
+
// actions: {
|
|
50
|
+
// [BillingTransactionActionEnum.APPROVE]: {
|
|
51
|
+
// permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
|
|
52
|
+
// next: () => BillingTransactionStatusEnum.APPROVED,
|
|
53
|
+
// },
|
|
54
|
+
// [BillingTransactionActionEnum.REJECT]: {
|
|
55
|
+
// permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
|
|
56
|
+
// next: () => BillingTransactionStatusEnum.REJECTED,
|
|
57
|
+
// },
|
|
58
|
+
// [BillingTransactionActionEnum.EDIT]: {
|
|
59
|
+
// permissions: ["BILLING_TRANSACTION_UPDATE_SELF"],
|
|
60
|
+
// next: (data: IBillingTransactionContextFlowData) => decideNextStatus(data),
|
|
61
|
+
// },
|
|
62
|
+
// },
|
|
63
|
+
// },
|
|
64
64
|
};
|
|
65
65
|
function decideNextStatus(data) {
|
|
66
66
|
var _a;
|
|
@@ -68,7 +68,7 @@ function decideNextStatus(data) {
|
|
|
68
68
|
const typeStatusMapping = {
|
|
69
69
|
[billing_transaction_enum_1.BillingTransactionType.WRITE_OFF]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
|
|
70
70
|
[billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
|
|
71
|
-
[
|
|
71
|
+
// [BillingTransactionType.ADJUST_AGAINST_CREDIT_NOTE]: BillingTransactionStatusEnum.ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING,
|
|
72
72
|
};
|
|
73
73
|
if (currentBillingTransactionEntity.type === dto.type) {
|
|
74
74
|
return currentBillingTransactionEntity.status;
|
|
@@ -309,6 +309,9 @@ export type IEntityFilterData<T extends EnumEntityType<EntityEnum | VirtualEntit
|
|
|
309
309
|
le?: {
|
|
310
310
|
[key in keyof T]?: T[key];
|
|
311
311
|
};
|
|
312
|
+
contains?: {
|
|
313
|
+
[key in keyof T]?: string[];
|
|
314
|
+
};
|
|
312
315
|
relations?: ISearchIncludeEntity<EntityEnum>[];
|
|
313
316
|
entities?: ISearchIncludeEntity<EntityEnum>[];
|
|
314
317
|
columnKeys?: (keyof T)[];
|
|
@@ -346,6 +349,9 @@ export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
|
|
|
346
349
|
lessThan?: {
|
|
347
350
|
[key in keyof EnumEntityType<EntityRelations[T]>]?: EnumEntityType<EntityRelations[T]>[key];
|
|
348
351
|
};
|
|
352
|
+
contains?: {
|
|
353
|
+
[key in keyof EnumEntityType<EntityRelations[T]>]?: string[];
|
|
354
|
+
};
|
|
349
355
|
virtualRelations?: ISearchIncludeEntity<EntityRelations[VirtualEntityEnum]>[];
|
|
350
356
|
orderBy?: Partial<Record<keyof EnumEntityType<T>, ColumnOrderBy>>;
|
|
351
357
|
limit?: number;
|
|
@@ -37,8 +37,4 @@ export declare class BillingTransactionEntityModel extends BaseEntityModel<Entit
|
|
|
37
37
|
get transactionCurrency(): CurrencyEnum;
|
|
38
38
|
getFileName(): string;
|
|
39
39
|
get isBillingSettled(): boolean;
|
|
40
|
-
static getUnsettledCreditNoteSummary(creditNotes: BillingTransactionEntityModel[], adjustedCreditNotes: BillingTransactionEntityModel[]): {
|
|
41
|
-
creditNote: BillingTransactionEntityModel;
|
|
42
|
-
amountPendingToBeSettled: number;
|
|
43
|
-
}[];
|
|
44
40
|
}
|
|
@@ -22,6 +22,23 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
|
|
|
22
22
|
this.updatedOn = 0;
|
|
23
23
|
this.createdBy = 0;
|
|
24
24
|
this.updatedBy = 0;
|
|
25
|
+
// static getUnsettledCreditNoteSummary(
|
|
26
|
+
// creditNotes: BillingTransactionEntityModel[],
|
|
27
|
+
// adjustedCreditNotes: BillingTransactionEntityModel[],
|
|
28
|
+
// ): { creditNote: BillingTransactionEntityModel; amountPendingToBeSettled: number }[] {
|
|
29
|
+
// return creditNotes.reduce(
|
|
30
|
+
// (acc, creditNote) => {
|
|
31
|
+
// const creditNoteAmount = getDecimalNumberFromString(creditNote.amount);
|
|
32
|
+
// const totalAdjusted = BillingTransactionEntityModel.sumAmounts(adjustedCreditNotes.filter((adj) => adj.referenceNo === creditNote.referenceNo));
|
|
33
|
+
// const amountPendingToBeSettled = creditNoteAmount - totalAdjusted;
|
|
34
|
+
// if (amountPendingToBeSettled > 0) {
|
|
35
|
+
// acc.push({ creditNote, amountPendingToBeSettled });
|
|
36
|
+
// }
|
|
37
|
+
// return acc;
|
|
38
|
+
// },
|
|
39
|
+
// [] as { creditNote: BillingTransactionEntityModel; amountPendingToBeSettled: number }[],
|
|
40
|
+
// );
|
|
41
|
+
// }
|
|
25
42
|
}
|
|
26
43
|
// billing?: BillingEntityModel;
|
|
27
44
|
// bank?: BankEntityModel;
|
|
@@ -61,17 +78,6 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
|
|
|
61
78
|
var _a;
|
|
62
79
|
return ((_a = this.billing) === null || _a === void 0 ? void 0 : _a.status) === billing_status_enum_1.BillingStatusEnum.SETTLED;
|
|
63
80
|
}
|
|
64
|
-
static getUnsettledCreditNoteSummary(creditNotes, adjustedCreditNotes) {
|
|
65
|
-
return creditNotes.reduce((acc, creditNote) => {
|
|
66
|
-
const creditNoteAmount = (0, utils_1.getDecimalNumberFromString)(creditNote.amount);
|
|
67
|
-
const totalAdjusted = BillingTransactionEntityModel.sumAmounts(adjustedCreditNotes.filter((adj) => adj.referenceNo === creditNote.referenceNo));
|
|
68
|
-
const amountPendingToBeSettled = creditNoteAmount - totalAdjusted;
|
|
69
|
-
if (amountPendingToBeSettled > 0) {
|
|
70
|
-
acc.push({ creditNote, amountPendingToBeSettled });
|
|
71
|
-
}
|
|
72
|
-
return acc;
|
|
73
|
-
}, []);
|
|
74
|
-
}
|
|
75
81
|
}
|
|
76
82
|
exports.BillingTransactionEntityModel = BillingTransactionEntityModel;
|
|
77
83
|
BillingTransactionEntityModel.relationConfigs = [
|
|
@@ -135,6 +135,8 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
135
135
|
invoiceDate: Date;
|
|
136
136
|
latestBilling?: IBillingEntity;
|
|
137
137
|
}): string;
|
|
138
|
+
static getBillingWithHighestInvoiceSequence(billings: IBillingEntity[]): IBillingEntity | undefined;
|
|
139
|
+
static getInvoiceSequence(invoiceNumber: Nullable<string>): number;
|
|
138
140
|
getBillingTimesheetUserIds(): number[];
|
|
139
141
|
getTimestamp(): string;
|
|
140
142
|
summarryFolderName(timestamp: string): string;
|
|
@@ -161,5 +163,4 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
161
163
|
get billingProfileCode(): BillingProfileCode;
|
|
162
164
|
get poNumber(): Nullable<string>;
|
|
163
165
|
get creditNoteTransactions(): BillingTransactionEntityModel[] | undefined;
|
|
164
|
-
get adjustedCreditNoteTransactions(): BillingTransactionEntityModel[] | undefined;
|
|
165
166
|
}
|
|
@@ -50,6 +50,9 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
50
50
|
this.createdOn = 0;
|
|
51
51
|
this.updatedOn = 0;
|
|
52
52
|
this.type = billing_type_enum_1.BillingTypeEnum.INVOICE;
|
|
53
|
+
// get adjustedCreditNoteTransactions() {
|
|
54
|
+
// return this.billingTransactions?.filter((transaction) => transaction.type === BillingTransactionType.ADJUST_AGAINST_CREDIT_NOTE);
|
|
55
|
+
// }
|
|
53
56
|
}
|
|
54
57
|
static validateDocumentNoDocumentFile(data, deleteDetails) {
|
|
55
58
|
return (0, utils_1.validateDocumentPairs)(BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES, data, deleteDetails);
|
|
@@ -243,14 +246,17 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
243
246
|
}
|
|
244
247
|
getTotalAmountRecieved() {
|
|
245
248
|
var _a, _b, _c, _d;
|
|
246
|
-
const amountRecieved = (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.TDS, billing_transaction_enum_1.BillingTransactionType.RECEIPT,
|
|
249
|
+
const amountRecieved = (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.TDS, billing_transaction_enum_1.BillingTransactionType.RECEIPT, /* BillingTransactionType.ADJUST_AGAINST_CREDIT_NOTE */].includes(transaction.type) &&
|
|
250
|
+
transaction.status !== billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED)) !== null && _b !== void 0 ? _b : [], "amount") -
|
|
251
|
+
(0, utils_1.sumNormalised)((_d = (_c = this.billingTransactions) === null || _c === void 0 ? void 0 : _c.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.REFUND && transaction.status !== billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED)) !== null && _d !== void 0 ? _d : [], "amount");
|
|
247
252
|
return amountRecieved;
|
|
248
253
|
}
|
|
249
254
|
getTotalRecievableAmount() {
|
|
250
255
|
var _a, _b;
|
|
251
256
|
return ((0, utils_1.getDecimalNumberFromString)(this.totalAmount) -
|
|
252
257
|
(this.getTotalAmountRecieved() +
|
|
253
|
-
(0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE, billing_transaction_enum_1.BillingTransactionType.WRITE_OFF].includes(transaction.type)
|
|
258
|
+
(0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE, billing_transaction_enum_1.BillingTransactionType.WRITE_OFF].includes(transaction.type) &&
|
|
259
|
+
transaction.status !== billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED)) !== null && _b !== void 0 ? _b : [], "amount")));
|
|
254
260
|
}
|
|
255
261
|
validateAdvanceBillingId(adjustedBillingTransactions) {
|
|
256
262
|
const index = adjustedBillingTransactions.findIndex((item) => item.advanceBillingId === null);
|
|
@@ -262,12 +268,12 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
262
268
|
}
|
|
263
269
|
}
|
|
264
270
|
getApprovedBillingTransactionsTotalAmount() {
|
|
265
|
-
var _a, _b;
|
|
266
|
-
return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![
|
|
271
|
+
var _a, _b, _c;
|
|
272
|
+
return (0, utils_1.sumNormalised)((_c = (_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![
|
|
267
273
|
billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
|
|
268
274
|
billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
|
|
269
|
-
|
|
270
|
-
].includes(entity.status))) !== null &&
|
|
275
|
+
// BillingTransactionStatusEnum.ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING,
|
|
276
|
+
].includes(entity.status))) === null || _b === void 0 ? void 0 : _b.filter((transaction) => transaction.status === billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED)) !== null && _c !== void 0 ? _c : [], "amount");
|
|
271
277
|
}
|
|
272
278
|
getCurrentBillingBillingProfile(billingProfiles) {
|
|
273
279
|
const billingParticularsOfCurrentBilling = this.billingProfileParticulars;
|
|
@@ -375,6 +381,23 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
375
381
|
}
|
|
376
382
|
return `${prefix}${String(nextSeq).padStart(4, "0")}`;
|
|
377
383
|
}
|
|
384
|
+
static getBillingWithHighestInvoiceSequence(billings) {
|
|
385
|
+
if (!billings.length) {
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
return billings.reduce((highest, current) => {
|
|
389
|
+
const highestSequence = this.getInvoiceSequence(highest.invoiceNumber);
|
|
390
|
+
const currentSequence = this.getInvoiceSequence(current.invoiceNumber);
|
|
391
|
+
return currentSequence > highestSequence ? current : highest;
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
static getInvoiceSequence(invoiceNumber) {
|
|
395
|
+
var _a;
|
|
396
|
+
if (!invoiceNumber) {
|
|
397
|
+
return 0;
|
|
398
|
+
}
|
|
399
|
+
return Number((_a = invoiceNumber.split("-").pop()) !== null && _a !== void 0 ? _a : 0);
|
|
400
|
+
}
|
|
378
401
|
getBillingTimesheetUserIds() {
|
|
379
402
|
var _a, _b;
|
|
380
403
|
return (_b = (_a = this.billingTimesheets) === null || _a === void 0 ? void 0 : _a.map((timesheet) => timesheet.userId)) !== null && _b !== void 0 ? _b : [];
|
|
@@ -470,10 +493,6 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
470
493
|
var _a;
|
|
471
494
|
return (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE);
|
|
472
495
|
}
|
|
473
|
-
get adjustedCreditNoteTransactions() {
|
|
474
|
-
var _a;
|
|
475
|
-
return (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.ADJUST_AGAINST_CREDIT_NOTE);
|
|
476
|
-
}
|
|
477
496
|
}
|
|
478
497
|
exports.BillingEntityModel = BillingEntityModel;
|
|
479
498
|
BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES = ["invoice"];
|
|
@@ -4,7 +4,6 @@ import { IClientEntity } from "../interface/client.entity.interface";
|
|
|
4
4
|
import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
|
|
5
5
|
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
6
6
|
import { BaseEntityModel } from "./base.entity.model";
|
|
7
|
-
import { BillingTransactionEntityModel } from "./billing-transaction.model";
|
|
8
7
|
import { ClientAffiliateEntityModel } from "./client-affiliate.entity.model";
|
|
9
8
|
import { ProjectEntityModel } from "./project.entity.model";
|
|
10
9
|
export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT> implements IClientEntity {
|
|
@@ -79,13 +78,5 @@ export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT
|
|
|
79
78
|
get city(): string;
|
|
80
79
|
get state(): string;
|
|
81
80
|
getBillingsFromProfileCode(billingProfileCode?: string): import("./billing.entity.model").BillingEntityModel[];
|
|
82
|
-
getCreditNoteTransactions(billingProfileCode?: string): BillingTransactionEntityModel[];
|
|
83
|
-
getAdjustedCreditNoteTransactions(billingProfileCode?: string): BillingTransactionEntityModel[];
|
|
84
|
-
get totalCreditNoteAmount(): number;
|
|
85
|
-
get totalCreditNoteAmountAdjusted(): number;
|
|
86
|
-
get totalCreditNoteAmountPendingForAdjustment(): number;
|
|
87
|
-
getUnsettledCreditNoteSummary(billingProfileCode?: string): {
|
|
88
|
-
creditNote: BillingTransactionEntityModel;
|
|
89
|
-
amountPendingToBeSettled: number;
|
|
90
|
-
}[];
|
|
81
|
+
getCreditNoteTransactions(billingProfileCode?: string): import("./billing-transaction.model").BillingTransactionEntityModel[];
|
|
91
82
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClientEntityModel = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
4
|
const code_util_1 = require("../../utils/code.util");
|
|
6
5
|
const document_validate_util_1 = require("../../utils/document-validate.util");
|
|
7
6
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
8
7
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
9
8
|
const base_entity_model_1 = require("./base.entity.model");
|
|
10
|
-
const billing_transaction_model_1 = require("./billing-transaction.model");
|
|
11
9
|
class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
12
10
|
constructor() {
|
|
13
11
|
super(...arguments);
|
|
@@ -26,6 +24,28 @@ class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
26
24
|
this.secondaryContact = null;
|
|
27
25
|
this.projects = [];
|
|
28
26
|
this.clientAffiliates = [];
|
|
27
|
+
// getAdjustedCreditNoteTransactions(billingProfileCode?: string) {
|
|
28
|
+
// return this.getBillingsFromProfileCode(billingProfileCode).flatMap((billing) => billing.adjustedCreditNoteTransactions ?? []);
|
|
29
|
+
// }
|
|
30
|
+
// get totalCreditNoteAmount(): number {
|
|
31
|
+
// const creditNoteTransactions = this.projects.flatMap((project) => project.settledBillings ?? []).flatMap((billing) => billing.creditNoteTransactions ?? []);
|
|
32
|
+
// return sumNormalised(creditNoteTransactions, "amount");
|
|
33
|
+
// }
|
|
34
|
+
// get totalCreditNoteAmountAdjusted(): number {
|
|
35
|
+
// const adjustedTransactions = this.projects
|
|
36
|
+
// .flatMap((project) => project.settledBillings ?? [])
|
|
37
|
+
// .flatMap((billing) => billing.adjustedCreditNoteTransactions ?? []);
|
|
38
|
+
// return sumNormalised(adjustedTransactions, "amount");
|
|
39
|
+
// }
|
|
40
|
+
// get totalCreditNoteAmountPendingForAdjustment(): number {
|
|
41
|
+
// return this.totalCreditNoteAmount - this.totalCreditNoteAmountAdjusted;
|
|
42
|
+
// }
|
|
43
|
+
// getUnsettledCreditNoteSummary(billingProfileCode?: string) {
|
|
44
|
+
// return BillingTransactionEntityModel.getUnsettledCreditNoteSummary(
|
|
45
|
+
// this.getCreditNoteTransactions(billingProfileCode),
|
|
46
|
+
// this.getAdjustedCreditNoteTransactions(billingProfileCode),
|
|
47
|
+
// );
|
|
48
|
+
// }
|
|
29
49
|
}
|
|
30
50
|
getRelationConfigs() {
|
|
31
51
|
return this.constructor.prototype.constructor.relationConfigs;
|
|
@@ -114,25 +134,6 @@ class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
114
134
|
getCreditNoteTransactions(billingProfileCode) {
|
|
115
135
|
return this.getBillingsFromProfileCode(billingProfileCode).flatMap((billing) => { var _a; return (_a = billing.creditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
|
|
116
136
|
}
|
|
117
|
-
getAdjustedCreditNoteTransactions(billingProfileCode) {
|
|
118
|
-
return this.getBillingsFromProfileCode(billingProfileCode).flatMap((billing) => { var _a; return (_a = billing.adjustedCreditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
|
|
119
|
-
}
|
|
120
|
-
get totalCreditNoteAmount() {
|
|
121
|
-
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 : []; });
|
|
122
|
-
return (0, utils_1.sumNormalised)(creditNoteTransactions, "amount");
|
|
123
|
-
}
|
|
124
|
-
get totalCreditNoteAmountAdjusted() {
|
|
125
|
-
const adjustedTransactions = this.projects
|
|
126
|
-
.flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; })
|
|
127
|
-
.flatMap((billing) => { var _a; return (_a = billing.adjustedCreditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
|
|
128
|
-
return (0, utils_1.sumNormalised)(adjustedTransactions, "amount");
|
|
129
|
-
}
|
|
130
|
-
get totalCreditNoteAmountPendingForAdjustment() {
|
|
131
|
-
return this.totalCreditNoteAmount - this.totalCreditNoteAmountAdjusted;
|
|
132
|
-
}
|
|
133
|
-
getUnsettledCreditNoteSummary(billingProfileCode) {
|
|
134
|
-
return billing_transaction_model_1.BillingTransactionEntityModel.getUnsettledCreditNoteSummary(this.getCreditNoteTransactions(billingProfileCode), this.getAdjustedCreditNoteTransactions(billingProfileCode));
|
|
135
|
-
}
|
|
136
137
|
}
|
|
137
138
|
exports.ClientEntityModel = ClientEntityModel;
|
|
138
139
|
ClientEntityModel.CLIENT_ENTITY_DOCUMENT_TYPES = ["pan", "tan", "gst"];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectEntityModel = void 0;
|
|
4
4
|
const enums_1 = require("../../enums");
|
|
5
|
-
|
|
5
|
+
// import { BillingStatusEnum } from "../enums/billing.status.enum";
|
|
6
6
|
const project_revenue_split_enum_1 = require("../enums/project-revenue-split.enum");
|
|
7
7
|
const project_entity_enum_1 = require("../enums/project.entity.enum");
|
|
8
8
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
@@ -31,6 +31,9 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
31
31
|
this.users = [];
|
|
32
32
|
this.client = {};
|
|
33
33
|
this.billings = [];
|
|
34
|
+
// get settledBillings() {
|
|
35
|
+
// return this.billings?.filter((billing) => billing.status === BillingStatusEnum.SETTLED);
|
|
36
|
+
// }
|
|
34
37
|
}
|
|
35
38
|
static fromEntity(entity) {
|
|
36
39
|
const result = new ProjectEntityModel(entity_utils_interface_1.EntityEnum.PROJECT);
|
|
@@ -121,10 +124,6 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
121
124
|
var _a;
|
|
122
125
|
return (_a = this.client.vendorCode) !== null && _a !== void 0 ? _a : "";
|
|
123
126
|
}
|
|
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
|
-
}
|
|
128
127
|
}
|
|
129
128
|
exports.ProjectEntityModel = ProjectEntityModel;
|
|
130
129
|
ProjectEntityModel.relationConfigs = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "law-common",
|
|
3
|
-
"version": "11.0.1-beta.
|
|
3
|
+
"version": "11.0.1-beta.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"clean": "rm -rf dist",
|
|
11
11
|
"build": "npm run clean && tsc",
|
|
12
|
-
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta
|
|
12
|
+
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
|
|
13
13
|
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
14
|
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
15
|
"publish:major": "npm version major && git push && npm run build && npm publish",
|