@kipicore/dbcore 1.1.368 → 1.1.370

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 (87) hide show
  1. package/dist/db/psql/migrations/20260401061046-update_pdc.d.ts +2 -0
  2. package/dist/db/psql/migrations/20260401061046-update_pdc.js +35 -0
  3. package/dist/db/psql/migrations/20260401063714-update_pdc_histroy.d.ts +2 -0
  4. package/dist/db/psql/migrations/20260401063714-update_pdc_histroy.js +45 -0
  5. package/dist/interfaces/feeReminderTypeInterface.d.ts +2 -1
  6. package/dist/interfaces/index.d.ts +0 -11
  7. package/dist/interfaces/index.js +0 -11
  8. package/dist/interfaces/pdcChequeInterface.d.ts +1 -3
  9. package/dist/interfaces/pdcHistoryInterface.d.ts +4 -4
  10. package/dist/models/mongodb/feeReminderTypeModel.js +6 -2
  11. package/dist/models/mongodb/index.d.ts +0 -1
  12. package/dist/models/mongodb/index.js +2 -4
  13. package/dist/models/psql/index.d.ts +0 -10
  14. package/dist/models/psql/index.js +3 -23
  15. package/dist/models/psql/pdcChequeModel.d.ts +1 -3
  16. package/dist/models/psql/pdcChequeModel.js +17 -31
  17. package/dist/models/psql/pdcHistoryModel.d.ts +3 -3
  18. package/dist/models/psql/pdcHistoryModel.js +30 -22
  19. package/dist/types/index.d.ts +0 -11
  20. package/dist/types/index.js +0 -11
  21. package/package.json +1 -1
  22. package/dist/interfaces/feeHistoryDetailsInterface.d.ts +0 -17
  23. package/dist/interfaces/feeHistoryDetailsInterface.js +0 -2
  24. package/dist/interfaces/feeHistoryInterface.d.ts +0 -22
  25. package/dist/interfaces/feeHistoryInterface.js +0 -2
  26. package/dist/interfaces/feeTypeHasTermsInterface.d.ts +0 -12
  27. package/dist/interfaces/feeTypeHasTermsInterface.js +0 -2
  28. package/dist/interfaces/feeTypeInterface.d.ts +0 -14
  29. package/dist/interfaces/feeTypeInterface.js +0 -4
  30. package/dist/interfaces/feesCollectionInterface.d.ts +0 -19
  31. package/dist/interfaces/feesCollectionInterface.js +0 -2
  32. package/dist/interfaces/paymentTermsInterface.d.ts +0 -16
  33. package/dist/interfaces/paymentTermsInterface.js +0 -2
  34. package/dist/interfaces/schoolFeeCollectionInterface.d.ts +0 -13
  35. package/dist/interfaces/schoolFeeCollectionInterface.js +0 -2
  36. package/dist/interfaces/schoolFeeInterface.d.ts +0 -22
  37. package/dist/interfaces/schoolFeeInterface.js +0 -2
  38. package/dist/interfaces/userFeeTypeByAccountInterface.d.ts +0 -19
  39. package/dist/interfaces/userFeeTypeByAccountInterface.js +0 -2
  40. package/dist/interfaces/userFeeTypeInterface.d.ts +0 -17
  41. package/dist/interfaces/userFeeTypeInterface.js +0 -2
  42. package/dist/interfaces/userHasFeeTermsInterface.d.ts +0 -37
  43. package/dist/interfaces/userHasFeeTermsInterface.js +0 -2
  44. package/dist/models/mongodb/schoolFeeModel.d.ts +0 -4
  45. package/dist/models/mongodb/schoolFeeModel.js +0 -182
  46. package/dist/models/psql/feeHistoryDetailsModel.d.ts +0 -27
  47. package/dist/models/psql/feeHistoryDetailsModel.js +0 -145
  48. package/dist/models/psql/feeHistoryModel.d.ts +0 -33
  49. package/dist/models/psql/feeHistoryModel.js +0 -189
  50. package/dist/models/psql/feeTypeHasTermsModel.d.ts +0 -22
  51. package/dist/models/psql/feeTypeHasTermsModel.js +0 -99
  52. package/dist/models/psql/feeTypeModel.d.ts +0 -24
  53. package/dist/models/psql/feeTypeModel.js +0 -110
  54. package/dist/models/psql/feesCollectionModel.d.ts +0 -30
  55. package/dist/models/psql/feesCollectionModel.js +0 -200
  56. package/dist/models/psql/paymentTermsModel.d.ts +0 -19
  57. package/dist/models/psql/paymentTermsModel.js +0 -125
  58. package/dist/models/psql/schoolFeeCollectionModel.d.ts +0 -23
  59. package/dist/models/psql/schoolFeeCollectionModel.js +0 -109
  60. package/dist/models/psql/userFeeTypeByAccountModel.d.ts +0 -23
  61. package/dist/models/psql/userFeeTypeByAccountModel.js +0 -179
  62. package/dist/models/psql/userFeeTypeModel.d.ts +0 -26
  63. package/dist/models/psql/userFeeTypeModel.js +0 -180
  64. package/dist/models/psql/userHasFeeTermsModel.d.ts +0 -28
  65. package/dist/models/psql/userHasFeeTermsModel.js +0 -136
  66. package/dist/types/feeHistoryDetailsType.d.ts +0 -6
  67. package/dist/types/feeHistoryDetailsType.js +0 -2
  68. package/dist/types/feeHistoryType.d.ts +0 -18
  69. package/dist/types/feeHistoryType.js +0 -2
  70. package/dist/types/feeTypeHasTermsType.d.ts +0 -3
  71. package/dist/types/feeTypeHasTermsType.js +0 -2
  72. package/dist/types/feeTypeType.d.ts +0 -3
  73. package/dist/types/feeTypeType.js +0 -2
  74. package/dist/types/feesCollectionType.d.ts +0 -3
  75. package/dist/types/feesCollectionType.js +0 -2
  76. package/dist/types/paymentTermsType.d.ts +0 -3
  77. package/dist/types/paymentTermsType.js +0 -3
  78. package/dist/types/schoolFeeCollectionType.d.ts +0 -3
  79. package/dist/types/schoolFeeCollectionType.js +0 -2
  80. package/dist/types/schoolFeeType.d.ts +0 -3
  81. package/dist/types/schoolFeeType.js +0 -2
  82. package/dist/types/userFeeTypeByAccountType.d.ts +0 -3
  83. package/dist/types/userFeeTypeByAccountType.js +0 -2
  84. package/dist/types/userFeeTypeType.d.ts +0 -6
  85. package/dist/types/userFeeTypeType.js +0 -2
  86. package/dist/types/userHasFeeTermsType.d.ts +0 -3
  87. package/dist/types/userHasFeeTermsType.js +0 -2
@@ -32,15 +32,10 @@ export * from './examHasAnswerSheetType';
32
32
  export * from './examType';
33
33
  export * from './facilityType';
34
34
  export * from './featureActionType';
35
- export * from './feeHistoryDetailsType';
36
- export * from './feeHistoryType';
37
35
  export * from './feeReminderSettingType';
38
36
  export * from './feeReminderType';
39
37
  export * from './feeReminderTypeType';
40
- export * from './feeTypeHasTermsType';
41
- export * from './feeTypeType';
42
38
  export * from './feedBackType';
43
- export * from './feesCollectionType';
44
39
  export * from './fileStorageType';
45
40
  export * from './floormanagementType';
46
41
  export * from './generateIdCardType';
@@ -62,7 +57,6 @@ export * from './masterLeaveType';
62
57
  export * from './moduleFeatureType';
63
58
  export * from './moduleType';
64
59
  export * from './offerType';
65
- export * from './paymentTermsType';
66
60
  export * from './pdcChequeType';
67
61
  export * from './pdcHistoryType';
68
62
  export * from './photosGalleryType';
@@ -71,8 +65,6 @@ export * from './productType';
71
65
  export * from './projectAssessmentOptionType';
72
66
  export * from './roleType';
73
67
  export * from './rulesRegulationType';
74
- export * from './schoolFeeCollectionType';
75
- export * from './schoolFeeType';
76
68
  export * from './schoolOfferType';
77
69
  export * from './sendNotificationType';
78
70
  export * from './slotType';
@@ -90,13 +82,10 @@ export * from './typeManagementType';
90
82
  export * from './uniqueNumberCounterType';
91
83
  export * from './userBookAssessmentType';
92
84
  export * from './userDetailsType';
93
- export * from './userFeeTypeByAccountType';
94
- export * from './userFeeTypeType';
95
85
  export * from './userHasAnnouncementType';
96
86
  export * from './userHasBatchType';
97
87
  export * from './userHasCourseType';
98
88
  export * from './userHasDeviceType';
99
- export * from './userHasFeeTermsType';
100
89
  export * from './userHasFileType';
101
90
  export * from './userHasHomeWorkType';
102
91
  export * from './userHasInventoryHistoryType';
@@ -48,15 +48,10 @@ __exportStar(require("./examHasAnswerSheetType"), exports);
48
48
  __exportStar(require("./examType"), exports);
49
49
  __exportStar(require("./facilityType"), exports);
50
50
  __exportStar(require("./featureActionType"), exports);
51
- __exportStar(require("./feeHistoryDetailsType"), exports);
52
- __exportStar(require("./feeHistoryType"), exports);
53
51
  __exportStar(require("./feeReminderSettingType"), exports);
54
52
  __exportStar(require("./feeReminderType"), exports);
55
53
  __exportStar(require("./feeReminderTypeType"), exports);
56
- __exportStar(require("./feeTypeHasTermsType"), exports);
57
- __exportStar(require("./feeTypeType"), exports);
58
54
  __exportStar(require("./feedBackType"), exports);
59
- __exportStar(require("./feesCollectionType"), exports);
60
55
  __exportStar(require("./fileStorageType"), exports);
61
56
  __exportStar(require("./floormanagementType"), exports);
62
57
  __exportStar(require("./generateIdCardType"), exports);
@@ -78,7 +73,6 @@ __exportStar(require("./masterLeaveType"), exports);
78
73
  __exportStar(require("./moduleFeatureType"), exports);
79
74
  __exportStar(require("./moduleType"), exports);
80
75
  __exportStar(require("./offerType"), exports);
81
- __exportStar(require("./paymentTermsType"), exports);
82
76
  __exportStar(require("./pdcChequeType"), exports);
83
77
  __exportStar(require("./pdcHistoryType"), exports);
84
78
  __exportStar(require("./photosGalleryType"), exports);
@@ -87,8 +81,6 @@ __exportStar(require("./productType"), exports);
87
81
  __exportStar(require("./projectAssessmentOptionType"), exports);
88
82
  __exportStar(require("./roleType"), exports);
89
83
  __exportStar(require("./rulesRegulationType"), exports);
90
- __exportStar(require("./schoolFeeCollectionType"), exports);
91
- __exportStar(require("./schoolFeeType"), exports);
92
84
  __exportStar(require("./schoolOfferType"), exports);
93
85
  __exportStar(require("./sendNotificationType"), exports);
94
86
  __exportStar(require("./slotType"), exports);
@@ -106,13 +98,10 @@ __exportStar(require("./typeManagementType"), exports);
106
98
  __exportStar(require("./uniqueNumberCounterType"), exports);
107
99
  __exportStar(require("./userBookAssessmentType"), exports);
108
100
  __exportStar(require("./userDetailsType"), exports);
109
- __exportStar(require("./userFeeTypeByAccountType"), exports);
110
- __exportStar(require("./userFeeTypeType"), exports);
111
101
  __exportStar(require("./userHasAnnouncementType"), exports);
112
102
  __exportStar(require("./userHasBatchType"), exports);
113
103
  __exportStar(require("./userHasCourseType"), exports);
114
104
  __exportStar(require("./userHasDeviceType"), exports);
115
- __exportStar(require("./userHasFeeTermsType"), exports);
116
105
  __exportStar(require("./userHasFileType"), exports);
117
106
  __exportStar(require("./userHasHomeWorkType"), exports);
118
107
  __exportStar(require("./userHasInventoryHistoryType"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.368",
3
+ "version": "1.1.370",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -1,17 +0,0 @@
1
- import { PAYMENT_TYPE } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IFeeHistoryDetailsModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- instituteId: string;
6
- feeHistoryId: string;
7
- userFeeTypeByAccountId: string;
8
- academicCalendarId: string;
9
- schoolFeeCollectionId: string;
10
- userId: string;
11
- feeTypeId: string;
12
- paidFee: number;
13
- upiId: string;
14
- paymentType: PAYMENT_TYPE;
15
- chequeNo: string;
16
- bankName: string;
17
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
1
- import { FEE_HISTORY_STATUS, PAYMENT_TYPE } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IFeeHistoryModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- instituteId: string;
6
- userId: string;
7
- feeCollectionId?: string;
8
- paidFee: number;
9
- pdfId?: string | null;
10
- invoiceId?: number | null;
11
- status: FEE_HISTORY_STATUS;
12
- paidDate: Date;
13
- upiId?: string | null;
14
- paymentType?: PAYMENT_TYPE;
15
- bankName?: string | null;
16
- chequeNo?: string | null;
17
- feeTypeId?: string[] | null;
18
- bankAccountId?: string | null;
19
- parentHistoryId?: string | null;
20
- schoolFeeCollectionId?: string | null;
21
- academicCalendarId?: string;
22
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- import { PAYMENT_TERMS_TYPE } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IFeeTypeHasTermsModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- stdId: string;
6
- feeTypeId: string;
7
- frequency: PAYMENT_TERMS_TYPE;
8
- amount: number;
9
- date: Date;
10
- instituteId: string;
11
- academicCalendarId: string;
12
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +0,0 @@
1
- import { FEE_TYPE, COMMAN_STATUS, FEE_TYPE_FREQUENCY, BOOLEAN_STATUS } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IFeeTypeModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- typeManagementId: string;
6
- frequency: FEE_TYPE_FREQUENCY;
7
- feeType: FEE_TYPE;
8
- module: COMMAN_STATUS;
9
- status: COMMAN_STATUS;
10
- account: string;
11
- academicCalendarId?: string;
12
- instituteId: string;
13
- isDefault: BOOLEAN_STATUS;
14
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // import { IDefaultAttributes } from './commonInterface';
3
- // import { FEE_TYPE, COMMAN_STATUS, FEE_TYPE_FREQUENCY, BOOLEAN_STATUS } from '../constants/app';
4
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +0,0 @@
1
- import { FEE_PAYMENT_STATUS, PAYMENT_TYPE } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IFeesCollectionModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- date: Date;
6
- feeAmount?: number;
7
- paymentType?: PAYMENT_TYPE;
8
- bankName?: string | null;
9
- chequeNo?: string | null;
10
- userId: string;
11
- academicCalendarId: string;
12
- instituteId: string;
13
- upiId?: string | null;
14
- status?: FEE_PAYMENT_STATUS;
15
- discount?: number;
16
- paidFee?: number;
17
- dueDate?: Date;
18
- isLeft: boolean;
19
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +0,0 @@
1
- import { PAYMENT_TERMS_STATUS, PAYMENT_TERMS_TYPE } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IPaymentTermsModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- date?: Date;
6
- startDate: Date;
7
- endDate: Date;
8
- paidAmount: number;
9
- type: PAYMENT_TERMS_TYPE;
10
- amount: number;
11
- status: PAYMENT_TERMS_STATUS;
12
- instituteId: string;
13
- userId: string;
14
- feeCollectionId: string;
15
- academicCalendarId?: string;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +0,0 @@
1
- import { IDefaultAttributes } from './commonInterface';
2
- export interface ISchoolFeesCollectionModelAttributes extends IDefaultAttributes {
3
- id: string;
4
- date?: Date;
5
- totalFeeAmount: number;
6
- userId: string;
7
- instituteId: string;
8
- discount: number;
9
- paidFee: number;
10
- dueDate?: Date;
11
- academicCalendarId: string;
12
- perviousFeeCollectionId: string | null;
13
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
1
- import { Document } from 'mongoose';
2
- import { PAYMENT_TERMS_TYPE } from '../constants/app';
3
- import { IDefaultAttributes } from './commonInterface';
4
- export interface ITermsSchema {
5
- date: Date;
6
- amount: number;
7
- }
8
- export interface IFeeSchema {
9
- feeTypeId: string;
10
- terms: ITermsSchema[];
11
- totalAmount: number;
12
- frequency: PAYMENT_TERMS_TYPE;
13
- isNotApplicableForGirls: boolean;
14
- }
15
- export interface ISchoolFeeModelAttributes extends IDefaultAttributes, Document {
16
- id: string;
17
- instituteId: string;
18
- stdId: string[];
19
- commonDueDate: number;
20
- fees: IFeeSchema[];
21
- academicCalendarId: string;
22
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +0,0 @@
1
- import { IDefaultAttributes } from './commonInterface';
2
- import { IUserFeeTypeModelAttributes } from './userFeeTypeInterface';
3
- export interface collectionHasUserFeeType {
4
- userFeeTypeType: IUserFeeTypeModelAttributes;
5
- feeTypeId: string;
6
- }
7
- export interface IUserFeeTypeByAccountModelAttributes extends IDefaultAttributes {
8
- collectionHasUserFeeType?: collectionHasUserFeeType[];
9
- id: string;
10
- userId: string;
11
- instituteId: string;
12
- bankAccountId: string;
13
- feeCollectionId: string;
14
- amount: number;
15
- discount: number;
16
- perviousFeeCollectionId: string;
17
- academicCalendarId: string;
18
- paidAmount: number;
19
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- import { COMMAN_STATUS } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IUserFeeTypeModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- userId: string;
6
- instituteId: string;
7
- feeCollectionId: string;
8
- feeTypeId: string;
9
- status: COMMAN_STATUS;
10
- amount: number;
11
- discount: number;
12
- paidFee: number;
13
- grNumber?: string;
14
- rollNumber: string;
15
- feeCollectionAccountId: string;
16
- academicCalendarId?: string;
17
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,37 +0,0 @@
1
- import { FEE_HISTORY_STATUS, PAYMENT_TERMS_STATUS, PAYMENT_TYPE } from '../constants/app';
2
- import { IDefaultAttributes } from './commonInterface';
3
- export interface IUserHasFeeTermsModelAttributes extends IDefaultAttributes {
4
- id: string;
5
- date?: Date;
6
- startDate: Date;
7
- endDate?: Date;
8
- paidAmount: number;
9
- amount: number;
10
- status: PAYMENT_TERMS_STATUS;
11
- instituteId: string;
12
- bankAccountId: string;
13
- userId: string;
14
- feeCollectionId: string;
15
- feeTypeId: string;
16
- stdId: string;
17
- academicCalendarId: string;
18
- }
19
- export interface IUserPayFeeAttributes {
20
- id: string;
21
- feesData: {
22
- paidFee: number;
23
- discount?: number;
24
- feeCollectionId: string;
25
- academicCalendarId: string;
26
- date?: Date;
27
- userId: string;
28
- instituteId: string;
29
- feeTypeId: string;
30
- stdId?: string;
31
- }[];
32
- paymentType: PAYMENT_TYPE;
33
- chequeNo: string;
34
- bankName: string;
35
- upiId?: string;
36
- status?: FEE_HISTORY_STATUS;
37
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import { Model } from 'mongoose';
2
- import { ISchoolFeeModelAttributes } from '../../interfaces/schoolFeeInterface';
3
- declare const SchoolFeeModel: Model<ISchoolFeeModelAttributes>;
4
- export default SchoolFeeModel;
@@ -1,182 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
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
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const mongoose_1 = __importStar(require("mongoose"));
40
- const app_1 = require("../../constants/app");
41
- const errorMessages_1 = require("../../constants/errorMessages");
42
- const instituteModel_1 = __importDefault(require("../psql/instituteModel"));
43
- const userInstituteMetaModel_1 = __importDefault(require("./userInstituteMetaModel"));
44
- const feeTypeModel_1 = __importDefault(require("../psql/feeTypeModel"));
45
- const termsSchemaSchema = new mongoose_1.Schema({
46
- date: {
47
- type: Date,
48
- required: true,
49
- },
50
- amount: {
51
- type: Number,
52
- default: 0,
53
- required: true,
54
- },
55
- // paidAmount: {
56
- // type: Number,
57
- // default: 0,
58
- // required: false,
59
- // },
60
- }, { _id: false });
61
- const feeSchema = new mongoose_1.Schema({
62
- feeTypeId: {
63
- type: String,
64
- required: true,
65
- },
66
- frequency: {
67
- type: String,
68
- enum: Object.values(app_1.PAYMENT_TERMS_TYPE),
69
- required: true,
70
- },
71
- terms: {
72
- type: [termsSchemaSchema],
73
- default: [],
74
- required: true,
75
- },
76
- isNotApplicableForGirls: {
77
- type: Boolean,
78
- default: false,
79
- required: false,
80
- },
81
- totalAmount: {
82
- type: Number,
83
- default: 0,
84
- required: true,
85
- },
86
- }, { _id: false });
87
- const schoolFeeSchema = new mongoose_1.Schema({
88
- instituteId: {
89
- type: String,
90
- required: true,
91
- },
92
- stdId: {
93
- type: [String],
94
- required: true,
95
- },
96
- commonDueDate: {
97
- type: Number,
98
- required: true,
99
- },
100
- fees: {
101
- type: [feeSchema],
102
- default: [],
103
- required: true,
104
- },
105
- academicCalendarId: {
106
- type: String,
107
- required: false,
108
- },
109
- createdBy: {
110
- type: String,
111
- required: false,
112
- },
113
- updatedBy: {
114
- type: String,
115
- required: false,
116
- },
117
- deletedBy: {
118
- type: String,
119
- required: false,
120
- },
121
- }, {
122
- timestamps: true,
123
- versionKey: false,
124
- });
125
- schoolFeeSchema.pre('save', async function (next) {
126
- const schoolFee = this;
127
- try {
128
- if (!schoolFee.fees || schoolFee.fees.length === 0) {
129
- return next(new Error('Fees array cannot be empty.'));
130
- }
131
- if (schoolFee.instituteId) {
132
- const institute = await instituteModel_1.default.findByPk(schoolFee.instituteId);
133
- if (!institute) {
134
- return next(new Error(errorMessages_1.INSTITUTE_ERROR_MESSAGES.NOT_FOUND));
135
- }
136
- }
137
- if (schoolFee.stdId) {
138
- const stdExits = await userInstituteMetaModel_1.default.findOne({
139
- userId: schoolFee.instituteId,
140
- instituteId: schoolFee.instituteId,
141
- entities: { $all: schoolFee.stdId },
142
- });
143
- if (!stdExits) {
144
- return next(new Error(errorMessages_1.USER_INSTITUTE_META_ERROR_MESSAGES.STD_NOT_FOUND));
145
- }
146
- }
147
- // const expectedLengths: Record<PAYMENT_TERMS_TYPE, number> = {
148
- // YEARLY: 1,
149
- // MONTHLY: 12,
150
- // HALF_YEARLY: 2,
151
- // QUARTERLY: 4,
152
- // FULL_PAYMENT: 1,
153
- // };
154
- for (const fee of schoolFee.fees) {
155
- // if (fee.frequency && expectedLengths[fee.frequency] !== fee.terms.length) {
156
- // return next(
157
- // new Error(`Invalid terms length for ${fee.frequency}. Expected ${expectedLengths[fee.frequency]}, but got ${fee.terms.length}.`),
158
- // );
159
- // }
160
- if (fee.feeTypeId) {
161
- const feeType = await feeTypeModel_1.default.findByPk(fee.feeTypeId);
162
- if (!feeType)
163
- return next(new Error(errorMessages_1.FEE_TYPE_ERROR_MESSAGES.NOT_FOUND));
164
- }
165
- const totalTermsAmount = fee.terms.reduce((sum, term) => sum + term.amount, 0);
166
- if (totalTermsAmount !== fee.totalAmount) {
167
- return next(new Error(`Total amount mismatch for feeTypeId ${fee.feeTypeId}: Expected ${fee.totalAmount}, but sum of terms is ${totalTermsAmount}.`));
168
- }
169
- for (const term of fee.terms) {
170
- if (!(term.date instanceof Date) || isNaN(term.date.getTime())) {
171
- return next(new Error(`Invalid date format in terms for feeTypeId ${fee.feeTypeId}.`));
172
- }
173
- }
174
- }
175
- next();
176
- }
177
- catch (error) {
178
- return next(error);
179
- }
180
- });
181
- const SchoolFeeModel = mongoose_1.default.model('schoolFee', schoolFeeSchema);
182
- exports.default = SchoolFeeModel;
@@ -1,27 +0,0 @@
1
- import { Model } from 'sequelize';
2
- import { IFeeHistoryDetailsModelAttributes } from '../../interfaces/feeHistoryDetailsInterface';
3
- import { TFeeHistoryDetailsModelCreationAttributes } from '../../types/feeHistoryDetailsType';
4
- import { PAYMENT_TYPE } from '../../constants/app';
5
- export declare class FeeHistoryDetailsModel extends Model<IFeeHistoryDetailsModelAttributes, TFeeHistoryDetailsModelCreationAttributes> {
6
- id: string;
7
- instituteId: string;
8
- userFeeTypeByAccountId: string;
9
- academicCalendarId: string;
10
- schoolFeeCollectionId: string;
11
- feeHistoryId: string;
12
- userId: string;
13
- feeTypeId: string;
14
- paidFee: number;
15
- upiId: string;
16
- paymentType: PAYMENT_TYPE;
17
- chequeNo: string;
18
- bankName: string;
19
- createdBy: string;
20
- updatedBy: string;
21
- deletedBy: string;
22
- readonly createdAt: Date;
23
- readonly updatedAt: Date;
24
- readonly deletedAt?: Date;
25
- static associate(models: any): void;
26
- }
27
- export default FeeHistoryDetailsModel;