law-common 11.0.0 → 11.0.1-beta.1
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 +1 -1
- package/dist/src/entities/enums/billing-transaction-status.enum.d.ts +2 -1
- package/dist/src/entities/enums/billing-transaction-status.enum.js +1 -0
- package/dist/src/entities/enums/billing.transaction.enum.d.ts +2 -1
- package/dist/src/entities/enums/billing.transaction.enum.js +1 -0
- package/dist/src/entities/flow-configs/billing-transaction.flow.config.js +17 -0
- package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +2 -2
- package/dist/src/entities/model/base.entity.model.js +2 -2
- package/dist/src/entities/model/billing-transaction.model.d.ts +7 -2
- package/dist/src/entities/model/billing-transaction.model.js +21 -0
- package/dist/src/entities/model/billing.entity.model.d.ts +6 -0
- package/dist/src/entities/model/billing.entity.model.js +19 -0
- package/dist/src/entities/model/client.entity.model.d.ts +9 -0
- package/dist/src/entities/model/client.entity.model.js +46 -0
- package/dist/src/entities/model/project.entity.model.d.ts +7 -2
- package/dist/src/entities/model/project.entity.model.js +22 -0
- package/dist/src/index.js +7 -17
- package/dist/src/utils/helper.fn.util.d.ts +2 -2
- package/dist/src/utils/models/date-code.model.util.d.ts +4 -0
- package/dist/src/utils/models/date-code.model.util.js +9 -0
- package/package.json +42 -42
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# law-common
|
|
1
|
+
# law-common
|
|
@@ -2,5 +2,6 @@ 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"
|
|
5
|
+
CREDITNOTE_APPROVAL_PENDING = "creditnote_approval_pending",
|
|
6
|
+
ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING = "adjust_against_credit_note_approval_pending"
|
|
6
7
|
}
|
|
@@ -7,4 +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
|
+
BillingTransactionStatusEnum["ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING"] = "adjust_against_credit_note_approval_pending";
|
|
10
11
|
})(BillingTransactionStatusEnum || (exports.BillingTransactionStatusEnum = BillingTransactionStatusEnum = {}));
|
|
@@ -3,7 +3,8 @@ export declare enum BillingTransactionType {
|
|
|
3
3
|
WRITE_OFF = "WRITE_OFF",
|
|
4
4
|
CREDIT_NOTE = "CREDIT_NOTE",
|
|
5
5
|
RECEIPT = "RECEIPT",
|
|
6
|
-
REFUND = "REFUND"
|
|
6
|
+
REFUND = "REFUND",
|
|
7
|
+
ADJUST_AGAINST_CREDIT_NOTE = "ADJUST_AGAINST_CREDIT_NOTE"
|
|
7
8
|
}
|
|
8
9
|
export declare namespace BillingTransactionType {
|
|
9
10
|
function getNames(): string[];
|
|
@@ -10,6 +10,7 @@ var BillingTransactionType;
|
|
|
10
10
|
BillingTransactionType["CREDIT_NOTE"] = "CREDIT_NOTE";
|
|
11
11
|
BillingTransactionType["RECEIPT"] = "RECEIPT";
|
|
12
12
|
BillingTransactionType["REFUND"] = "REFUND";
|
|
13
|
+
BillingTransactionType["ADJUST_AGAINST_CREDIT_NOTE"] = "ADJUST_AGAINST_CREDIT_NOTE";
|
|
13
14
|
})(BillingTransactionType || (exports.BillingTransactionType = BillingTransactionType = {}));
|
|
14
15
|
(function (BillingTransactionType) {
|
|
15
16
|
function getNames() {
|
|
@@ -45,6 +45,22 @@ exports.billingTransactionFlowConfig = {
|
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
|
+
[billing_transaction_status_enum_1.BillingTransactionStatusEnum.ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING]: {
|
|
49
|
+
actions: {
|
|
50
|
+
[billing_transaction_action_enum_1.BillingTransactionActionEnum.APPROVE]: {
|
|
51
|
+
permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
|
|
52
|
+
next: () => billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED,
|
|
53
|
+
},
|
|
54
|
+
[billing_transaction_action_enum_1.BillingTransactionActionEnum.REJECT]: {
|
|
55
|
+
permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
|
|
56
|
+
next: () => billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED,
|
|
57
|
+
},
|
|
58
|
+
[billing_transaction_action_enum_1.BillingTransactionActionEnum.EDIT]: {
|
|
59
|
+
permissions: ["BILLING_TRANSACTION_UPDATE_SELF"],
|
|
60
|
+
next: (data) => decideNextStatus(data),
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
48
64
|
};
|
|
49
65
|
function decideNextStatus(data) {
|
|
50
66
|
var _a;
|
|
@@ -52,6 +68,7 @@ function decideNextStatus(data) {
|
|
|
52
68
|
const typeStatusMapping = {
|
|
53
69
|
[billing_transaction_enum_1.BillingTransactionType.WRITE_OFF]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
|
|
54
70
|
[billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
|
|
71
|
+
[billing_transaction_enum_1.BillingTransactionType.ADJUST_AGAINST_CREDIT_NOTE]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.ADJUST_AGAINST_CREDIT_NOTE_APPROVAL_PENDING,
|
|
55
72
|
};
|
|
56
73
|
if (currentBillingTransactionEntity.type === dto.type) {
|
|
57
74
|
return currentBillingTransactionEntity.status;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BillingTransactionStatusEnum } from "../enums/billing-transaction-status.enum";
|
|
2
2
|
import { BillingTransactionType } from "../enums/billing.transaction.enum";
|
|
3
3
|
import { IEntityAuditColumn } from "./entity-audit-columns.interface";
|
|
4
|
-
import { IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
+
import { IEntityFilterData, Nullable } from "./entity.utils.interface";
|
|
5
5
|
export interface IBillingTransactionEntity extends IEntityAuditColumn {
|
|
6
6
|
id: number;
|
|
7
7
|
billingId: number;
|
|
@@ -12,7 +12,7 @@ export interface IBillingTransactionEntity extends IEntityAuditColumn {
|
|
|
12
12
|
bankCharges?: number;
|
|
13
13
|
bankId?: number;
|
|
14
14
|
paymentDate?: string;
|
|
15
|
-
referenceNo?: string
|
|
15
|
+
referenceNo?: Nullable<string>;
|
|
16
16
|
supportingDocsUrls?: string;
|
|
17
17
|
status: BillingTransactionStatusEnum;
|
|
18
18
|
}
|
|
@@ -47,10 +47,10 @@ class BaseEntityModel {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
if (foundRelatedEntities.length > 1) {
|
|
50
|
-
throw new Error(`Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
|
|
50
|
+
throw new Error(`[populateRelationsByIndex]. Entity ${this.entityName} - Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
|
|
51
51
|
}
|
|
52
52
|
if (foundRelatedEntities.length === 0) {
|
|
53
|
-
console.warn(`No related entity found for ${relationConfig.name} with ${thisMappingKey}=${this[relationConfig.mapKeyConfig.foreignKey]}`);
|
|
53
|
+
console.warn(`[populateRelationsByIndex]. Entity ${this.entityName} - No related entity found for ${relationConfig.name} with ${thisMappingKey}=${this[relationConfig.mapKeyConfig.foreignKey]}`);
|
|
54
54
|
}
|
|
55
55
|
this[thisKey] = foundRelatedEntities[0];
|
|
56
56
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { CurrencyEnum } from "../../enums";
|
|
1
2
|
import { BillingTransactionStatusEnum } from "../enums/billing-transaction-status.enum";
|
|
2
3
|
import { BillingTransactionType } from "../enums/billing.transaction.enum";
|
|
3
4
|
import { IBillingTransactionEntity } from "../interface/billing_transaction.entity.interface";
|
|
4
|
-
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
5
|
+
import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
|
|
5
6
|
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
6
7
|
import { BankEntityModel } from "./bank.entity.model";
|
|
7
8
|
import { BaseEntityModel } from "./base.entity.model";
|
|
@@ -17,7 +18,7 @@ export declare class BillingTransactionEntityModel extends BaseEntityModel<Entit
|
|
|
17
18
|
bankCharges?: number;
|
|
18
19
|
bankId?: number;
|
|
19
20
|
paymentDate?: string;
|
|
20
|
-
referenceNo?: string
|
|
21
|
+
referenceNo?: Nullable<string>;
|
|
21
22
|
supportingDocsUrls?: string;
|
|
22
23
|
status: BillingTransactionStatusEnum;
|
|
23
24
|
createdOn: number;
|
|
@@ -32,4 +33,8 @@ export declare class BillingTransactionEntityModel extends BaseEntityModel<Entit
|
|
|
32
33
|
static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.USER, EntityEnum.BANK, EntityEnum.BILLING], EntityEnum.BILLING_TRANSACTION>;
|
|
33
34
|
static fromEntity(entity: IBillingTransactionEntity): BillingTransactionEntityModel;
|
|
34
35
|
static sumAmounts(transactions: BillingTransactionEntityModel[]): number;
|
|
36
|
+
get isForeignCurrencyTransaction(): boolean;
|
|
37
|
+
get transactionCurrency(): CurrencyEnum;
|
|
38
|
+
getFileName(): string;
|
|
39
|
+
get isBillingSettled(): boolean;
|
|
35
40
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BillingTransactionEntityModel = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const billing_transaction_status_enum_1 = require("../enums/billing-transaction-status.enum");
|
|
6
|
+
const billing_status_enum_1 = require("../enums/billing.status.enum");
|
|
6
7
|
const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
|
|
7
8
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
8
9
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
@@ -40,6 +41,26 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
|
|
|
40
41
|
});
|
|
41
42
|
}), "amount");
|
|
42
43
|
}
|
|
44
|
+
get isForeignCurrencyTransaction() {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
return (_b = (_a = this.billing) === null || _a === void 0 ? void 0 : _a.isForeignBilling) !== null && _b !== void 0 ? _b : false;
|
|
47
|
+
}
|
|
48
|
+
get transactionCurrency() {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return (_b = (_a = this.billing) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : "";
|
|
51
|
+
}
|
|
52
|
+
getFileName() {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f;
|
|
54
|
+
const { dateCode, timeCode } = utils_1.DateCodeModel.getCurrentISTDateTimeCode();
|
|
55
|
+
const invoiceNo = (_b = (_a = this.billing) === null || _a === void 0 ? void 0 : _a.invoiceNumber) !== null && _b !== void 0 ? _b : "";
|
|
56
|
+
const clientName = ((_d = (_c = this.billing) === null || _c === void 0 ? void 0 : _c.clientName) !== null && _d !== void 0 ? _d : "").replace(/ /g, "_");
|
|
57
|
+
const projectName = ((_f = (_e = this.billing) === null || _e === void 0 ? void 0 : _e.projectName) !== null && _f !== void 0 ? _f : "").replace(/ /g, "_");
|
|
58
|
+
return `${this.type}_${invoiceNo}_${clientName}_${projectName}_${dateCode}_${timeCode}`;
|
|
59
|
+
}
|
|
60
|
+
get isBillingSettled() {
|
|
61
|
+
var _a;
|
|
62
|
+
return ((_a = this.billing) === null || _a === void 0 ? void 0 : _a.status) === billing_status_enum_1.BillingStatusEnum.SETTLED;
|
|
63
|
+
}
|
|
43
64
|
}
|
|
44
65
|
exports.BillingTransactionEntityModel = BillingTransactionEntityModel;
|
|
45
66
|
BillingTransactionEntityModel.relationConfigs = [
|
|
@@ -8,6 +8,7 @@ import { BillingTypeEnum } from "../enums/billing-type.enum";
|
|
|
8
8
|
import { BillingActionsEnum } from "../enums/billing.action.enum";
|
|
9
9
|
import { BillingStatusEnum } from "../enums/billing.status.enum";
|
|
10
10
|
import { BillingInvoiceTypeEnum } from "../enums/billing_invoice_type.enum";
|
|
11
|
+
import { BillingProfileCode } from "../enums/billing_profile_code.enum";
|
|
11
12
|
import { BillingInvoiceNumberPrefixEnum } from "../enums/invoice-number-prefix.enum";
|
|
12
13
|
import { PaymentStatusEnum } from "../enums/payment_status.enum";
|
|
13
14
|
import { IBillingEntity } from "../interface/billing.entity.interface";
|
|
@@ -156,4 +157,9 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
156
157
|
get isForeignCurrencyProject(): boolean;
|
|
157
158
|
get isProformaInvoice(): boolean;
|
|
158
159
|
get title(): BillingTemplateTitle;
|
|
160
|
+
get billingProfileName(): string;
|
|
161
|
+
get billingProfileCode(): BillingProfileCode;
|
|
162
|
+
get poNumber(): Nullable<string>;
|
|
163
|
+
get creditNoteTransactions(): BillingTransactionEntityModel[] | undefined;
|
|
164
|
+
get adjustedCreditNoteTransactions(): BillingTransactionEntityModel[] | undefined;
|
|
159
165
|
}
|
|
@@ -12,6 +12,8 @@ const billing_type_enum_1 = require("../enums/billing-type.enum");
|
|
|
12
12
|
const billing_status_enum_1 = require("../enums/billing.status.enum");
|
|
13
13
|
const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
|
|
14
14
|
const billing_invoice_type_enum_1 = require("../enums/billing_invoice_type.enum");
|
|
15
|
+
const billing_profile_enum_1 = require("../enums/billing_profile.enum");
|
|
16
|
+
const billing_profile_code_enum_1 = require("../enums/billing_profile_code.enum");
|
|
15
17
|
const invoice_number_prefix_enum_1 = require("../enums/invoice-number-prefix.enum");
|
|
16
18
|
const payment_status_enum_1 = require("../enums/payment_status.enum");
|
|
17
19
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
@@ -451,6 +453,23 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
451
453
|
? constants_1.BillingTemplateTitle.DRAFT_INVOICE
|
|
452
454
|
: constants_1.BillingTemplateTitle.INVOICE;
|
|
453
455
|
}
|
|
456
|
+
get billingProfileName() {
|
|
457
|
+
return this.billingProfileParticulars.name;
|
|
458
|
+
}
|
|
459
|
+
get billingProfileCode() {
|
|
460
|
+
return this.billingProfileName === billing_profile_enum_1.BillingProfileName.AGRAM_LEGAL_CONSULTANTS ? billing_profile_code_enum_1.BillingProfileCode.ALC : billing_profile_code_enum_1.BillingProfileCode.ALP;
|
|
461
|
+
}
|
|
462
|
+
get poNumber() {
|
|
463
|
+
return this.billingProfileParticulars.poNumber;
|
|
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
|
+
}
|
|
454
473
|
}
|
|
455
474
|
exports.BillingEntityModel = BillingEntityModel;
|
|
456
475
|
BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES = ["invoice"];
|
|
@@ -71,4 +71,13 @@ export declare class ClientEntityModel extends BaseEntityModel<EntityEnum.CLIENT
|
|
|
71
71
|
* - Err with validation errors if any rule is violated
|
|
72
72
|
*/
|
|
73
73
|
static validateDocumentNoDocumentFile(data: DocumentFields<typeof ClientEntityModel.CLIENT_ENTITY_DOCUMENT_TYPES>, deleteDetails?: DeleteDocumentDetails<typeof ClientEntityModel.CLIENT_ENTITY_DOCUMENT_TYPES>): Result<void, IDtoValidationError[]>;
|
|
74
|
+
get gstNo(): string;
|
|
75
|
+
private get parsedAddress();
|
|
76
|
+
get addressLineOne(): string;
|
|
77
|
+
get addressLineTwo(): string;
|
|
78
|
+
get city(): string;
|
|
79
|
+
get state(): string;
|
|
80
|
+
get totalCreditNoteAmount(): number;
|
|
81
|
+
get totalCreditNoteAmountAdjusted(): number;
|
|
82
|
+
get totalCreditNoteAmountPendingForAdjustment(): number;
|
|
74
83
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClientEntityModel = void 0;
|
|
4
4
|
const code_util_1 = require("../../utils/code.util");
|
|
5
5
|
const document_validate_util_1 = require("../../utils/document-validate.util");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
6
7
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
7
8
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
8
9
|
const base_entity_model_1 = require("./base.entity.model");
|
|
@@ -74,6 +75,51 @@ class ClientEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
74
75
|
static validateDocumentNoDocumentFile(data, deleteDetails) {
|
|
75
76
|
return (0, document_validate_util_1.validateDocumentPairs)(ClientEntityModel.CLIENT_ENTITY_DOCUMENT_TYPES, data, deleteDetails);
|
|
76
77
|
}
|
|
78
|
+
get gstNo() {
|
|
79
|
+
var _a;
|
|
80
|
+
return (_a = this.gstNumber) !== null && _a !== void 0 ? _a : "";
|
|
81
|
+
}
|
|
82
|
+
get parsedAddress() {
|
|
83
|
+
if (!this.address)
|
|
84
|
+
return null;
|
|
85
|
+
try {
|
|
86
|
+
return JSON.parse(this.address);
|
|
87
|
+
}
|
|
88
|
+
catch (_a) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
get addressLineOne() {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
return (_b = (_a = this.parsedAddress) === null || _a === void 0 ? void 0 : _a.addressLine1) !== null && _b !== void 0 ? _b : "";
|
|
95
|
+
}
|
|
96
|
+
get addressLineTwo() {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
return (_b = (_a = this.parsedAddress) === null || _a === void 0 ? void 0 : _a.addressLine2) !== null && _b !== void 0 ? _b : "";
|
|
99
|
+
}
|
|
100
|
+
get city() {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
return (_b = (_a = this.parsedAddress) === null || _a === void 0 ? void 0 : _a.city) !== null && _b !== void 0 ? _b : "";
|
|
103
|
+
}
|
|
104
|
+
get state() {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return (_b = (_a = this.parsedAddress) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : "";
|
|
107
|
+
}
|
|
108
|
+
get totalCreditNoteAmount() {
|
|
109
|
+
const creditNoteTransactions = this.projects
|
|
110
|
+
.flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; })
|
|
111
|
+
.flatMap((billing) => { var _a; return (_a = billing.creditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
|
|
112
|
+
return (0, utils_1.sumNormalised)(creditNoteTransactions, "amount");
|
|
113
|
+
}
|
|
114
|
+
get totalCreditNoteAmountAdjusted() {
|
|
115
|
+
const adjustedTransactions = this.projects
|
|
116
|
+
.flatMap((project) => { var _a; return (_a = project.settledBillings) !== null && _a !== void 0 ? _a : []; })
|
|
117
|
+
.flatMap((billing) => { var _a; return (_a = billing.adjustedCreditNoteTransactions) !== null && _a !== void 0 ? _a : []; });
|
|
118
|
+
return (0, utils_1.sumNormalised)(adjustedTransactions, "amount");
|
|
119
|
+
}
|
|
120
|
+
get totalCreditNoteAmountPendingForAdjustment() {
|
|
121
|
+
return this.totalCreditNoteAmount - this.totalCreditNoteAmountAdjusted;
|
|
122
|
+
}
|
|
77
123
|
}
|
|
78
124
|
exports.ClientEntityModel = ClientEntityModel;
|
|
79
125
|
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;
|
|
@@ -45,4 +47,7 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
|
|
|
45
47
|
isAdhocProject(): boolean;
|
|
46
48
|
get partnersOwnerUsersOfProject(): UserEntityModel[];
|
|
47
49
|
get clientName(): string;
|
|
50
|
+
get clientGSTNumber(): string;
|
|
51
|
+
get clientVendorCode(): string;
|
|
52
|
+
get settledBillings(): BillingEntityModel[] | undefined;
|
|
48
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);
|
|
@@ -112,6 +114,17 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
112
114
|
get clientName() {
|
|
113
115
|
return this.client.name;
|
|
114
116
|
}
|
|
117
|
+
get clientGSTNumber() {
|
|
118
|
+
return this.client.gstNo;
|
|
119
|
+
}
|
|
120
|
+
get clientVendorCode() {
|
|
121
|
+
var _a;
|
|
122
|
+
return (_a = this.client.vendorCode) !== null && _a !== void 0 ? _a : "";
|
|
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
|
+
}
|
|
115
128
|
}
|
|
116
129
|
exports.ProjectEntityModel = ProjectEntityModel;
|
|
117
130
|
ProjectEntityModel.relationConfigs = [
|
|
@@ -124,6 +137,15 @@ ProjectEntityModel.relationConfigs = [
|
|
|
124
137
|
key: "id",
|
|
125
138
|
},
|
|
126
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
|
+
},
|
|
127
149
|
{
|
|
128
150
|
name: entity_utils_interface_1.EntityEnum.CLIENT,
|
|
129
151
|
relation: relation_type_enum_1.RelationType.ONE,
|
package/dist/src/index.js
CHANGED
|
@@ -15,23 +15,13 @@ 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) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
})();
|
|
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
|
+
};
|
|
35
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
27
|
};
|
|
@@ -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
|
-
[
|
|
152
|
+
[x: string]: 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
|
-
[
|
|
157
|
+
[x: string]: any;
|
|
158
158
|
}>;
|
|
159
159
|
export declare function getPropertyFilterByPermissionFn<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
|
|
160
160
|
[key: string]: () => Promise<IEntityFilterData<T>>;
|
|
@@ -372,5 +372,14 @@ class DateCodeModel {
|
|
|
372
372
|
toStringFormat(dateFormat) {
|
|
373
373
|
return (0, date_fns_1.format)(this.getDate(), dateFormat);
|
|
374
374
|
}
|
|
375
|
+
static getCurrentISTDateTimeCode() {
|
|
376
|
+
const now = new Date();
|
|
377
|
+
const istOffsetMs = 5.5 * 60 * 60 * 1000;
|
|
378
|
+
const nowIST = new Date(now.getTime() + istOffsetMs);
|
|
379
|
+
return {
|
|
380
|
+
dateCode: (0, date_fns_1.format)(nowIST, "ddMMyyyy"),
|
|
381
|
+
timeCode: (0, date_fns_1.format)(nowIST, "HHmmss"),
|
|
382
|
+
};
|
|
383
|
+
}
|
|
375
384
|
}
|
|
376
385
|
exports.DateCodeModel = DateCodeModel;
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "law-common",
|
|
3
|
-
"version": "11.0.
|
|
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
|
-
"check-version": "npm view law-common versions --json | jq -r '.[-1]'"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [],
|
|
24
|
-
"author": "",
|
|
25
|
-
"license": "ISC",
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/jest": "^29.5.13",
|
|
28
|
-
"@types/lodash": "^4.17.21",
|
|
29
|
-
"@types/node": "^22.6.1",
|
|
30
|
-
"jest": "^29.7.0",
|
|
31
|
-
"prettier": "3.8.1",
|
|
32
|
-
"ts-jest": "^29.2.5",
|
|
33
|
-
"ts-node": "^10.9.2",
|
|
34
|
-
"typescript": "^5.6.2"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@types/express": "^5.0.0",
|
|
38
|
-
"@types/multer": "^1.4.12",
|
|
39
|
-
"date-fns": "^4.1.0",
|
|
40
|
-
"lodash": "4.17.21"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "law-common",
|
|
3
|
+
"version": "11.0.1-beta.1",
|
|
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
|
+
"check-version": "npm view law-common versions --json | jq -r '.[-1]'"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "ISC",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jest": "^29.5.13",
|
|
28
|
+
"@types/lodash": "^4.17.21",
|
|
29
|
+
"@types/node": "^22.6.1",
|
|
30
|
+
"jest": "^29.7.0",
|
|
31
|
+
"prettier": "3.8.1",
|
|
32
|
+
"ts-jest": "^29.2.5",
|
|
33
|
+
"ts-node": "^10.9.2",
|
|
34
|
+
"typescript": "^5.6.2"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@types/express": "^5.0.0",
|
|
38
|
+
"@types/multer": "^1.4.12",
|
|
39
|
+
"date-fns": "^4.1.0",
|
|
40
|
+
"lodash": "4.17.21"
|
|
41
|
+
}
|
|
42
|
+
}
|