turf-common 1.0.16-beta.31 → 1.0.16-beta.32

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.
Files changed (71) hide show
  1. package/package.json +1 -1
  2. package/build/enums/pricing-plan-status.enum.d.ts +0 -4
  3. package/build/enums/pricing-plan-status.enum.js +0 -8
  4. package/build/interface/get-pricing-plan-by-date-response.interface copy.d.ts +0 -23
  5. package/build/interface/get-pricing-plan-by-date-response.interface copy.js +0 -2
  6. package/build/interface/pitch-slab.interface copy.d.ts +0 -5
  7. package/build/interface/pitch-slab.interface copy.js +0 -2
  8. package/build/models/booking-details-model.d.ts +0 -39
  9. package/build/models/booking-details-model.js +0 -69
  10. package/build/models/booking-entity-model.d.ts +0 -21
  11. package/build/models/booking-entity-model.js +0 -47
  12. package/build/models/booking-payment-history-model.d.ts +0 -20
  13. package/build/models/booking-payment-history-model.js +0 -36
  14. package/build/models/cancellation-policy-model.d.ts +0 -18
  15. package/build/models/cancellation-policy-model.js +0 -32
  16. package/build/models/configuration-model.d.ts +0 -16
  17. package/build/models/configuration-model.js +0 -17
  18. package/build/models/price-model.d.ts +0 -11
  19. package/build/models/price-model.js +0 -15
  20. package/build/models/pricing-plan-entity-model.d.ts +0 -47
  21. package/build/models/pricing-plan-entity-model.js +0 -128
  22. package/build/models/subscription-model.d.ts +0 -30
  23. package/build/models/subscription-model.js +0 -51
  24. package/build/models/turf-model.d.ts +0 -34
  25. package/build/models/turf-model.js +0 -88
  26. package/build/models/user-model.d.ts +0 -31
  27. package/build/models/user-model.js +0 -19
  28. package/build/types/entity/bank-details-entity.type.d.ts +0 -12
  29. package/build/types/entity/bank-details-entity.type.js +0 -2
  30. package/build/types/entity/booking-cancellation-entity.type.d.ts +0 -32
  31. package/build/types/entity/booking-cancellation-entity.type.js +0 -2
  32. package/build/types/entity/booking-customer-entity.type.d.ts +0 -8
  33. package/build/types/entity/booking-customer-entity.type.js +0 -2
  34. package/build/types/entity/booking-details-entity.type.d.ts +0 -27
  35. package/build/types/entity/booking-details-entity.type.js +0 -2
  36. package/build/types/entity/booking-history-entity.type.d.ts +0 -31
  37. package/build/types/entity/booking-history-entity.type.js +0 -2
  38. package/build/types/entity/booking-payment-history-entity.type.d.ts +0 -13
  39. package/build/types/entity/booking-payment-history-entity.type.js +0 -2
  40. package/build/types/entity/bookings-entity.type.d.ts +0 -6
  41. package/build/types/entity/bookings-entity.type.js +0 -2
  42. package/build/types/entity/cancellation-policy-entity.type.d.ts +0 -8
  43. package/build/types/entity/cancellation-policy-entity.type.js +0 -2
  44. package/build/types/entity/configurations-entity.type.d.ts +0 -8
  45. package/build/types/entity/configurations-entity.type.js +0 -2
  46. package/build/types/entity/coupon.entity.type.d.ts +0 -10
  47. package/build/types/entity/coupon.entity.type.js +0 -2
  48. package/build/types/entity/cron-jobs-entity.type.d.ts +0 -12
  49. package/build/types/entity/cron-jobs-entity.type.js +0 -2
  50. package/build/types/entity/entity-audit-column.type.d.ts +0 -12
  51. package/build/types/entity/entity-audit-column.type.js +0 -9
  52. package/build/types/entity/faqs-entity.type.d.ts +0 -10
  53. package/build/types/entity/faqs-entity.type.js +0 -2
  54. package/build/types/entity/organization-entity.type.d.ts +0 -23
  55. package/build/types/entity/organization-entity.type.js +0 -2
  56. package/build/types/entity/pitch-entity.type.d.ts +0 -9
  57. package/build/types/entity/pitch-entity.type.js +0 -2
  58. package/build/types/entity/price-entity.type.d.ts +0 -5
  59. package/build/types/entity/price-entity.type.js +0 -3
  60. package/build/types/entity/pricing-plan-entity.d.ts +0 -16
  61. package/build/types/entity/pricing-plan-entity.js +0 -2
  62. package/build/types/entity/registration-entity.type.d.ts +0 -12
  63. package/build/types/entity/registration-entity.type.js +0 -2
  64. package/build/types/entity/subscription-entity.type.d.ts +0 -20
  65. package/build/types/entity/subscription-entity.type.js +0 -2
  66. package/build/types/entity/subscription-pitch-mapping.type.d.ts +0 -7
  67. package/build/types/entity/subscription-pitch-mapping.type.js +0 -3
  68. package/build/types/entity/turf-entity.type.d.ts +0 -17
  69. package/build/types/entity/turf-entity.type.js +0 -2
  70. package/build/types/entity/user-entity.type.d.ts +0 -24
  71. package/build/types/entity/user-entity.type.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.0.16-beta.31",
3
+ "version": "1.0.16-beta.32",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -1,4 +0,0 @@
1
- export declare enum PricingPlanStatus {
2
- ACTIVE = "active",
3
- DEACTIVE = "deactive"
4
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PricingPlanStatus = void 0;
4
- var PricingPlanStatus;
5
- (function (PricingPlanStatus) {
6
- PricingPlanStatus["ACTIVE"] = "active";
7
- PricingPlanStatus["DEACTIVE"] = "deactive";
8
- })(PricingPlanStatus || (exports.PricingPlanStatus = PricingPlanStatus = {}));
@@ -1,23 +0,0 @@
1
- export interface GetPricingPlanByDateResponse {
2
- id: number;
3
- effective_from_date: number;
4
- effective_to_date: number;
5
- base_price: number;
6
- unit: string;
7
- pitch_slab: {
8
- [key: string]: {
9
- from: number;
10
- to: number;
11
- discount: string;
12
- };
13
- };
14
- billing_cycle: {
15
- [key: string]: {
16
- from: number;
17
- to: number;
18
- discount: string;
19
- name: string;
20
- key: string;
21
- };
22
- };
23
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export interface IPitchSlab {
2
- from: number;
3
- to: number;
4
- discount: string;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,39 +0,0 @@
1
- import { BookingDetailsStatus } from "../enums/booking-details-status.enum";
2
- import { IBookingDetailsModel } from "../interface/booking-details-model.interface";
3
- import { IBookingDetailsWithBooking } from "../types/bookingdetails-with-booking.type";
4
- import { IBookingDetailsEntity } from "../types/entity/booking-details-entity.type";
5
- import { IBookingsEntity } from "../types/entity/bookings-entity.type";
6
- import { ChargesModel } from "./charge-model";
7
- export declare class BookingDetailsModel implements IBookingDetailsModel {
8
- id: number;
9
- turfId: number;
10
- pitchId: number;
11
- customerName: string;
12
- contact: string;
13
- paymentMode: string;
14
- couponCode: string;
15
- totalCost: number;
16
- discountedCost: number;
17
- amountPaid: number;
18
- email: string;
19
- status: BookingDetailsStatus;
20
- sport: string;
21
- remarks: string;
22
- initialBookingGrossAmount: number;
23
- additionalBookingGrossAmount: number;
24
- discountAmount: number;
25
- cancelledBookingGrossAmount: number;
26
- totalCancellationCharges: number;
27
- netTotal: number;
28
- amountPayable: number;
29
- refundPayable: number;
30
- totalRefundedAmount: number;
31
- createdOn: Date;
32
- updatedOn: Date;
33
- createdBy: number;
34
- updatedBy: number;
35
- constructor(data: IBookingDetailsEntity);
36
- static getIdAndCreatedBy(bookingDetailsEntities: IBookingDetailsEntity[]): number[][];
37
- assignCharges(chargeModel: ChargesModel): void;
38
- static toMap(bookingDetailsEntities: IBookingDetailsEntity[], bookingsEntities: IBookingsEntity[]): IBookingDetailsWithBooking;
39
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.BookingDetailsModel = void 0;
15
- var booking_entity_model_1 = require("./booking-entity-model");
16
- var BookingDetailsModel = /** @class */ (function () {
17
- function BookingDetailsModel(data) {
18
- Object.assign(this, data);
19
- }
20
- BookingDetailsModel.getIdAndCreatedBy = function (bookingDetailsEntities) {
21
- var bookingDetailsIds = [];
22
- var userIds = [];
23
- bookingDetailsEntities.forEach(function (_a) {
24
- var bookingDetailId = _a.id, createdBy = _a.createdBy;
25
- bookingDetailsIds.push(bookingDetailId), userIds.push(createdBy);
26
- });
27
- return [bookingDetailsIds, userIds];
28
- };
29
- // static toMap(
30
- // bookingDetailsEntities: IBookingDetailsEntity[],
31
- // bookingsEntities: BookingsEntity[],
32
- // ): IBookingDetailsWithBooking {
33
- // const response: IBookingDetailsWithBooking = {};
34
- // bookingDetailsEntities.forEach((bookingsDetailsEntity) => {
35
- // const bookingDetailsId = bookingsDetailsEntity.id;
36
- // if (!response[bookingDetailsId]) {
37
- // response[bookingDetailsId] = {
38
- // ...bookingsDetailsEntity,
39
- // bookings: {},
40
- // };
41
- // }
42
- // const filterBookingEntities = bookingsEntities.filter(
43
- // (bookingEntity) => bookingEntity.bookingDetailsId === bookingDetailsId,
44
- // );
45
- // response[bookingDetailsId].bookings = BookingsEntity.toMap(
46
- // filterBookingEntities,
47
- // );
48
- // });
49
- // return response;
50
- // }
51
- BookingDetailsModel.prototype.assignCharges = function (chargeModel) {
52
- this.discountAmount = chargeModel.getDiscountAmount();
53
- Object.assign(this, chargeModel);
54
- };
55
- BookingDetailsModel.toMap = function (bookingDetailsEntities, bookingsEntities) {
56
- var response = {};
57
- bookingDetailsEntities.forEach(function (bookingsDetailsEntity) {
58
- var bookingDetailsId = bookingsDetailsEntity.id;
59
- if (!response[bookingDetailsId]) {
60
- response[bookingDetailsId] = __assign(__assign({}, bookingsDetailsEntity), { bookings: {} });
61
- }
62
- var filterBookingEntities = bookingsEntities.filter(function (bookingEntity) { return bookingEntity.bookingDetailsId === bookingDetailsId; });
63
- response[bookingDetailsId].bookings = booking_entity_model_1.BookingEntityModel.toMap(filterBookingEntities);
64
- });
65
- return response;
66
- };
67
- return BookingDetailsModel;
68
- }());
69
- exports.BookingDetailsModel = BookingDetailsModel;
@@ -1,21 +0,0 @@
1
- import { IBookingsEntityModel } from "../interface/booking-entity-model.interface";
2
- import { IBookingsEntity } from "../types/entity/bookings-entity.type";
3
- import { BookingCode } from "./booking-code-model";
4
- export declare class BookingEntityModel implements IBookingsEntityModel {
5
- bookingDetailsId: number;
6
- code: string;
7
- cost: string;
8
- createdOn: Date;
9
- updatedOn: Date;
10
- createdBy: number;
11
- updatedBy: number;
12
- constructor(data: IBookingsEntity);
13
- getTotalCost(): number;
14
- getBookingTimeInMinutes(): number;
15
- isTimeExtended(newBookingEntities: IBookingsEntity[]): boolean;
16
- getBookingCode(): BookingCode;
17
- static toMap(bookingEntities: IBookingsEntity[]): {
18
- [key: string]: string;
19
- };
20
- static findByCodeAndTurfId(bookingEntities: IBookingsEntity[], turfId: number, bookingCode: string): IBookingsEntity | undefined;
21
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BookingEntityModel = void 0;
4
- var booking_code_model_1 = require("./booking-code-model");
5
- var BookingEntityModel = /** @class */ (function () {
6
- function BookingEntityModel(data) {
7
- Object.assign(this, data);
8
- }
9
- BookingEntityModel.prototype.getTotalCost = function () {
10
- return this.cost
11
- .split(",")
12
- .map(Number)
13
- .reduce(function (accumulator, currentValue) { return accumulator + currentValue; }, 0);
14
- };
15
- BookingEntityModel.prototype.getBookingTimeInMinutes = function () {
16
- var bookingCode = new booking_code_model_1.BookingCode(this.code);
17
- return bookingCode.getBookingTimeInMinutes();
18
- };
19
- BookingEntityModel.prototype.isTimeExtended = function (newBookingEntities) {
20
- var newTimeInMinutes = newBookingEntities
21
- .map(function (bookingEntity) {
22
- return new BookingEntityModel(bookingEntity).getBookingTimeInMinutes();
23
- })
24
- .reduce(function (accumulator, currentValue) { return accumulator + currentValue; }, 0);
25
- return (newTimeInMinutes > new BookingEntityModel(this).getBookingTimeInMinutes());
26
- };
27
- BookingEntityModel.prototype.getBookingCode = function () {
28
- return new booking_code_model_1.BookingCode(this.code, this.cost);
29
- };
30
- BookingEntityModel.toMap = function (bookingEntities) {
31
- var response = {};
32
- bookingEntities.forEach(function (bookingEntity) {
33
- response[bookingEntity.code] =
34
- response[bookingEntity.code] === undefined
35
- ? bookingEntity.cost
36
- : response[bookingEntity.code];
37
- });
38
- return response;
39
- };
40
- BookingEntityModel.findByCodeAndTurfId = function (bookingEntities, turfId, bookingCode) {
41
- return bookingEntities.find(function (bookingEntity) {
42
- return bookingEntity.code === booking_code_model_1.BookingCode.getInstance(turfId, bookingCode).code;
43
- });
44
- };
45
- return BookingEntityModel;
46
- }());
47
- exports.BookingEntityModel = BookingEntityModel;
@@ -1,20 +0,0 @@
1
- import { PaymentMode } from "../enums/payment-mode.enum";
2
- import { BookingPaymentTransactionType } from "../enums/transaction-type.enum";
3
- import { IDateWisePaymentHistoryData } from "../types/date-wise-payment-history-data.types";
4
- import { IBookingPaymentHistoryEntity } from "../types/entity/booking-payment-history-entity.type";
5
- export declare class BookingPaymentHistoryModel implements IBookingPaymentHistoryEntity {
6
- id: number;
7
- bookingDetailsId: number;
8
- turfId: number;
9
- pitchId: number;
10
- type: PaymentMode | null;
11
- transactionType: BookingPaymentTransactionType;
12
- amount: number;
13
- bookingHistoryId: number;
14
- createdOn: Date;
15
- updatedOn: Date;
16
- createdBy: number;
17
- updatedBy: number;
18
- constructor(data: IBookingPaymentHistoryEntity);
19
- static dateCodeAndTurfIdWiseData(bookingPaymentHistoryEntities: IBookingPaymentHistoryEntity[]): IDateWisePaymentHistoryData;
20
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BookingPaymentHistoryModel = void 0;
4
- var payment_mode_enum_1 = require("../enums/payment-mode.enum");
5
- var booking_code_model_1 = require("./booking-code-model");
6
- var BookingPaymentHistoryModel = /** @class */ (function () {
7
- function BookingPaymentHistoryModel(data) {
8
- Object.assign(this, data);
9
- }
10
- BookingPaymentHistoryModel.dateCodeAndTurfIdWiseData = function (bookingPaymentHistoryEntities) {
11
- var dateWisePaymentHistoryData = {};
12
- for (var _i = 0, bookingPaymentHistoryEntities_1 = bookingPaymentHistoryEntities; _i < bookingPaymentHistoryEntities_1.length; _i++) {
13
- var bookingPaymentHistoryEntity = bookingPaymentHistoryEntities_1[_i];
14
- var turfId = bookingPaymentHistoryEntity.turfId, amount = bookingPaymentHistoryEntity.amount, type = bookingPaymentHistoryEntity.type, createdOn = bookingPaymentHistoryEntity.createdOn;
15
- var dateCode = booking_code_model_1.BookingCode.getDateCode(createdOn);
16
- if (!dateWisePaymentHistoryData[dateCode])
17
- dateWisePaymentHistoryData[dateCode] = {};
18
- var turfWisePaymentData = dateWisePaymentHistoryData[dateCode][turfId];
19
- if (!turfWisePaymentData)
20
- turfWisePaymentData = dateWisePaymentHistoryData[dateCode][turfId] = {
21
- cashTotal: 0,
22
- upiTotal: 0,
23
- total: 0,
24
- };
25
- if (type === payment_mode_enum_1.PaymentMode.CASH)
26
- turfWisePaymentData.cashTotal += amount;
27
- else if (type === payment_mode_enum_1.PaymentMode.UPI)
28
- turfWisePaymentData.upiTotal += amount;
29
- turfWisePaymentData.total =
30
- turfWisePaymentData.cashTotal + turfWisePaymentData.upiTotal;
31
- }
32
- return dateWisePaymentHistoryData;
33
- };
34
- return BookingPaymentHistoryModel;
35
- }());
36
- exports.BookingPaymentHistoryModel = BookingPaymentHistoryModel;
@@ -1,18 +0,0 @@
1
- import { ICancellationPolicyModel } from "../interface/cancellation-policy-model.interface";
2
- import { ICancellationPolicyEntity } from "../types/entity/cancellation-policy-entity.type";
3
- export declare class CancellationPolicyModel implements ICancellationPolicyModel {
4
- id: number;
5
- turfId: number;
6
- from: number;
7
- to: number;
8
- charges: string;
9
- createdOn: Date;
10
- updatedOn: Date;
11
- createdBy: number;
12
- updatedBy: number;
13
- constructor(data: ICancellationPolicyEntity);
14
- unitOfCharges(): string;
15
- chargesWithoutUnit(): string;
16
- isInEffect(hours: number): boolean;
17
- getCancellationCharges(cost: number): number;
18
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CancellationPolicyModel = void 0;
4
- var CancellationPolicyModel = /** @class */ (function () {
5
- function CancellationPolicyModel(data) {
6
- Object.assign(this, data);
7
- }
8
- CancellationPolicyModel.prototype.unitOfCharges = function () {
9
- return this.charges.slice(-1);
10
- };
11
- CancellationPolicyModel.prototype.chargesWithoutUnit = function () {
12
- return this.charges.slice(0, -1);
13
- };
14
- CancellationPolicyModel.prototype.isInEffect = function (hours) {
15
- return this.from <= hours && hours <= this.to;
16
- };
17
- CancellationPolicyModel.prototype.getCancellationCharges = function (cost) {
18
- var cancellationCharges = 0;
19
- var cancellationChargesModel = new CancellationPolicyModel(this);
20
- if (cancellationChargesModel.unitOfCharges() === "P") {
21
- var percentageValue = cancellationChargesModel.chargesWithoutUnit();
22
- cancellationCharges = (cost * Number(percentageValue)) / 100;
23
- }
24
- else if (cancellationChargesModel.unitOfCharges() === "U") {
25
- var unit = cancellationChargesModel.chargesWithoutUnit();
26
- cancellationCharges = Number(unit);
27
- }
28
- return cancellationCharges;
29
- };
30
- return CancellationPolicyModel;
31
- }());
32
- exports.CancellationPolicyModel = CancellationPolicyModel;
@@ -1,16 +0,0 @@
1
- import { ConfigurationKey } from "../enums/configuration-key.enum";
2
- import { IConfigurationsModel } from "../interface/configuration-model.interface";
3
- import { IConfigurationsEntity } from "../types/entity/configurations-entity.type";
4
- export declare class ConfigurationsModel implements IConfigurationsModel {
5
- id: number;
6
- key: ConfigurationKey;
7
- value: string;
8
- description: string;
9
- createdOn: Date;
10
- updatedOn: Date;
11
- createdBy: number;
12
- updatedBy: number;
13
- constructor(data: IConfigurationsEntity);
14
- isCronJobKey(): boolean;
15
- static findByKey(configurationEntities: IConfigurationsEntity[], key: ConfigurationKey): IConfigurationsEntity | undefined;
16
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigurationsModel = void 0;
4
- var configuration_key_enum_1 = require("../enums/configuration-key.enum");
5
- var ConfigurationsModel = /** @class */ (function () {
6
- function ConfigurationsModel(data) {
7
- Object.assign(this, data);
8
- }
9
- ConfigurationsModel.prototype.isCronJobKey = function () {
10
- return configuration_key_enum_1.ConfigurationKey.CronJobsConfigurationsKeys(this.key);
11
- };
12
- ConfigurationsModel.findByKey = function (configurationEntities, key) {
13
- return configurationEntities.find(function (configurationEntity) { return configurationEntity.key === key; });
14
- };
15
- return ConfigurationsModel;
16
- }());
17
- exports.ConfigurationsModel = ConfigurationsModel;
@@ -1,11 +0,0 @@
1
- import { IPriceModel } from "../interface/price-model.interface";
2
- import { IPriceEntity } from "../types/entity/price-entity.type";
3
- export declare class PriceModel implements IPriceModel {
4
- id: string;
5
- price: number;
6
- createdOn: Date;
7
- updatedOn: Date;
8
- createdBy: number;
9
- updatedBy: number;
10
- static sortByCode(priceEntities: IPriceEntity[]): IPriceEntity[];
11
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PriceModel = void 0;
4
- var PriceModel = /** @class */ (function () {
5
- function PriceModel() {
6
- }
7
- PriceModel.sortByCode = function (priceEntities) {
8
- priceEntities = priceEntities.sort(function (a, b) {
9
- return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
10
- });
11
- return priceEntities;
12
- };
13
- return PriceModel;
14
- }());
15
- exports.PriceModel = PriceModel;
@@ -1,47 +0,0 @@
1
- import { PricingPlanStatus } from "../enums/pricing-plan-status.enum copy";
2
- import { IBillingCycle } from "../interface/billing-cycle.interface";
3
- import { GetPricingPlanByDateResponse } from "../interface/get-pricing-plan-by-date-response.interface";
4
- import { IPitchSlab } from "../interface/pitch-slab.interface";
5
- import { IPricingPlanEntityModel } from "../interface/pricing-plan-entity-model.interface";
6
- import { IPricingPlanEntity } from "../types/entity/pricing-plan-entity";
7
- import { BillingCycleModel } from "./billing-cycle-model";
8
- import { PricingPlanModel } from "./pricing-plan-model";
9
- export declare class PricingPlanEntityModel implements IPricingPlanEntityModel {
10
- id: number;
11
- effectiveFrom: Date;
12
- effectiveTo: Date;
13
- costCode: string;
14
- status: PricingPlanStatus;
15
- createdBy: number;
16
- createdOn: Date;
17
- updatedBy: number;
18
- updatedOn: Date;
19
- basePrice: number;
20
- billingCycle: string;
21
- unit: string;
22
- constructor(data: IPricingPlanEntity);
23
- getBillingCycleKeys(): string[];
24
- toModel(): PricingPlanModel;
25
- arrayToIndexedObject<T>(arr: T[]): {
26
- [key: string]: T;
27
- };
28
- toObject(): GetPricingPlanByDateResponse;
29
- toPitchSlabs(): IPitchSlab[];
30
- toBillingCycles(): IBillingCycle[];
31
- }
32
- export declare class PitchSlabParser {
33
- code: string;
34
- constructor(code: string);
35
- parseToModel(): IPitchSlab;
36
- }
37
- export declare class BillingCycleCodeParser {
38
- code: string;
39
- from: number;
40
- to: number;
41
- discount: string;
42
- name: string;
43
- constructor(code: string);
44
- parse(): BillingCycleCodeParser;
45
- parseToModel(): BillingCycleModel;
46
- getKey(): string;
47
- }
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BillingCycleCodeParser = exports.PitchSlabParser = exports.PricingPlanEntityModel = void 0;
4
- var billing_cycle_model_1 = require("./billing-cycle-model");
5
- var booking_code_model_1 = require("./booking-code-model");
6
- var pitch_slab_model_1 = require("./pitch-slab-model");
7
- var pricing_plan_model_1 = require("./pricing-plan-model");
8
- var PricingPlanEntityModel = /** @class */ (function () {
9
- function PricingPlanEntityModel(data) {
10
- Object.assign(this, data);
11
- }
12
- PricingPlanEntityModel.prototype.getBillingCycleKeys = function () {
13
- return this.toBillingCycles().map(function (billingCycle) { return billingCycle.key; });
14
- };
15
- PricingPlanEntityModel.prototype.toModel = function () {
16
- return new pricing_plan_model_1.PricingPlanModel({
17
- id: this.id,
18
- base_price: this.basePrice,
19
- effective_from_date: parseInt(booking_code_model_1.BookingCode.getDateCode(this.effectiveFrom)),
20
- effective_to_date: parseInt(booking_code_model_1.BookingCode.getDateCode(this.effectiveTo)),
21
- unit: this.unit,
22
- billing_cycle: this.arrayToIndexedObject(this.toBillingCycles()),
23
- pitch_slab: this.arrayToIndexedObject(this.toPitchSlabs()),
24
- });
25
- };
26
- PricingPlanEntityModel.prototype.arrayToIndexedObject = function (arr) {
27
- return arr.reduce(function (result, item, index) {
28
- result[index.toString()] = item; //a, b, c
29
- return result;
30
- }, {});
31
- };
32
- PricingPlanEntityModel.prototype.toObject = function () {
33
- var responseObj = {
34
- id: this.id,
35
- effective_from_date: 0,
36
- effective_to_date: 0,
37
- base_price: 0,
38
- unit: "per_hour_per_pitch",
39
- pitch_slab: {},
40
- billing_cycle: {},
41
- };
42
- var billingCycle = this.billingCycle.split(",");
43
- billingCycle.forEach(function (billing, index) {
44
- var billingArray = billing.split("_");
45
- responseObj.billing_cycle[index] = {
46
- from: Number(billingArray[0].slice(0, 3)),
47
- to: Number(billingArray[0].slice(3, 6)),
48
- discount: billingArray[1],
49
- name: billingArray.slice(2).join("_"),
50
- key: billingArray.slice(2).join("-").toLowerCase().replace(/ /g, "-"),
51
- };
52
- });
53
- this.costCode.split(",").forEach(function (code, index) {
54
- var costCode = code.split("_");
55
- responseObj.pitch_slab[index] = {
56
- from: Number(costCode[0].slice(0, 3)),
57
- to: Number(costCode[0].slice(3, 6)),
58
- discount: costCode[1],
59
- };
60
- });
61
- responseObj.effective_from_date = Number(booking_code_model_1.BookingCode.getDateCode(this.effectiveFrom));
62
- responseObj.effective_to_date = Number(booking_code_model_1.BookingCode.getDateCode(this.effectiveTo));
63
- responseObj.unit = this.unit;
64
- responseObj.base_price = this.basePrice;
65
- return responseObj;
66
- };
67
- PricingPlanEntityModel.prototype.toPitchSlabs = function () {
68
- return this.costCode
69
- .split(",")
70
- .map(function (cost_code) { return new PitchSlabParser(cost_code).parseToModel(); });
71
- };
72
- PricingPlanEntityModel.prototype.toBillingCycles = function () {
73
- return this.billingCycle
74
- .split(",")
75
- .map(function (billingCode) {
76
- return new BillingCycleCodeParser(billingCode).parseToModel();
77
- });
78
- };
79
- return PricingPlanEntityModel;
80
- }());
81
- exports.PricingPlanEntityModel = PricingPlanEntityModel;
82
- var PitchSlabParser = /** @class */ (function () {
83
- function PitchSlabParser(code) {
84
- this.code = code;
85
- }
86
- PitchSlabParser.prototype.parseToModel = function () {
87
- var costCodeComponents = this.code.split("_");
88
- return new pitch_slab_model_1.PitchSlabModel({
89
- discount: costCodeComponents[1],
90
- from: parseInt(costCodeComponents[0].slice(0, 3)),
91
- to: parseInt(costCodeComponents[0].slice(3)),
92
- });
93
- };
94
- return PitchSlabParser;
95
- }());
96
- exports.PitchSlabParser = PitchSlabParser;
97
- var BillingCycleCodeParser = /** @class */ (function () {
98
- function BillingCycleCodeParser(code) {
99
- this.code = code;
100
- }
101
- BillingCycleCodeParser.prototype.parse = function () {
102
- var billingCycleComponents = this.code.split("_");
103
- this.from = parseInt(billingCycleComponents[0].slice(0, 3));
104
- this.to = parseInt(billingCycleComponents[0].slice(3, 6));
105
- this.discount = billingCycleComponents[1];
106
- this.name = billingCycleComponents[2];
107
- return this;
108
- };
109
- BillingCycleCodeParser.prototype.parseToModel = function () {
110
- var billingCycleComponents = this.code.split("_");
111
- this.from = parseInt(billingCycleComponents[0].slice(0, 3));
112
- this.to = parseInt(billingCycleComponents[0].slice(3, 6));
113
- this.discount = billingCycleComponents[1];
114
- this.name = billingCycleComponents[2];
115
- return new billing_cycle_model_1.BillingCycleModel({
116
- discount: this.discount,
117
- from: this.from,
118
- to: this.to,
119
- name: this.name,
120
- key: this.getKey(),
121
- });
122
- };
123
- BillingCycleCodeParser.prototype.getKey = function () {
124
- return this.name.toLowerCase().replace(" ", "-");
125
- };
126
- return BillingCycleCodeParser;
127
- }());
128
- exports.BillingCycleCodeParser = BillingCycleCodeParser;
@@ -1,30 +0,0 @@
1
- import { SubscriptionStatus } from "../interface/subscription-status.interface";
2
- import { ISubscriptionEntity, ISubscriptionModel } from "../types/entity/subscription-entity.type";
3
- export declare class SubscriptionModel implements ISubscriptionModel {
4
- id: number;
5
- organizationId: number;
6
- from: Date;
7
- to: Date;
8
- type: string;
9
- grossAmount: number;
10
- discount: string;
11
- netAmount: number;
12
- amountPaid: number;
13
- status: SubscriptionStatus;
14
- noOfPitches: number;
15
- remarks: string;
16
- registrationId: number;
17
- pricingPlanId: number;
18
- previousSubscriptionIds: string;
19
- createdOn: Date;
20
- updatedOn: Date;
21
- createdBy: number;
22
- updatedBy: number;
23
- constructor(data: ISubscriptionEntity);
24
- remainingSubscriptionDays(): number;
25
- static updateStatus(subscriptionEntities: ISubscriptionEntity[], status: SubscriptionStatus, userId: number): ISubscriptionEntity[];
26
- remainingAmount(): number;
27
- isAmountFullyPaid(): boolean;
28
- isAmountPaidGreater(): boolean;
29
- updateStatusIfPaymentDone(): void;
30
- }