invoice-system-common 1.0.28-beta.0 → 1.0.30-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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/interfaces/billing-line-item.entity.interface.d.ts +1 -1
- package/dist/models/billing-line-item-model.d.ts +23 -0
- package/dist/models/billing-line-item-model.js +37 -0
- package/dist/models/billing.model.d.ts +32 -0
- package/dist/models/billing.model.js +46 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -36,3 +36,5 @@ export * from "./helpers/date.utils";
|
|
|
36
36
|
export * from "./helpers/generics";
|
|
37
37
|
export * from "./helpers/helper.function.utils";
|
|
38
38
|
export * from "./enums/entity-list.enum";
|
|
39
|
+
export * from "./models/billing-line-item-model";
|
|
40
|
+
export * from "./models/billing.model";
|
package/dist/index.js
CHANGED
|
@@ -52,3 +52,5 @@ __exportStar(require("./helpers/date.utils"), exports);
|
|
|
52
52
|
__exportStar(require("./helpers/generics"), exports);
|
|
53
53
|
__exportStar(require("./helpers/helper.function.utils"), exports);
|
|
54
54
|
__exportStar(require("./enums/entity-list.enum"), exports);
|
|
55
|
+
__exportStar(require("./models/billing-line-item-model"), exports);
|
|
56
|
+
__exportStar(require("./models/billing.model"), exports);
|
|
@@ -6,7 +6,7 @@ export interface IBillingLineItemEntity extends IAuditColumnEntity {
|
|
|
6
6
|
inventoryId: number;
|
|
7
7
|
description: string;
|
|
8
8
|
rateId?: number | null;
|
|
9
|
-
rateAmount
|
|
9
|
+
rateAmount: number;
|
|
10
10
|
quantity: number;
|
|
11
11
|
tenureValue: number;
|
|
12
12
|
normalizedTenureInDays: number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BillingLineItemStatusEnum } from "../enums/billing-line-item-status.enum";
|
|
2
|
+
import { IBillingLineItemEntity } from "../interfaces/billing-line-item.entity.interface";
|
|
3
|
+
export declare class BillingLineItemModel implements IBillingLineItemEntity {
|
|
4
|
+
id: number;
|
|
5
|
+
billId: number;
|
|
6
|
+
inventoryId: number;
|
|
7
|
+
rateId?: number;
|
|
8
|
+
rateAmount: number;
|
|
9
|
+
quantity: number;
|
|
10
|
+
tenureValue: number;
|
|
11
|
+
normalizedTenureInDays: number;
|
|
12
|
+
startDate: string;
|
|
13
|
+
endDate: string;
|
|
14
|
+
totalAmount: number;
|
|
15
|
+
description: string;
|
|
16
|
+
status: BillingLineItemStatusEnum;
|
|
17
|
+
createdOn: Date;
|
|
18
|
+
updatedOn: Date;
|
|
19
|
+
createdBy: number;
|
|
20
|
+
updatedBy: number;
|
|
21
|
+
constructor(data: IBillingLineItemEntity);
|
|
22
|
+
getLineItemTotalAmount(): number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingLineItemModel = void 0;
|
|
4
|
+
const date_utils_1 = require("../helpers/date.utils");
|
|
5
|
+
const helper_function_utils_1 = require("../helpers/helper.function.utils");
|
|
6
|
+
class BillingLineItemModel {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
var _a;
|
|
9
|
+
this.id = data.id;
|
|
10
|
+
this.billId = data.billId;
|
|
11
|
+
this.inventoryId = data.inventoryId;
|
|
12
|
+
this.rateId = (_a = data.rateId) !== null && _a !== void 0 ? _a : undefined;
|
|
13
|
+
this.rateAmount = data.rateAmount;
|
|
14
|
+
this.quantity = data.quantity;
|
|
15
|
+
this.tenureValue = data.tenureValue;
|
|
16
|
+
this.normalizedTenureInDays = data.normalizedTenureInDays;
|
|
17
|
+
this.startDate = data.startDate;
|
|
18
|
+
this.endDate = data.endDate;
|
|
19
|
+
this.totalAmount = Number(data.totalAmount);
|
|
20
|
+
this.description = data.description;
|
|
21
|
+
this.status = data.status;
|
|
22
|
+
// audit
|
|
23
|
+
this.createdOn = data.createdOn;
|
|
24
|
+
this.updatedOn = data.updatedOn;
|
|
25
|
+
this.createdBy = data.createdBy;
|
|
26
|
+
this.updatedBy = data.updatedBy;
|
|
27
|
+
}
|
|
28
|
+
getLineItemTotalAmount() {
|
|
29
|
+
// calculate number of days between startDate and endDate
|
|
30
|
+
const numberOfDays = new date_utils_1.DateUtils().getDaysBetween(this.startDate, this.endDate);
|
|
31
|
+
// then find the rate per day
|
|
32
|
+
const ratePerDay = (0, helper_function_utils_1.getDecimalNoUptoNPlaces)(this.rateAmount / this.normalizedTenureInDays);
|
|
33
|
+
// then total number of days * rate per day * quantity gives total amount for that item
|
|
34
|
+
return numberOfDays * ratePerDay * this.quantity;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BillingLineItemModel = BillingLineItemModel;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BillingStatusEnum } from "../enums/billing.status.enum";
|
|
2
|
+
import { EntityList } from "../enums/entity-list.enum";
|
|
3
|
+
import { BillingRateTenureEnum } from "../enums/tenure.enum";
|
|
4
|
+
import { EntityType } from "../helpers/generics";
|
|
5
|
+
import { BillingLineItemModel } from "./billing-line-item-model";
|
|
6
|
+
export declare class BillingModel implements EntityType<EntityList.BILLING> {
|
|
7
|
+
id: number;
|
|
8
|
+
organizationId: number;
|
|
9
|
+
clientId: number;
|
|
10
|
+
referenceClientId: number;
|
|
11
|
+
startDate: string;
|
|
12
|
+
endDate: string;
|
|
13
|
+
billingRateTenure: BillingRateTenureEnum;
|
|
14
|
+
invoiceNo: string;
|
|
15
|
+
invoiceUrl: string | null;
|
|
16
|
+
totalAmount: number;
|
|
17
|
+
discount: number;
|
|
18
|
+
netBillingAmount: number;
|
|
19
|
+
accountNumber?: string;
|
|
20
|
+
ifscCode?: string;
|
|
21
|
+
gstNumber?: string;
|
|
22
|
+
status: BillingStatusEnum;
|
|
23
|
+
createdOn: Date;
|
|
24
|
+
updatedOn: Date;
|
|
25
|
+
createdBy: number;
|
|
26
|
+
updatedBy: number;
|
|
27
|
+
constructor(data: EntityType<EntityList.BILLING>);
|
|
28
|
+
getBillingStartDate(): string;
|
|
29
|
+
getBillingEndDate(): string;
|
|
30
|
+
static getBillingTotalAmountFromLineItems(lineItems: BillingLineItemModel[]): number;
|
|
31
|
+
getNetBillingAmountAfterDiscount(): number;
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingModel = void 0;
|
|
4
|
+
const helper_function_utils_1 = require("../helpers/helper.function.utils");
|
|
5
|
+
class BillingModel {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
this.id = data.id;
|
|
9
|
+
this.organizationId = data.organizationId;
|
|
10
|
+
this.clientId = data.clientId;
|
|
11
|
+
this.referenceClientId = (_a = data.referenceClientId) !== null && _a !== void 0 ? _a : undefined;
|
|
12
|
+
this.startDate = data.startDate;
|
|
13
|
+
this.endDate = data.endDate;
|
|
14
|
+
this.billingRateTenure = data.billingRateTenure;
|
|
15
|
+
this.invoiceNo = data.invoiceNo;
|
|
16
|
+
this.invoiceUrl = data.invoiceUrl;
|
|
17
|
+
this.totalAmount = Number(data.totalAmount);
|
|
18
|
+
this.discount = data.discount;
|
|
19
|
+
this.netBillingAmount = Number(data.netBillingAmount);
|
|
20
|
+
this.accountNumber = (_b = data.accountNumber) !== null && _b !== void 0 ? _b : undefined;
|
|
21
|
+
this.ifscCode = (_c = data.ifscCode) !== null && _c !== void 0 ? _c : undefined;
|
|
22
|
+
this.gstNumber = (_d = data.gstNumber) !== null && _d !== void 0 ? _d : undefined;
|
|
23
|
+
this.status = data.status;
|
|
24
|
+
this.createdOn = data.createdOn;
|
|
25
|
+
this.updatedOn = data.updatedOn;
|
|
26
|
+
this.createdBy = data.createdBy;
|
|
27
|
+
this.updatedBy = data.updatedBy;
|
|
28
|
+
}
|
|
29
|
+
getBillingStartDate() {
|
|
30
|
+
return this.startDate;
|
|
31
|
+
}
|
|
32
|
+
getBillingEndDate() {
|
|
33
|
+
return this.endDate;
|
|
34
|
+
}
|
|
35
|
+
static getBillingTotalAmountFromLineItems(lineItems) {
|
|
36
|
+
let totalAmount = 0;
|
|
37
|
+
for (const item of lineItems) {
|
|
38
|
+
totalAmount += item.getLineItemTotalAmount();
|
|
39
|
+
}
|
|
40
|
+
return (0, helper_function_utils_1.getDecimalNoUptoNPlaces)(totalAmount);
|
|
41
|
+
}
|
|
42
|
+
getNetBillingAmountAfterDiscount() {
|
|
43
|
+
return (0, helper_function_utils_1.getDecimalNoUptoNPlaces)(this.totalAmount - (this.totalAmount * this.discount) / 100);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.BillingModel = BillingModel;
|