@mody-park-cha-raja/finance_common 4.27.0 → 4.27.1-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 ADDED
@@ -0,0 +1,18 @@
1
+ # Name
2
+ ### @mody-park-cha-raja/finance_common
3
+
4
+ # Synopsis
5
+ Common interfaces, models, enums, and utilities for the Mody Park Cha Raja finance ecosystem
6
+
7
+ # Description
8
+
9
+ # Example
10
+
11
+ # Install:
12
+ `npm install @mody-park-cha-raja/finance_common`
13
+
14
+ # Test:
15
+ `npm test`
16
+
17
+ #License:
18
+ ISC
package/dist/index.d.mts CHANGED
@@ -1,8 +1,18 @@
1
1
  import * as XLSX from 'xlsx';
2
2
 
3
+ /**
4
+ * @deprecated MPCR-60 — static flat data is being replaced by the persisted
5
+ * `flat` entity (see `models/flat.entity.model.ts` + `EntityList.FLAT`).
6
+ * Keep only as a seed/migration reference; do not add new usage.
7
+ * TODO MPCR-60 remove
8
+ */
9
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
3
10
  declare const SPECIAL_FLATS: readonly string[];
11
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
4
12
  declare const FLAT_NUMBERS: readonly string[];
13
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
5
14
  declare const FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
15
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
6
16
  declare const WINGS: readonly string[];
7
17
 
8
18
  declare enum ConfigurationKey {
@@ -137,6 +147,16 @@ interface IExpenseEntity extends IAuditColumnEntity {
137
147
  status?: EntityStatus;
138
148
  }
139
149
 
150
+ interface IFlatHistoryEntity extends IBaseHistoryEntity {
151
+ }
152
+
153
+ interface IFlatEntity extends IAuditColumnEntity {
154
+ id: number;
155
+ wing: string;
156
+ unitNumber: string;
157
+ status: EntityStatus;
158
+ }
159
+
140
160
  interface ISponsorHistoryEntity extends IBaseHistoryEntity {
141
161
  }
142
162
 
@@ -351,6 +371,20 @@ declare class ExpenseModel extends BaseEntityModel implements IExpenseEntity {
351
371
  get vendorName(): string;
352
372
  }
353
373
 
374
+ declare class FlatHistoryModel extends BaseEntityModel implements IFlatHistoryEntity {
375
+ id: number;
376
+ entityId: number;
377
+ data: string;
378
+ operation: EntityHistoryOperation;
379
+ createdOn: number;
380
+ updatedOn: number;
381
+ createdBy: number;
382
+ updatedBy: number;
383
+ protected constructor();
384
+ static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList.FLAT_HISTORY>>>;
385
+ static populateFromEntity(entity: IFlatHistoryEntity): FlatHistoryModel;
386
+ }
387
+
354
388
  interface FlatDonationLike {
355
389
  flatNo: string;
356
390
  amount: number;
@@ -380,6 +414,15 @@ interface FlatOption {
380
414
  value: string;
381
415
  }
382
416
  declare class FlatModel {
417
+ id: number;
418
+ wing: string;
419
+ unitNumber: string;
420
+ status: EntityStatus;
421
+ createdOn: number;
422
+ updatedOn: number;
423
+ createdBy: number;
424
+ updatedBy: number;
425
+ static populateFromEntity(entity: IFlatEntity): FlatModel;
383
426
  static readonly FLAT_NUMBERS: readonly string[];
384
427
  static readonly FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
385
428
  static readonly SPECIAL_FLATS: readonly string[];
@@ -528,6 +571,8 @@ declare const entityListEntityModelMap: {
528
571
  transaction_history: typeof TransactionHistoryModel.populateFromEntity;
529
572
  sponsor: typeof SponsorModel.populateFromEntity;
530
573
  sponsor_history: typeof SponsorHistoryModel.populateFromEntity;
574
+ flat: typeof FlatModel.populateFromEntity;
575
+ flat_history: typeof FlatHistoryModel.populateFromEntity;
531
576
  configuration: typeof ConfigurationModel.populateFromEntity;
532
577
  };
533
578
 
@@ -770,10 +815,12 @@ declare enum EntityList {
770
815
  TRANSACTION_HISTORY = "transaction_history",
771
816
  SPONSOR = "sponsor",
772
817
  SPONSOR_HISTORY = "sponsor_history",
818
+ FLAT = "flat",
819
+ FLAT_HISTORY = "flat_history",
773
820
  CONFIGURATION = "configuration"
774
821
  }
775
- type EntityType<T extends EntityList> = T extends EntityList.DONATION ? IDonationEntity : T extends EntityList.DONATION_HISTORY ? IDonationHistoryEntity : T extends EntityList.USER ? IUserEntity : T extends EntityList.USER_HISTORY ? IUserHistoryEntity : T extends EntityList.EXPENSE ? IExpenseEntity : T extends EntityList.EXPENSE_HISTORY ? IExpenseHistoryEntity : T extends EntityList.VENDOR ? IVendorEntity : T extends EntityList.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityList.TRANSACTION ? ITransactionEntity : T extends EntityList.TRANSACTION_HISTORY ? ITransactionHistoryEntity : T extends EntityList.SPONSOR ? ISponsorEntity : T extends EntityList.SPONSOR_HISTORY ? ISponsorHistoryEntity : T extends EntityList.CONFIGURATION ? IConfigurationEntity : never;
776
- type EntityModelType<T extends EntityList> = T extends EntityList.DONATION ? DonationModel : T extends EntityList.DONATION_HISTORY ? DonationHistoryModel : T extends EntityList.USER ? UserModel : T extends EntityList.USER_HISTORY ? UserHistoryModel : T extends EntityList.EXPENSE ? ExpenseModel : T extends EntityList.EXPENSE_HISTORY ? ExpenseHistoryModel : T extends EntityList.VENDOR ? VendorModel : T extends EntityList.VENDOR_HISTORY ? VendorHistoryModel : T extends EntityList.TRANSACTION ? TransactionModel : T extends EntityList.TRANSACTION_HISTORY ? TransactionHistoryModel : T extends EntityList.SPONSOR ? SponsorModel : T extends EntityList.SPONSOR_HISTORY ? SponsorHistoryModel : T extends EntityList.CONFIGURATION ? ConfigurationModel : never;
822
+ type EntityType<T extends EntityList> = T extends EntityList.DONATION ? IDonationEntity : T extends EntityList.DONATION_HISTORY ? IDonationHistoryEntity : T extends EntityList.USER ? IUserEntity : T extends EntityList.USER_HISTORY ? IUserHistoryEntity : T extends EntityList.EXPENSE ? IExpenseEntity : T extends EntityList.EXPENSE_HISTORY ? IExpenseHistoryEntity : T extends EntityList.VENDOR ? IVendorEntity : T extends EntityList.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityList.TRANSACTION ? ITransactionEntity : T extends EntityList.TRANSACTION_HISTORY ? ITransactionHistoryEntity : T extends EntityList.SPONSOR ? ISponsorEntity : T extends EntityList.SPONSOR_HISTORY ? ISponsorHistoryEntity : T extends EntityList.FLAT ? IFlatEntity : T extends EntityList.FLAT_HISTORY ? IFlatHistoryEntity : T extends EntityList.CONFIGURATION ? IConfigurationEntity : never;
823
+ type EntityModelType<T extends EntityList> = T extends EntityList.DONATION ? DonationModel : T extends EntityList.DONATION_HISTORY ? DonationHistoryModel : T extends EntityList.USER ? UserModel : T extends EntityList.USER_HISTORY ? UserHistoryModel : T extends EntityList.EXPENSE ? ExpenseModel : T extends EntityList.EXPENSE_HISTORY ? ExpenseHistoryModel : T extends EntityList.VENDOR ? VendorModel : T extends EntityList.VENDOR_HISTORY ? VendorHistoryModel : T extends EntityList.TRANSACTION ? TransactionModel : T extends EntityList.TRANSACTION_HISTORY ? TransactionHistoryModel : T extends EntityList.SPONSOR ? SponsorModel : T extends EntityList.SPONSOR_HISTORY ? SponsorHistoryModel : T extends EntityList.FLAT ? FlatModel : T extends EntityList.FLAT_HISTORY ? FlatHistoryModel : T extends EntityList.CONFIGURATION ? ConfigurationModel : never;
777
824
  type EntityListEntityModelMap = {
778
825
  [T in EntityList]: EntityModelType<T>[];
779
826
  };
@@ -895,4 +942,25 @@ interface IConfigurationUpdateDto extends IEntityUpdateDto<EntityType<EntityList
895
942
  interface IConfigurationSearchDto extends IEntityFilterData<EntityType<EntityList.CONFIGURATION>> {
896
943
  }
897
944
 
898
- export { ALL_WINGS_SELECTION, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, FLATS_BY_WING, FLAT_NUMBERS, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatModel, type FlatOption, type FlatParseResult, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PAYMENT_OPTIONS, PaymentType, ReferenceIdPrefix, RelationType, SPECIAL_FLATS, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, WINGS, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, convertNumberToWords, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getObjectDiffingKeys, getWingSelectionLabel, getWingSelectionSlug, groupBy, serializeXlsx };
945
+ interface IFlatCreateDto extends IEntityCreateDto<EntityType<EntityList.FLAT>> {
946
+ }
947
+ interface IFlatUpdateDto extends IEntityUpdateDto<EntityType<EntityList.FLAT>> {
948
+ }
949
+ interface IFlatSearchDto extends IEntityFilterData<EntityType<EntityList.FLAT>> {
950
+ }
951
+
952
+ declare const FLAT_WING_PATTERN: RegExp;
953
+ declare const SHOP_WING = "SH";
954
+ declare const SPECIAL_FLAT_LABELS: readonly ["Devotee", "Ex-Member Devotee", "Others"];
955
+ declare const FLAT_UNIT_NUMBER_PATTERN: RegExp;
956
+ declare const SHOP_UNIT_NUMBER_PATTERN: RegExp;
957
+ type FlatValidationError = {
958
+ key: string;
959
+ message: string;
960
+ };
961
+ declare function isValidFlatWing(wing: string | null | undefined): boolean;
962
+ declare function isSpecialFlatLabel(label: string): boolean;
963
+ declare function getFlatValidationErrors(input: Partial<IFlatEntity>): FlatValidationError[];
964
+ declare function validateFlatOrThrow(input: Partial<IFlatEntity>): void;
965
+
966
+ export { ALL_WINGS_SELECTION, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, FLATS_BY_WING, FLAT_NUMBERS, FLAT_UNIT_NUMBER_PATTERN, FLAT_WING_PATTERN, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatHistoryModel, FlatModel, type FlatOption, type FlatParseResult, type FlatValidationError, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IFlatCreateDto, type IFlatEntity, type IFlatHistoryEntity, type IFlatSearchDto, type IFlatUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PAYMENT_OPTIONS, PaymentType, ReferenceIdPrefix, RelationType, SHOP_UNIT_NUMBER_PATTERN, SHOP_WING, SPECIAL_FLATS, SPECIAL_FLAT_LABELS, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, WINGS, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, convertNumberToWords, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getFlatValidationErrors, getObjectDiffingKeys, getWingSelectionLabel, getWingSelectionSlug, groupBy, isSpecialFlatLabel, isValidFlatWing, serializeXlsx, validateFlatOrThrow };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,18 @@
1
1
  import * as XLSX from 'xlsx';
2
2
 
3
+ /**
4
+ * @deprecated MPCR-60 — static flat data is being replaced by the persisted
5
+ * `flat` entity (see `models/flat.entity.model.ts` + `EntityList.FLAT`).
6
+ * Keep only as a seed/migration reference; do not add new usage.
7
+ * TODO MPCR-60 remove
8
+ */
9
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
3
10
  declare const SPECIAL_FLATS: readonly string[];
11
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
4
12
  declare const FLAT_NUMBERS: readonly string[];
13
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
5
14
  declare const FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
15
+ /** @deprecated Use FlatEntity from the database instead. Kept for migration reference. */
6
16
  declare const WINGS: readonly string[];
7
17
 
8
18
  declare enum ConfigurationKey {
@@ -137,6 +147,16 @@ interface IExpenseEntity extends IAuditColumnEntity {
137
147
  status?: EntityStatus;
138
148
  }
139
149
 
150
+ interface IFlatHistoryEntity extends IBaseHistoryEntity {
151
+ }
152
+
153
+ interface IFlatEntity extends IAuditColumnEntity {
154
+ id: number;
155
+ wing: string;
156
+ unitNumber: string;
157
+ status: EntityStatus;
158
+ }
159
+
140
160
  interface ISponsorHistoryEntity extends IBaseHistoryEntity {
141
161
  }
142
162
 
@@ -351,6 +371,20 @@ declare class ExpenseModel extends BaseEntityModel implements IExpenseEntity {
351
371
  get vendorName(): string;
352
372
  }
353
373
 
374
+ declare class FlatHistoryModel extends BaseEntityModel implements IFlatHistoryEntity {
375
+ id: number;
376
+ entityId: number;
377
+ data: string;
378
+ operation: EntityHistoryOperation;
379
+ createdOn: number;
380
+ updatedOn: number;
381
+ createdBy: number;
382
+ updatedBy: number;
383
+ protected constructor();
384
+ static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList.FLAT_HISTORY>>>;
385
+ static populateFromEntity(entity: IFlatHistoryEntity): FlatHistoryModel;
386
+ }
387
+
354
388
  interface FlatDonationLike {
355
389
  flatNo: string;
356
390
  amount: number;
@@ -380,6 +414,15 @@ interface FlatOption {
380
414
  value: string;
381
415
  }
382
416
  declare class FlatModel {
417
+ id: number;
418
+ wing: string;
419
+ unitNumber: string;
420
+ status: EntityStatus;
421
+ createdOn: number;
422
+ updatedOn: number;
423
+ createdBy: number;
424
+ updatedBy: number;
425
+ static populateFromEntity(entity: IFlatEntity): FlatModel;
383
426
  static readonly FLAT_NUMBERS: readonly string[];
384
427
  static readonly FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
385
428
  static readonly SPECIAL_FLATS: readonly string[];
@@ -528,6 +571,8 @@ declare const entityListEntityModelMap: {
528
571
  transaction_history: typeof TransactionHistoryModel.populateFromEntity;
529
572
  sponsor: typeof SponsorModel.populateFromEntity;
530
573
  sponsor_history: typeof SponsorHistoryModel.populateFromEntity;
574
+ flat: typeof FlatModel.populateFromEntity;
575
+ flat_history: typeof FlatHistoryModel.populateFromEntity;
531
576
  configuration: typeof ConfigurationModel.populateFromEntity;
532
577
  };
533
578
 
@@ -770,10 +815,12 @@ declare enum EntityList {
770
815
  TRANSACTION_HISTORY = "transaction_history",
771
816
  SPONSOR = "sponsor",
772
817
  SPONSOR_HISTORY = "sponsor_history",
818
+ FLAT = "flat",
819
+ FLAT_HISTORY = "flat_history",
773
820
  CONFIGURATION = "configuration"
774
821
  }
775
- type EntityType<T extends EntityList> = T extends EntityList.DONATION ? IDonationEntity : T extends EntityList.DONATION_HISTORY ? IDonationHistoryEntity : T extends EntityList.USER ? IUserEntity : T extends EntityList.USER_HISTORY ? IUserHistoryEntity : T extends EntityList.EXPENSE ? IExpenseEntity : T extends EntityList.EXPENSE_HISTORY ? IExpenseHistoryEntity : T extends EntityList.VENDOR ? IVendorEntity : T extends EntityList.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityList.TRANSACTION ? ITransactionEntity : T extends EntityList.TRANSACTION_HISTORY ? ITransactionHistoryEntity : T extends EntityList.SPONSOR ? ISponsorEntity : T extends EntityList.SPONSOR_HISTORY ? ISponsorHistoryEntity : T extends EntityList.CONFIGURATION ? IConfigurationEntity : never;
776
- type EntityModelType<T extends EntityList> = T extends EntityList.DONATION ? DonationModel : T extends EntityList.DONATION_HISTORY ? DonationHistoryModel : T extends EntityList.USER ? UserModel : T extends EntityList.USER_HISTORY ? UserHistoryModel : T extends EntityList.EXPENSE ? ExpenseModel : T extends EntityList.EXPENSE_HISTORY ? ExpenseHistoryModel : T extends EntityList.VENDOR ? VendorModel : T extends EntityList.VENDOR_HISTORY ? VendorHistoryModel : T extends EntityList.TRANSACTION ? TransactionModel : T extends EntityList.TRANSACTION_HISTORY ? TransactionHistoryModel : T extends EntityList.SPONSOR ? SponsorModel : T extends EntityList.SPONSOR_HISTORY ? SponsorHistoryModel : T extends EntityList.CONFIGURATION ? ConfigurationModel : never;
822
+ type EntityType<T extends EntityList> = T extends EntityList.DONATION ? IDonationEntity : T extends EntityList.DONATION_HISTORY ? IDonationHistoryEntity : T extends EntityList.USER ? IUserEntity : T extends EntityList.USER_HISTORY ? IUserHistoryEntity : T extends EntityList.EXPENSE ? IExpenseEntity : T extends EntityList.EXPENSE_HISTORY ? IExpenseHistoryEntity : T extends EntityList.VENDOR ? IVendorEntity : T extends EntityList.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityList.TRANSACTION ? ITransactionEntity : T extends EntityList.TRANSACTION_HISTORY ? ITransactionHistoryEntity : T extends EntityList.SPONSOR ? ISponsorEntity : T extends EntityList.SPONSOR_HISTORY ? ISponsorHistoryEntity : T extends EntityList.FLAT ? IFlatEntity : T extends EntityList.FLAT_HISTORY ? IFlatHistoryEntity : T extends EntityList.CONFIGURATION ? IConfigurationEntity : never;
823
+ type EntityModelType<T extends EntityList> = T extends EntityList.DONATION ? DonationModel : T extends EntityList.DONATION_HISTORY ? DonationHistoryModel : T extends EntityList.USER ? UserModel : T extends EntityList.USER_HISTORY ? UserHistoryModel : T extends EntityList.EXPENSE ? ExpenseModel : T extends EntityList.EXPENSE_HISTORY ? ExpenseHistoryModel : T extends EntityList.VENDOR ? VendorModel : T extends EntityList.VENDOR_HISTORY ? VendorHistoryModel : T extends EntityList.TRANSACTION ? TransactionModel : T extends EntityList.TRANSACTION_HISTORY ? TransactionHistoryModel : T extends EntityList.SPONSOR ? SponsorModel : T extends EntityList.SPONSOR_HISTORY ? SponsorHistoryModel : T extends EntityList.FLAT ? FlatModel : T extends EntityList.FLAT_HISTORY ? FlatHistoryModel : T extends EntityList.CONFIGURATION ? ConfigurationModel : never;
777
824
  type EntityListEntityModelMap = {
778
825
  [T in EntityList]: EntityModelType<T>[];
779
826
  };
@@ -895,4 +942,25 @@ interface IConfigurationUpdateDto extends IEntityUpdateDto<EntityType<EntityList
895
942
  interface IConfigurationSearchDto extends IEntityFilterData<EntityType<EntityList.CONFIGURATION>> {
896
943
  }
897
944
 
898
- export { ALL_WINGS_SELECTION, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, FLATS_BY_WING, FLAT_NUMBERS, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatModel, type FlatOption, type FlatParseResult, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PAYMENT_OPTIONS, PaymentType, ReferenceIdPrefix, RelationType, SPECIAL_FLATS, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, WINGS, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, convertNumberToWords, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getObjectDiffingKeys, getWingSelectionLabel, getWingSelectionSlug, groupBy, serializeXlsx };
945
+ interface IFlatCreateDto extends IEntityCreateDto<EntityType<EntityList.FLAT>> {
946
+ }
947
+ interface IFlatUpdateDto extends IEntityUpdateDto<EntityType<EntityList.FLAT>> {
948
+ }
949
+ interface IFlatSearchDto extends IEntityFilterData<EntityType<EntityList.FLAT>> {
950
+ }
951
+
952
+ declare const FLAT_WING_PATTERN: RegExp;
953
+ declare const SHOP_WING = "SH";
954
+ declare const SPECIAL_FLAT_LABELS: readonly ["Devotee", "Ex-Member Devotee", "Others"];
955
+ declare const FLAT_UNIT_NUMBER_PATTERN: RegExp;
956
+ declare const SHOP_UNIT_NUMBER_PATTERN: RegExp;
957
+ type FlatValidationError = {
958
+ key: string;
959
+ message: string;
960
+ };
961
+ declare function isValidFlatWing(wing: string | null | undefined): boolean;
962
+ declare function isSpecialFlatLabel(label: string): boolean;
963
+ declare function getFlatValidationErrors(input: Partial<IFlatEntity>): FlatValidationError[];
964
+ declare function validateFlatOrThrow(input: Partial<IFlatEntity>): void;
965
+
966
+ export { ALL_WINGS_SELECTION, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, FLATS_BY_WING, FLAT_NUMBERS, FLAT_UNIT_NUMBER_PATTERN, FLAT_WING_PATTERN, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatHistoryModel, FlatModel, type FlatOption, type FlatParseResult, type FlatValidationError, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IFlatCreateDto, type IFlatEntity, type IFlatHistoryEntity, type IFlatSearchDto, type IFlatUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PAYMENT_OPTIONS, PaymentType, ReferenceIdPrefix, RelationType, SHOP_UNIT_NUMBER_PATTERN, SHOP_WING, SPECIAL_FLATS, SPECIAL_FLAT_LABELS, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, WINGS, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, convertNumberToWords, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getFlatValidationErrors, getObjectDiffingKeys, getWingSelectionLabel, getWingSelectionSlug, groupBy, isSpecialFlatLabel, isValidFlatWing, serializeXlsx, validateFlatOrThrow };
package/dist/index.js CHANGED
@@ -49,6 +49,9 @@ __export(index_exports, {
49
49
  ExpenseType: () => ExpenseType,
50
50
  FLATS_BY_WING: () => FLATS_BY_WING,
51
51
  FLAT_NUMBERS: () => FLAT_NUMBERS,
52
+ FLAT_UNIT_NUMBER_PATTERN: () => FLAT_UNIT_NUMBER_PATTERN,
53
+ FLAT_WING_PATTERN: () => FLAT_WING_PATTERN,
54
+ FlatHistoryModel: () => FlatHistoryModel,
52
55
  FlatModel: () => FlatModel,
53
56
  ForbiddenException: () => ForbiddenException,
54
57
  HttpException: () => HttpException,
@@ -58,7 +61,10 @@ __export(index_exports, {
58
61
  PaymentType: () => PaymentType,
59
62
  ReferenceIdPrefix: () => ReferenceIdPrefix,
60
63
  RelationType: () => RelationType,
64
+ SHOP_UNIT_NUMBER_PATTERN: () => SHOP_UNIT_NUMBER_PATTERN,
65
+ SHOP_WING: () => SHOP_WING,
61
66
  SPECIAL_FLATS: () => SPECIAL_FLATS,
67
+ SPECIAL_FLAT_LABELS: () => SPECIAL_FLAT_LABELS,
62
68
  SponsorHistoryModel: () => SponsorHistoryModel,
63
69
  SponsorModel: () => SponsorModel,
64
70
  SponsorTier: () => SponsorTier,
@@ -84,11 +90,15 @@ __export(index_exports, {
84
90
  diffArrays: () => diffArrays,
85
91
  entityListEntityModelMap: () => entityListEntityModelMap,
86
92
  epochToReadableDate: () => epochToReadableDate,
93
+ getFlatValidationErrors: () => getFlatValidationErrors,
87
94
  getObjectDiffingKeys: () => getObjectDiffingKeys,
88
95
  getWingSelectionLabel: () => getWingSelectionLabel,
89
96
  getWingSelectionSlug: () => getWingSelectionSlug,
90
97
  groupBy: () => groupBy,
91
- serializeXlsx: () => serializeXlsx
98
+ isSpecialFlatLabel: () => isSpecialFlatLabel,
99
+ isValidFlatWing: () => isValidFlatWing,
100
+ serializeXlsx: () => serializeXlsx,
101
+ validateFlatOrThrow: () => validateFlatOrThrow
92
102
  });
93
103
  module.exports = __toCommonJS(index_exports);
94
104
 
@@ -898,6 +908,26 @@ _ExpenseModel.relations = {
898
908
  };
899
909
  var ExpenseModel = _ExpenseModel;
900
910
 
911
+ // src/models/flat-history.entity.model.ts
912
+ var _FlatHistoryModel = class _FlatHistoryModel extends BaseEntityModel {
913
+ constructor() {
914
+ super();
915
+ this.id = 0;
916
+ this.entityId = 0;
917
+ this.data = "";
918
+ this.operation = "CREATE" /* CREATE */;
919
+ this.createdOn = 0;
920
+ this.updatedOn = 0;
921
+ this.createdBy = 0;
922
+ this.updatedBy = 0;
923
+ }
924
+ static populateFromEntity(entity) {
925
+ return Object.assign(new _FlatHistoryModel(), entity);
926
+ }
927
+ };
928
+ _FlatHistoryModel.relations = {};
929
+ var FlatHistoryModel = _FlatHistoryModel;
930
+
901
931
  // src/utils/numberToWords.ts
902
932
  function convertNumberToWords(num) {
903
933
  if (num === 0) return "Zero Rupees Only";
@@ -981,6 +1011,19 @@ function convertNumberToWords(num) {
981
1011
 
982
1012
  // src/models/flat.entity.model.ts
983
1013
  var _FlatModel = class _FlatModel {
1014
+ constructor() {
1015
+ this.id = 0;
1016
+ this.wing = "";
1017
+ this.unitNumber = "";
1018
+ this.status = "Active" /* ACTIVE */;
1019
+ this.createdOn = 0;
1020
+ this.updatedOn = 0;
1021
+ this.createdBy = 0;
1022
+ this.updatedBy = 0;
1023
+ }
1024
+ static populateFromEntity(entity) {
1025
+ return Object.assign(new _FlatModel(), entity);
1026
+ }
984
1027
  static getDonationYear() {
985
1028
  return (/* @__PURE__ */ new Date()).getFullYear();
986
1029
  }
@@ -1350,6 +1393,8 @@ var EntityList = /* @__PURE__ */ ((EntityList2) => {
1350
1393
  EntityList2["TRANSACTION_HISTORY"] = "transaction_history";
1351
1394
  EntityList2["SPONSOR"] = "sponsor";
1352
1395
  EntityList2["SPONSOR_HISTORY"] = "sponsor_history";
1396
+ EntityList2["FLAT"] = "flat";
1397
+ EntityList2["FLAT_HISTORY"] = "flat_history";
1353
1398
  EntityList2["CONFIGURATION"] = "configuration";
1354
1399
  return EntityList2;
1355
1400
  })(EntityList || {});
@@ -1368,6 +1413,8 @@ var entityListEntityModelMap = {
1368
1413
  ["transaction_history" /* TRANSACTION_HISTORY */]: TransactionHistoryModel.populateFromEntity,
1369
1414
  ["sponsor" /* SPONSOR */]: SponsorModel.populateFromEntity,
1370
1415
  ["sponsor_history" /* SPONSOR_HISTORY */]: SponsorHistoryModel.populateFromEntity,
1416
+ ["flat" /* FLAT */]: FlatModel.populateFromEntity,
1417
+ ["flat_history" /* FLAT_HISTORY */]: FlatHistoryModel.populateFromEntity,
1371
1418
  ["configuration" /* CONFIGURATION */]: ConfigurationModel.populateFromEntity
1372
1419
  };
1373
1420
 
@@ -1855,6 +1902,79 @@ var USER_RELATION_CONFIG = {
1855
1902
  name: "user" /* USER */,
1856
1903
  columnKeys: ["id", "name"]
1857
1904
  };
1905
+
1906
+ // src/validators/flat.validator.ts
1907
+ var FLAT_WING_PATTERN = /^[A-Z]$/;
1908
+ var SHOP_WING = "SH";
1909
+ var SPECIAL_FLAT_LABELS = [
1910
+ "Devotee",
1911
+ "Ex-Member Devotee",
1912
+ "Others"
1913
+ ];
1914
+ var FLAT_UNIT_NUMBER_PATTERN = /^[0-9]{1,3}[A-Za-z]?$/;
1915
+ var SHOP_UNIT_NUMBER_PATTERN = /^[0-9]{1,4}$/;
1916
+ function isValidFlatWing(wing) {
1917
+ if (wing == null) return true;
1918
+ if (wing === SHOP_WING) return true;
1919
+ return FLAT_WING_PATTERN.test(wing);
1920
+ }
1921
+ function isSpecialFlatLabel(label) {
1922
+ return SPECIAL_FLAT_LABELS.includes(label);
1923
+ }
1924
+ function getFlatValidationErrors(input) {
1925
+ const errors = [];
1926
+ const wing = input.wing ?? null;
1927
+ const unitNumber = input.unitNumber ?? "";
1928
+ if (!isValidFlatWing(wing)) {
1929
+ errors.push({
1930
+ key: "wing",
1931
+ message: `Invalid wing "${input.wing}". Wing must be null, a single letter A-Z, or "${SHOP_WING}".`
1932
+ });
1933
+ }
1934
+ if (unitNumber.length === 0) {
1935
+ errors.push({
1936
+ key: "unitNumber",
1937
+ message: "unitNumber is required."
1938
+ });
1939
+ return errors;
1940
+ }
1941
+ if (wing == null) {
1942
+ if (!isSpecialFlatLabel(unitNumber)) {
1943
+ errors.push({
1944
+ key: "unitNumber",
1945
+ message: `Wing is null, so unitNumber must be one of the special flat labels: ${SPECIAL_FLAT_LABELS.join(", ")}.`
1946
+ });
1947
+ }
1948
+ } else if (wing === SHOP_WING) {
1949
+ if (!SHOP_UNIT_NUMBER_PATTERN.test(unitNumber)) {
1950
+ errors.push({
1951
+ key: "unitNumber",
1952
+ message: `Invalid shop unitNumber "${unitNumber}". Must be numeric (e.g. "12").`
1953
+ });
1954
+ }
1955
+ } else if (!FLAT_UNIT_NUMBER_PATTERN.test(unitNumber)) {
1956
+ errors.push({
1957
+ key: "unitNumber",
1958
+ message: `Invalid flat unitNumber "${unitNumber}". Must match the format 1-3 digits with an optional letter suffix (e.g. "101", "101A").`
1959
+ });
1960
+ }
1961
+ if (input.status != null && !Object.values(EntityStatus).includes(input.status)) {
1962
+ errors.push({
1963
+ key: "status",
1964
+ message: `Invalid status "${input.status}". Allowed: ${Object.values(EntityStatus).join(", ")}.`
1965
+ });
1966
+ }
1967
+ return errors;
1968
+ }
1969
+ function validateFlatOrThrow(input) {
1970
+ const errors = getFlatValidationErrors(input);
1971
+ if (errors.length > 0) {
1972
+ throw new BadRequestException(
1973
+ errors.map((e) => e.message),
1974
+ errors
1975
+ );
1976
+ }
1977
+ }
1858
1978
  // Annotate the CommonJS export names for ESM import in node:
1859
1979
  0 && (module.exports = {
1860
1980
  ALL_WINGS_SELECTION,
@@ -1876,6 +1996,9 @@ var USER_RELATION_CONFIG = {
1876
1996
  ExpenseType,
1877
1997
  FLATS_BY_WING,
1878
1998
  FLAT_NUMBERS,
1999
+ FLAT_UNIT_NUMBER_PATTERN,
2000
+ FLAT_WING_PATTERN,
2001
+ FlatHistoryModel,
1879
2002
  FlatModel,
1880
2003
  ForbiddenException,
1881
2004
  HttpException,
@@ -1885,7 +2008,10 @@ var USER_RELATION_CONFIG = {
1885
2008
  PaymentType,
1886
2009
  ReferenceIdPrefix,
1887
2010
  RelationType,
2011
+ SHOP_UNIT_NUMBER_PATTERN,
2012
+ SHOP_WING,
1888
2013
  SPECIAL_FLATS,
2014
+ SPECIAL_FLAT_LABELS,
1889
2015
  SponsorHistoryModel,
1890
2016
  SponsorModel,
1891
2017
  SponsorTier,
@@ -1911,10 +2037,14 @@ var USER_RELATION_CONFIG = {
1911
2037
  diffArrays,
1912
2038
  entityListEntityModelMap,
1913
2039
  epochToReadableDate,
2040
+ getFlatValidationErrors,
1914
2041
  getObjectDiffingKeys,
1915
2042
  getWingSelectionLabel,
1916
2043
  getWingSelectionSlug,
1917
2044
  groupBy,
1918
- serializeXlsx
2045
+ isSpecialFlatLabel,
2046
+ isValidFlatWing,
2047
+ serializeXlsx,
2048
+ validateFlatOrThrow
1919
2049
  });
1920
2050
  //# sourceMappingURL=index.js.map