invoice-system-common 1.0.30-beta.5 → 1.0.30-beta.6
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BillingRateTenureEnum } from "../enums/tenure.enum";
|
|
1
2
|
import { IBillingLineItemCreateDto } from "../interfaces/billing-line-item.dto.interface";
|
|
2
3
|
export declare class BillingLineItemCreateModel implements IBillingLineItemCreateDto {
|
|
3
4
|
billId: number;
|
|
@@ -19,7 +20,7 @@ export declare class BillingLineItemCreateModel implements IBillingLineItemCreat
|
|
|
19
20
|
/**
|
|
20
21
|
* Calculates tenureValue based on billing type
|
|
21
22
|
*/
|
|
22
|
-
calculateTenureValue(
|
|
23
|
+
calculateTenureValue(billingTenureType: BillingRateTenureEnum): void;
|
|
23
24
|
/**
|
|
24
25
|
* Returns a clean DTO for API submission
|
|
25
26
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BillingLineItemCreateModel = void 0;
|
|
4
|
+
const tenure_enum_1 = require("../enums/tenure.enum");
|
|
4
5
|
const date_utils_1 = require("../helpers/date.utils");
|
|
5
6
|
const helper_function_utils_1 = require("../helpers/helper.function.utils");
|
|
6
7
|
class BillingLineItemCreateModel {
|
|
@@ -34,10 +35,13 @@ class BillingLineItemCreateModel {
|
|
|
34
35
|
/**
|
|
35
36
|
* Calculates tenureValue based on billing type
|
|
36
37
|
*/
|
|
37
|
-
calculateTenureValue(
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
calculateTenureValue(billingTenureType) {
|
|
39
|
+
const daysUsed = new date_utils_1.DateUtils().getDaysBetween(this.startDate, this.endDate);
|
|
40
|
+
if (billingTenureType === tenure_enum_1.BillingRateTenureEnum.MONTHLY) {
|
|
41
|
+
const daysInMonth = new date_utils_1.DateUtils().getDaysInMonthFromYYYYMMDD(this.endDate);
|
|
42
|
+
this.normalizedTenureInDays = daysInMonth;
|
|
43
|
+
this.tenureValue = daysUsed / daysInMonth;
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* Returns a clean DTO for API submission
|
|
@@ -21,6 +21,7 @@ class BillingCreateModel {
|
|
|
21
21
|
calculateBillingTotalAmount() {
|
|
22
22
|
let total = 0;
|
|
23
23
|
for (const item of this.lineItems) {
|
|
24
|
+
item.calculateTenureValue(this.billingRateTenure);
|
|
24
25
|
total += item.calculateTotalAmount();
|
|
25
26
|
}
|
|
26
27
|
this.totalAmount = (0, helper_function_utils_1.getDecimalNoUptoNPlaces)(total);
|