law-common 10.72.10 → 10.72.14-beta.0
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/api/interface/billing.entity.response.d.ts +1 -4
- package/dist/src/constants/billing_constants.d.ts +7 -0
- package/dist/src/constants/billing_constants.js +16 -1
- package/dist/src/entities/model/billing.entity.model.d.ts +10 -1
- package/dist/src/entities/model/billing.entity.model.js +41 -2
- package/dist/src/entities/model/project.entity.model.d.ts +1 -0
- package/dist/src/entities/model/project.entity.model.js +3 -0
- package/dist/src/utils/string.util.d.ts +4 -3
- package/dist/src/utils/string.util.js +9 -8
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# law-common
|
|
1
|
+
# law-common
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BillingActionsEnum,
|
|
1
|
+
import { BillingActionsEnum, BillingStatusEnum, EntityModelRelationHelper, IBillingEntity, IBillingReimbursementExpenseEntity, IBillingTimesheetEntity, IProjectEntity, IUserEntity } from "../../entities";
|
|
2
2
|
import { IUpdateBillingDto } from "./billing.update.dto.interface";
|
|
3
3
|
export type IBillingEntityResponse = {
|
|
4
4
|
billing: IBillingEntity;
|
|
@@ -33,8 +33,5 @@ export type IBillingFlowContextData = {
|
|
|
33
33
|
};
|
|
34
34
|
export interface IBillingExportContext {
|
|
35
35
|
currentUser: IUserEntity;
|
|
36
|
-
billingEntity: BillingEntityModel;
|
|
37
36
|
billingEntityModelRelationHelper: EntityModelRelationHelper;
|
|
38
|
-
billingProfileEntity: IBillingProfileEntity[];
|
|
39
|
-
designationEntites: IDesignationEntity[];
|
|
40
37
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { BillingStatusEnum } from "../entities";
|
|
1
2
|
export declare const billingPrefixCompanyName = "ALC";
|
|
2
3
|
export declare const billingSequenceSeperator = "-";
|
|
3
4
|
export declare const billingSequenceSeperatorForCurrentFy = "/";
|
|
4
5
|
export declare const currentFY = "2526";
|
|
5
6
|
export declare const PROHIBITED_CHARS = "\\ / : * ? \" < > | . , ; = # % & { } $ ! ' @ ` ~ ^ [ ] ( ) +";
|
|
7
|
+
export declare enum BillingTemplateTitle {
|
|
8
|
+
PROFORMA_INVOICE = "PROFORMA INVOICE",
|
|
9
|
+
INVOICE = "INVOICE",
|
|
10
|
+
DRAFT_INVOICE = "DRAFT INVOICE"
|
|
11
|
+
}
|
|
12
|
+
export declare const proFormaInvoiceStatuses: BillingStatusEnum[];
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROHIBITED_CHARS = exports.currentFY = exports.billingSequenceSeperatorForCurrentFy = exports.billingSequenceSeperator = exports.billingPrefixCompanyName = void 0;
|
|
3
|
+
exports.proFormaInvoiceStatuses = exports.BillingTemplateTitle = exports.PROHIBITED_CHARS = exports.currentFY = exports.billingSequenceSeperatorForCurrentFy = exports.billingSequenceSeperator = exports.billingPrefixCompanyName = void 0;
|
|
4
|
+
const entities_1 = require("../entities");
|
|
4
5
|
exports.billingPrefixCompanyName = "ALC";
|
|
5
6
|
exports.billingSequenceSeperator = "-";
|
|
6
7
|
exports.billingSequenceSeperatorForCurrentFy = "/";
|
|
7
8
|
exports.currentFY = "2526";
|
|
8
9
|
exports.PROHIBITED_CHARS = `\\ / : * ? " < > | . , ; = # % & { } $ ! ' @ \` ~ ^ [ ] ( ) +`;
|
|
10
|
+
var BillingTemplateTitle;
|
|
11
|
+
(function (BillingTemplateTitle) {
|
|
12
|
+
BillingTemplateTitle["PROFORMA_INVOICE"] = "PROFORMA INVOICE";
|
|
13
|
+
BillingTemplateTitle["INVOICE"] = "INVOICE";
|
|
14
|
+
BillingTemplateTitle["DRAFT_INVOICE"] = "DRAFT INVOICE";
|
|
15
|
+
})(BillingTemplateTitle || (exports.BillingTemplateTitle = BillingTemplateTitle = {}));
|
|
16
|
+
exports.proFormaInvoiceStatuses = [
|
|
17
|
+
entities_1.BillingStatusEnum.PENDING_APPROVAL,
|
|
18
|
+
entities_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
19
|
+
entities_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
20
|
+
entities_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
|
|
21
|
+
entities_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
22
|
+
entities_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
|
|
23
|
+
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IBillingFlowConfig } from "../../api";
|
|
1
|
+
import { IBillingFlowConfig, IBillingParticulars } from "../../api";
|
|
2
|
+
import { BillingTemplateTitle } from "../../constants";
|
|
2
3
|
import { CurrencyEnum } from "../../enums";
|
|
3
4
|
import { IDtoValidationError, Result } from "../../misc";
|
|
4
5
|
import { DeleteDocumentDetails, DocumentFields } from "../../utils";
|
|
@@ -68,6 +69,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
68
69
|
isProjectComplete?: boolean;
|
|
69
70
|
static readonly BILLING_ENTITY_DOCUMENT_TYPES: readonly ["invoice"];
|
|
70
71
|
static validateDocumentNoDocumentFile(data: DocumentFields<typeof BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES>, deleteDetails?: DeleteDocumentDetails<typeof BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES>): Result<void, IDtoValidationError[]>;
|
|
72
|
+
get bankFromBillingBankId(): BankEntityModel | undefined;
|
|
71
73
|
get intermediaryBanks(): import("./intermediary-bank.entity.model").IntermediaryBankEntityModel[] | undefined;
|
|
72
74
|
get reimbursements(): ReimbursementEntityModel[];
|
|
73
75
|
static relationConfigs: RelationConfigs<[
|
|
@@ -109,6 +111,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
109
111
|
validateAdvanceBillingId(adjustedBillingTransactions: IBillingTransactionEntity[]): void;
|
|
110
112
|
getApprovedBillingTransactionsTotalAmount(): number;
|
|
111
113
|
getCurrentBillingBillingProfile(billingProfiles: BillingProfileEntityModel[]): BillingProfileEntityModel[];
|
|
114
|
+
get billingProfileParticulars(): IBillingParticulars;
|
|
112
115
|
static getLatestBillingEntityModel(billingEntityModels: BillingEntityModel[]): BillingEntityModel | void;
|
|
113
116
|
static getNextInvoiceNumber(params: {
|
|
114
117
|
type: BillingInvoiceNumberPrefixEnum;
|
|
@@ -147,4 +150,10 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
|
|
|
147
150
|
get projectName(): string;
|
|
148
151
|
getActiveBillingTransactions(): BillingTransactionEntityModel[] | undefined;
|
|
149
152
|
hasActiveTranansactions(): boolean | undefined;
|
|
153
|
+
isClientInvoice(): boolean;
|
|
154
|
+
get clientAffiliate(): import("./client-affiliate.entity.model").ClientAffiliateEntityModel | undefined;
|
|
155
|
+
get isForeignBilling(): boolean;
|
|
156
|
+
get isForeignCurrencyProject(): boolean;
|
|
157
|
+
get isProformaInvoice(): boolean;
|
|
158
|
+
get title(): BillingTemplateTitle;
|
|
150
159
|
}
|
|
@@ -52,6 +52,10 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
52
52
|
static validateDocumentNoDocumentFile(data, deleteDetails) {
|
|
53
53
|
return (0, utils_1.validateDocumentPairs)(BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES, data, deleteDetails);
|
|
54
54
|
}
|
|
55
|
+
get bankFromBillingBankId() {
|
|
56
|
+
var _a;
|
|
57
|
+
return (_a = this.bank) === null || _a === void 0 ? void 0 : _a.find((b) => b.id === this.bankId);
|
|
58
|
+
}
|
|
55
59
|
get intermediaryBanks() {
|
|
56
60
|
const thisBank = this.bank;
|
|
57
61
|
if (thisBank)
|
|
@@ -90,7 +94,10 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
90
94
|
this.mapStatusCategory(this.status) === billing_status_category_enum_1.BillingStatusCategoryEnum.PAYMENT_STATUS &&
|
|
91
95
|
this.status !== billing_status_enum_1.BillingStatusEnum.SETTLED) {
|
|
92
96
|
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);
|
|
93
|
-
const
|
|
97
|
+
const dueDateOld = new Date(this.createdOn);
|
|
98
|
+
console.log("Bill due date old: ", dueDateOld);
|
|
99
|
+
const dueDate = new Date(this.createdOn * 1000);
|
|
100
|
+
console.log("Bill Due Date:", dueDate);
|
|
94
101
|
dueDate.setDate(dueDate.getDate() + overdueDays);
|
|
95
102
|
overdue = dueDate < new Date();
|
|
96
103
|
}
|
|
@@ -260,9 +267,12 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
260
267
|
return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING, billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING].includes(entity.status))) !== null && _b !== void 0 ? _b : [], "amount");
|
|
261
268
|
}
|
|
262
269
|
getCurrentBillingBillingProfile(billingProfiles) {
|
|
263
|
-
const billingParticularsOfCurrentBilling =
|
|
270
|
+
const billingParticularsOfCurrentBilling = this.billingProfileParticulars;
|
|
264
271
|
return billingProfiles.filter((profile) => profile.name === billingParticularsOfCurrentBilling.name);
|
|
265
272
|
}
|
|
273
|
+
get billingProfileParticulars() {
|
|
274
|
+
return JSON.parse(this.particulars);
|
|
275
|
+
}
|
|
266
276
|
static getLatestBillingEntityModel(billingEntityModels) {
|
|
267
277
|
if (billingEntityModels.length === 0)
|
|
268
278
|
return;
|
|
@@ -415,6 +425,35 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
415
425
|
const billTransactions = this.getActiveBillingTransactions();
|
|
416
426
|
return billTransactions && billTransactions.length > 0;
|
|
417
427
|
}
|
|
428
|
+
isClientInvoice() {
|
|
429
|
+
return this.invoiceEntityType === billing_invoice_type_enum_1.BillingInvoiceTypeEnum.CLIENT;
|
|
430
|
+
}
|
|
431
|
+
get clientAffiliate() {
|
|
432
|
+
var _a, _b;
|
|
433
|
+
return (_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.clientAffiliates) === null || _b === void 0 ? void 0 : _b.find((affiliate) => affiliate.id === this.invoiceEntityId);
|
|
434
|
+
}
|
|
435
|
+
get isForeignBilling() {
|
|
436
|
+
var _a;
|
|
437
|
+
if (this.isClientInvoice()) {
|
|
438
|
+
return ((_a = this.client) === null || _a === void 0 ? void 0 : _a.country) !== undefined && this.client.country !== "India";
|
|
439
|
+
}
|
|
440
|
+
const affiliate = this.clientAffiliate;
|
|
441
|
+
return (affiliate === null || affiliate === void 0 ? void 0 : affiliate.country) !== undefined && affiliate.country !== "India";
|
|
442
|
+
}
|
|
443
|
+
get isForeignCurrencyProject() {
|
|
444
|
+
var _a, _b;
|
|
445
|
+
return (_b = (_a = this.project) === null || _a === void 0 ? void 0 : _a.isForeignCurrencyProjoect()) !== null && _b !== void 0 ? _b : false;
|
|
446
|
+
}
|
|
447
|
+
get isProformaInvoice() {
|
|
448
|
+
return this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE;
|
|
449
|
+
}
|
|
450
|
+
get title() {
|
|
451
|
+
return this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE
|
|
452
|
+
? constants_1.BillingTemplateTitle.PROFORMA_INVOICE
|
|
453
|
+
: constants_1.proFormaInvoiceStatuses.includes(this.status)
|
|
454
|
+
? constants_1.BillingTemplateTitle.DRAFT_INVOICE
|
|
455
|
+
: constants_1.BillingTemplateTitle.INVOICE;
|
|
456
|
+
}
|
|
418
457
|
}
|
|
419
458
|
exports.BillingEntityModel = BillingEntityModel;
|
|
420
459
|
BillingEntityModel.BILLING_ENTITY_DOCUMENT_TYPES = ["invoice"];
|
|
@@ -36,4 +36,5 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
|
|
|
36
36
|
static relationConfigs: RelationConfigs<[EntityEnum.PROJECT_USER_MAPPING, EntityEnum.CLIENT], EntityEnum.PROJECT>;
|
|
37
37
|
populateUsers(users: UserEntityModel[], projectUserMapping: ProjectUserMappingEntityModel[]): void;
|
|
38
38
|
getRelationConfigs(): [import("../interface/relation-config.interface").IRelationConfig<EntityEnum.PROJECT_USER_MAPPING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.CLIENT, EntityEnum.PROJECT>];
|
|
39
|
+
isForeignCurrencyProjoect(): boolean;
|
|
39
40
|
}
|
|
@@ -86,6 +86,9 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
86
86
|
getRelationConfigs() {
|
|
87
87
|
return ProjectEntityModel.relationConfigs;
|
|
88
88
|
}
|
|
89
|
+
isForeignCurrencyProjoect() {
|
|
90
|
+
return this.currency !== enums_1.CurrencyEnum.INR;
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
exports.ProjectEntityModel = ProjectEntityModel;
|
|
91
94
|
ProjectEntityModel.relationConfigs = [
|
|
@@ -3,9 +3,10 @@ export declare function formatString(input: string): string;
|
|
|
3
3
|
* Converts a string to Title Case.
|
|
4
4
|
*
|
|
5
5
|
* Examples:
|
|
6
|
-
* - "APPROVE"
|
|
7
|
-
* - "PENDING_REVIEW"
|
|
8
|
-
* - "in_progress"
|
|
6
|
+
* - "APPROVE" => "Approve"
|
|
7
|
+
* - "PENDING_REVIEW" => "Pending Review"
|
|
8
|
+
* - "in_progress" => "In Progress"
|
|
9
|
+
* - "DRAFT INVOICE" => "Draft Invoice"
|
|
9
10
|
*
|
|
10
11
|
* @param {string} input - The string to convert.
|
|
11
12
|
* @returns {string} - The string in Title Case.
|
|
@@ -20,9 +20,10 @@ function formatString(input) {
|
|
|
20
20
|
* Converts a string to Title Case.
|
|
21
21
|
*
|
|
22
22
|
* Examples:
|
|
23
|
-
* - "APPROVE"
|
|
24
|
-
* - "PENDING_REVIEW"
|
|
25
|
-
* - "in_progress"
|
|
23
|
+
* - "APPROVE" => "Approve"
|
|
24
|
+
* - "PENDING_REVIEW" => "Pending Review"
|
|
25
|
+
* - "in_progress" => "In Progress"
|
|
26
|
+
* - "DRAFT INVOICE" => "Draft Invoice"
|
|
26
27
|
*
|
|
27
28
|
* @param {string} input - The string to convert.
|
|
28
29
|
* @returns {string} - The string in Title Case.
|
|
@@ -30,11 +31,11 @@ function formatString(input) {
|
|
|
30
31
|
function toTitleCase(input) {
|
|
31
32
|
if (!input)
|
|
32
33
|
return "";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
return input
|
|
35
|
+
.replace(/[_-]+/g, " ")
|
|
36
|
+
.split(/\s+/) // split by one or more spaces
|
|
37
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
38
|
+
.join(" ");
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Converts a camelCase or PascalCase string into a human-readable
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "law-common",
|
|
3
|
-
"version": "10.72.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist/**/*"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "rm -rf dist",
|
|
11
|
-
"build": "npm run clean && tsc",
|
|
12
|
-
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
|
|
13
|
-
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
|
-
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
|
-
"publish:major": "npm version major && git push && npm run build && npm publish",
|
|
16
|
-
"link": "npm run build && npm link",
|
|
17
|
-
"test": "jest",
|
|
18
|
-
"format": "prettier --write .",
|
|
19
|
-
"check-format": "prettier --check .",
|
|
20
|
-
"pull:link": "git pull && npm run link"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [],
|
|
23
|
-
"author": "",
|
|
24
|
-
"license": "ISC",
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/jest": "^29.5.13",
|
|
27
|
-
"@types/lodash": "^4.17.21",
|
|
28
|
-
"@types/node": "^22.6.1",
|
|
29
|
-
"jest": "^29.7.0",
|
|
30
|
-
"prettier": "3.8.1",
|
|
31
|
-
"ts-jest": "^29.2.5",
|
|
32
|
-
"ts-node": "^10.9.2",
|
|
33
|
-
"typescript": "^5.6.2"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@types/express": "^5.0.0",
|
|
37
|
-
"@types/multer": "^1.4.12",
|
|
38
|
-
"date-fns": "^4.1.0",
|
|
39
|
-
"lodash": "4.17.21"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "law-common",
|
|
3
|
+
"version": "10.72.14-beta.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
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jest": "^29.5.13",
|
|
27
|
+
"@types/lodash": "^4.17.21",
|
|
28
|
+
"@types/node": "^22.6.1",
|
|
29
|
+
"jest": "^29.7.0",
|
|
30
|
+
"prettier": "3.8.1",
|
|
31
|
+
"ts-jest": "^29.2.5",
|
|
32
|
+
"ts-node": "^10.9.2",
|
|
33
|
+
"typescript": "^5.6.2"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@types/express": "^5.0.0",
|
|
37
|
+
"@types/multer": "^1.4.12",
|
|
38
|
+
"date-fns": "^4.1.0",
|
|
39
|
+
"lodash": "4.17.21"
|
|
40
|
+
}
|
|
41
|
+
}
|