@mody-park-cha-raja/finance_common 4.27.1-beta.2 → 4.27.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -123,7 +123,6 @@ interface IDonationEntity extends IAuditColumnEntity {
123
123
  id: number;
124
124
  receiptNumber: string;
125
125
  flatNo: string;
126
- flatId: number;
127
126
  amount: number;
128
127
  mobileNumber?: string;
129
128
  paymentType: PaymentType;
@@ -293,69 +292,10 @@ declare class UserModel extends BaseEntityModel implements IUserEntity {
293
292
  static populateFromEntity(entity: IUserEntity): UserModel;
294
293
  }
295
294
 
296
- interface FlatDonationLike {
297
- flatNo: string;
298
- amount: number;
299
- donationYear?: number;
300
- createdOn?: number;
301
- createdByUser?: Nullable<{
302
- name?: string;
303
- }>;
304
- updatedByUser?: Nullable<{
305
- name?: string;
306
- }>;
307
- }
308
- type FlatCollectionStatus = "Paid" | "Pending";
309
- interface FlatCollectionEntry {
310
- flatNumber: string;
311
- status: FlatCollectionStatus;
312
- amount: number;
313
- latestDonation?: Nullable<FlatDonationLike>;
314
- }
315
- interface FlatParseResult {
316
- wing?: string;
317
- num?: string;
318
- isSpecial: boolean;
319
- }
320
- interface FlatOption {
321
- label: string;
322
- value: string;
323
- }
324
- declare class FlatModel {
325
- id: number;
326
- wing: string;
327
- unitNumber: string;
328
- status: EntityStatus;
329
- createdOn: number;
330
- updatedOn: number;
331
- createdBy: number;
332
- updatedBy: number;
333
- static populateFromEntity(entity: IFlatEntity): FlatModel;
334
- createdByUser?: UserModel;
335
- updatedByUser?: UserModel;
336
- donations?: DonationModel[];
337
- static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
338
- static readonly FLAT_NUMBERS: readonly string[];
339
- static readonly FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
340
- static readonly SPECIAL_FLATS: readonly string[];
341
- static readonly WINGS: readonly string[];
342
- static getDonationYear(): number;
343
- static getTotalFlats(): number;
344
- static buildFlatNumber(wing: string, num: string): string;
345
- static isSpecialFlat(flatNo: string): boolean;
346
- static parseFlatNumber(flatNo: string): FlatParseResult;
347
- static getFlatOptions(wing: string): FlatOption[];
348
- static getDisplayLabel(wing: string, flatNo: string): string;
349
- static computeCollectionStatus(donations: FlatDonationLike[], year: number): FlatCollectionEntry[];
350
- static compareFlatNumbers(a: string, b: string): number;
351
- static convertNumberToWords(num: number): string;
352
- }
353
-
354
295
  declare class DonationModel extends BaseEntityModel implements IDonationEntity {
355
296
  id: number;
356
297
  receiptNumber: string;
357
298
  flatNo: string;
358
- flatId: number;
359
299
  amount: number;
360
300
  mobileNumber?: string;
361
301
  paymentType: PaymentType;
@@ -367,10 +307,20 @@ declare class DonationModel extends BaseEntityModel implements IDonationEntity {
367
307
  updatedBy: number;
368
308
  createdByUser?: UserModel;
369
309
  updatedByUser?: UserModel;
370
- flat?: FlatModel;
371
310
  protected constructor();
372
311
  static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
373
312
  static populateFromEntity(entity: IDonationEntity): DonationModel;
313
+ /**
314
+ * Sums the `amount` of all ACTIVE donations in the given list.
315
+ * The list is always `DonationModel[]`.
316
+ *
317
+ * @param donations - The list of DonationModels to sum
318
+ * @returns The total amount of all `EntityStatus.ACTIVE` donations (0 for empty lists)
319
+ *
320
+ * @example
321
+ * DonationModel.sumActiveDonations(donations); // 12345
322
+ */
323
+ static sumActiveDonations(donations: DonationModel[]): number;
374
324
  static getReceiptPrefix(flatNo: string): string;
375
325
  static generateReceiptNumber(flatNo: string, existingDonations: DonationModel[]): string;
376
326
  static toWhatsAppNumber(mobile: string): string;
@@ -446,6 +396,60 @@ declare class FlatHistoryModel extends BaseEntityModel implements IFlatHistoryEn
446
396
  static populateFromEntity(entity: IFlatHistoryEntity): FlatHistoryModel;
447
397
  }
448
398
 
399
+ interface FlatDonationLike {
400
+ flatNo: string;
401
+ amount: number;
402
+ donationYear?: number;
403
+ createdOn?: number;
404
+ createdByUser?: Nullable<{
405
+ name?: string;
406
+ }>;
407
+ updatedByUser?: Nullable<{
408
+ name?: string;
409
+ }>;
410
+ }
411
+ type FlatCollectionStatus = "Paid" | "Pending";
412
+ interface FlatCollectionEntry {
413
+ flatNumber: string;
414
+ status: FlatCollectionStatus;
415
+ amount: number;
416
+ latestDonation?: Nullable<FlatDonationLike>;
417
+ }
418
+ interface FlatParseResult {
419
+ wing?: string;
420
+ num?: string;
421
+ isSpecial: boolean;
422
+ }
423
+ interface FlatOption {
424
+ label: string;
425
+ value: string;
426
+ }
427
+ declare class FlatModel {
428
+ id: number;
429
+ wing: string;
430
+ unitNumber: string;
431
+ status: EntityStatus;
432
+ createdOn: number;
433
+ updatedOn: number;
434
+ createdBy: number;
435
+ updatedBy: number;
436
+ static populateFromEntity(entity: IFlatEntity): FlatModel;
437
+ static readonly FLAT_NUMBERS: readonly string[];
438
+ static readonly FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
439
+ static readonly SPECIAL_FLATS: readonly string[];
440
+ static readonly WINGS: readonly string[];
441
+ static getDonationYear(): number;
442
+ static getTotalFlats(): number;
443
+ static buildFlatNumber(wing: string, num: string): string;
444
+ static isSpecialFlat(flatNo: string): boolean;
445
+ static parseFlatNumber(flatNo: string): FlatParseResult;
446
+ static getFlatOptions(wing: string): FlatOption[];
447
+ static getDisplayLabel(wing: string, flatNo: string): string;
448
+ static computeCollectionStatus(donations: FlatDonationLike[], year: number): FlatCollectionEntry[];
449
+ static compareFlatNumbers(a: string, b: string): number;
450
+ static convertNumberToWords(num: number): string;
451
+ }
452
+
449
453
  declare class SponsorHistoryModel extends BaseEntityModel implements ISponsorHistoryEntity {
450
454
  id: number;
451
455
  entityId: number;
@@ -685,6 +689,19 @@ declare function definedValues<T>(arr: Array<Nullable<T> | undefined>): T[];
685
689
  * epochToReadableDate(1700000000000); // "2023-11-14T18:13:20.000Z"
686
690
  */
687
691
  declare function epochToReadableDate(epoch: number | string, format?: "short" | "long" | "short-dt" | "iso"): string;
692
+ /**
693
+ * Rounds a number to exactly 2 decimal places.
694
+ * Uses `Number.EPSILON` to avoid common float artifacts
695
+ * (e.g. `305.4999999` incorrectly rounding down).
696
+ *
697
+ * @param value - The number to round
698
+ * @returns The number rounded to 2 decimal places (still a number, format per-platform afterwards)
699
+ *
700
+ * @example
701
+ * roundToTwoDecimals(305.49999); // 305.5
702
+ * roundToTwoDecimals(100.125); // 100.13
703
+ */
704
+ declare function roundToTwoDecimals(value: number): number;
688
705
 
689
706
  declare function convertNumberToWords(num: number): string;
690
707
 
@@ -970,4 +987,4 @@ declare function isSpecialFlatLabel(label: string): boolean;
970
987
  declare function getFlatValidationErrors(input: Partial<IFlatEntity>): FlatValidationError[];
971
988
  declare function validateFlatOrThrow(input: Partial<IFlatEntity>): void;
972
989
 
973
- 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 };
990
+ 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, roundToTwoDecimals, serializeXlsx, validateFlatOrThrow };
package/dist/index.d.ts CHANGED
@@ -123,7 +123,6 @@ interface IDonationEntity extends IAuditColumnEntity {
123
123
  id: number;
124
124
  receiptNumber: string;
125
125
  flatNo: string;
126
- flatId: number;
127
126
  amount: number;
128
127
  mobileNumber?: string;
129
128
  paymentType: PaymentType;
@@ -293,69 +292,10 @@ declare class UserModel extends BaseEntityModel implements IUserEntity {
293
292
  static populateFromEntity(entity: IUserEntity): UserModel;
294
293
  }
295
294
 
296
- interface FlatDonationLike {
297
- flatNo: string;
298
- amount: number;
299
- donationYear?: number;
300
- createdOn?: number;
301
- createdByUser?: Nullable<{
302
- name?: string;
303
- }>;
304
- updatedByUser?: Nullable<{
305
- name?: string;
306
- }>;
307
- }
308
- type FlatCollectionStatus = "Paid" | "Pending";
309
- interface FlatCollectionEntry {
310
- flatNumber: string;
311
- status: FlatCollectionStatus;
312
- amount: number;
313
- latestDonation?: Nullable<FlatDonationLike>;
314
- }
315
- interface FlatParseResult {
316
- wing?: string;
317
- num?: string;
318
- isSpecial: boolean;
319
- }
320
- interface FlatOption {
321
- label: string;
322
- value: string;
323
- }
324
- declare class FlatModel {
325
- id: number;
326
- wing: string;
327
- unitNumber: string;
328
- status: EntityStatus;
329
- createdOn: number;
330
- updatedOn: number;
331
- createdBy: number;
332
- updatedBy: number;
333
- static populateFromEntity(entity: IFlatEntity): FlatModel;
334
- createdByUser?: UserModel;
335
- updatedByUser?: UserModel;
336
- donations?: DonationModel[];
337
- static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
338
- static readonly FLAT_NUMBERS: readonly string[];
339
- static readonly FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
340
- static readonly SPECIAL_FLATS: readonly string[];
341
- static readonly WINGS: readonly string[];
342
- static getDonationYear(): number;
343
- static getTotalFlats(): number;
344
- static buildFlatNumber(wing: string, num: string): string;
345
- static isSpecialFlat(flatNo: string): boolean;
346
- static parseFlatNumber(flatNo: string): FlatParseResult;
347
- static getFlatOptions(wing: string): FlatOption[];
348
- static getDisplayLabel(wing: string, flatNo: string): string;
349
- static computeCollectionStatus(donations: FlatDonationLike[], year: number): FlatCollectionEntry[];
350
- static compareFlatNumbers(a: string, b: string): number;
351
- static convertNumberToWords(num: number): string;
352
- }
353
-
354
295
  declare class DonationModel extends BaseEntityModel implements IDonationEntity {
355
296
  id: number;
356
297
  receiptNumber: string;
357
298
  flatNo: string;
358
- flatId: number;
359
299
  amount: number;
360
300
  mobileNumber?: string;
361
301
  paymentType: PaymentType;
@@ -367,10 +307,20 @@ declare class DonationModel extends BaseEntityModel implements IDonationEntity {
367
307
  updatedBy: number;
368
308
  createdByUser?: UserModel;
369
309
  updatedByUser?: UserModel;
370
- flat?: FlatModel;
371
310
  protected constructor();
372
311
  static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
373
312
  static populateFromEntity(entity: IDonationEntity): DonationModel;
313
+ /**
314
+ * Sums the `amount` of all ACTIVE donations in the given list.
315
+ * The list is always `DonationModel[]`.
316
+ *
317
+ * @param donations - The list of DonationModels to sum
318
+ * @returns The total amount of all `EntityStatus.ACTIVE` donations (0 for empty lists)
319
+ *
320
+ * @example
321
+ * DonationModel.sumActiveDonations(donations); // 12345
322
+ */
323
+ static sumActiveDonations(donations: DonationModel[]): number;
374
324
  static getReceiptPrefix(flatNo: string): string;
375
325
  static generateReceiptNumber(flatNo: string, existingDonations: DonationModel[]): string;
376
326
  static toWhatsAppNumber(mobile: string): string;
@@ -446,6 +396,60 @@ declare class FlatHistoryModel extends BaseEntityModel implements IFlatHistoryEn
446
396
  static populateFromEntity(entity: IFlatHistoryEntity): FlatHistoryModel;
447
397
  }
448
398
 
399
+ interface FlatDonationLike {
400
+ flatNo: string;
401
+ amount: number;
402
+ donationYear?: number;
403
+ createdOn?: number;
404
+ createdByUser?: Nullable<{
405
+ name?: string;
406
+ }>;
407
+ updatedByUser?: Nullable<{
408
+ name?: string;
409
+ }>;
410
+ }
411
+ type FlatCollectionStatus = "Paid" | "Pending";
412
+ interface FlatCollectionEntry {
413
+ flatNumber: string;
414
+ status: FlatCollectionStatus;
415
+ amount: number;
416
+ latestDonation?: Nullable<FlatDonationLike>;
417
+ }
418
+ interface FlatParseResult {
419
+ wing?: string;
420
+ num?: string;
421
+ isSpecial: boolean;
422
+ }
423
+ interface FlatOption {
424
+ label: string;
425
+ value: string;
426
+ }
427
+ declare class FlatModel {
428
+ id: number;
429
+ wing: string;
430
+ unitNumber: string;
431
+ status: EntityStatus;
432
+ createdOn: number;
433
+ updatedOn: number;
434
+ createdBy: number;
435
+ updatedBy: number;
436
+ static populateFromEntity(entity: IFlatEntity): FlatModel;
437
+ static readonly FLAT_NUMBERS: readonly string[];
438
+ static readonly FLATS_BY_WING: ReadonlyMap<string, readonly string[]>;
439
+ static readonly SPECIAL_FLATS: readonly string[];
440
+ static readonly WINGS: readonly string[];
441
+ static getDonationYear(): number;
442
+ static getTotalFlats(): number;
443
+ static buildFlatNumber(wing: string, num: string): string;
444
+ static isSpecialFlat(flatNo: string): boolean;
445
+ static parseFlatNumber(flatNo: string): FlatParseResult;
446
+ static getFlatOptions(wing: string): FlatOption[];
447
+ static getDisplayLabel(wing: string, flatNo: string): string;
448
+ static computeCollectionStatus(donations: FlatDonationLike[], year: number): FlatCollectionEntry[];
449
+ static compareFlatNumbers(a: string, b: string): number;
450
+ static convertNumberToWords(num: number): string;
451
+ }
452
+
449
453
  declare class SponsorHistoryModel extends BaseEntityModel implements ISponsorHistoryEntity {
450
454
  id: number;
451
455
  entityId: number;
@@ -685,6 +689,19 @@ declare function definedValues<T>(arr: Array<Nullable<T> | undefined>): T[];
685
689
  * epochToReadableDate(1700000000000); // "2023-11-14T18:13:20.000Z"
686
690
  */
687
691
  declare function epochToReadableDate(epoch: number | string, format?: "short" | "long" | "short-dt" | "iso"): string;
692
+ /**
693
+ * Rounds a number to exactly 2 decimal places.
694
+ * Uses `Number.EPSILON` to avoid common float artifacts
695
+ * (e.g. `305.4999999` incorrectly rounding down).
696
+ *
697
+ * @param value - The number to round
698
+ * @returns The number rounded to 2 decimal places (still a number, format per-platform afterwards)
699
+ *
700
+ * @example
701
+ * roundToTwoDecimals(305.49999); // 305.5
702
+ * roundToTwoDecimals(100.125); // 100.13
703
+ */
704
+ declare function roundToTwoDecimals(value: number): number;
688
705
 
689
706
  declare function convertNumberToWords(num: number): string;
690
707
 
@@ -970,4 +987,4 @@ declare function isSpecialFlatLabel(label: string): boolean;
970
987
  declare function getFlatValidationErrors(input: Partial<IFlatEntity>): FlatValidationError[];
971
988
  declare function validateFlatOrThrow(input: Partial<IFlatEntity>): void;
972
989
 
973
- 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 };
990
+ 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, roundToTwoDecimals, serializeXlsx, validateFlatOrThrow };
package/dist/index.js CHANGED
@@ -97,6 +97,7 @@ __export(index_exports, {
97
97
  groupBy: () => groupBy,
98
98
  isSpecialFlatLabel: () => isSpecialFlatLabel,
99
99
  isValidFlatWing: () => isValidFlatWing,
100
+ roundToTwoDecimals: () => roundToTwoDecimals,
100
101
  serializeXlsx: () => serializeXlsx,
101
102
  validateFlatOrThrow: () => validateFlatOrThrow
102
103
  });
@@ -789,7 +790,6 @@ var _DonationModel = class _DonationModel extends BaseEntityModel {
789
790
  this.id = 0;
790
791
  this.receiptNumber = "";
791
792
  this.flatNo = "";
792
- this.flatId = 0;
793
793
  this.amount = 0;
794
794
  this.paymentType = "Cash" /* CASH */;
795
795
  this.status = "Active" /* ACTIVE */;
@@ -804,6 +804,19 @@ var _DonationModel = class _DonationModel extends BaseEntityModel {
804
804
  amount: Number(entity.amount)
805
805
  });
806
806
  }
807
+ /**
808
+ * Sums the `amount` of all ACTIVE donations in the given list.
809
+ * The list is always `DonationModel[]`.
810
+ *
811
+ * @param donations - The list of DonationModels to sum
812
+ * @returns The total amount of all `EntityStatus.ACTIVE` donations (0 for empty lists)
813
+ *
814
+ * @example
815
+ * DonationModel.sumActiveDonations(donations); // 12345
816
+ */
817
+ static sumActiveDonations(donations) {
818
+ return donations.filter((d) => d.status === "Active" /* ACTIVE */).reduce((sum, d) => sum + Number(d.amount), 0);
819
+ }
807
820
  static getReceiptPrefix(flatNo) {
808
821
  const year = (/* @__PURE__ */ new Date()).getFullYear();
809
822
  if (flatNo === "Devotee") return `MPCR-${year}-OD`;
@@ -834,12 +847,6 @@ _DonationModel.relations = {
834
847
  ],
835
848
  searchProperty: "id",
836
849
  entity: "user" /* USER */
837
- },
838
- ["flat" /* FLAT */]: {
839
- relationType: "ONE" /* ONE */,
840
- mappingProperties: [{ sourceProperty: "flatId", targetProperty: "flat" }],
841
- searchProperty: "id",
842
- entity: "flat" /* FLAT */
843
850
  }
844
851
  };
845
852
  var DonationModel = _DonationModel;
@@ -1113,25 +1120,6 @@ var _FlatModel = class _FlatModel {
1113
1120
  return convertNumberToWords(num);
1114
1121
  }
1115
1122
  };
1116
- _FlatModel.relations = {
1117
- ["user" /* USER */]: {
1118
- relationType: "ONE" /* ONE */,
1119
- mappingProperties: [
1120
- { sourceProperty: "createdBy", targetProperty: "createdByUser" },
1121
- { sourceProperty: "updatedBy", targetProperty: "updatedByUser" }
1122
- ],
1123
- searchProperty: "id",
1124
- entity: "user" /* USER */
1125
- },
1126
- ["donation" /* DONATION */]: {
1127
- relationType: "MANY" /* MANY */,
1128
- mappingProperties: [
1129
- { sourceProperty: "id", targetProperty: "donations" }
1130
- ],
1131
- searchProperty: "flatId",
1132
- entity: "donation" /* DONATION */
1133
- }
1134
- };
1135
1123
  _FlatModel.FLAT_NUMBERS = FLAT_NUMBERS;
1136
1124
  _FlatModel.FLATS_BY_WING = FLATS_BY_WING;
1137
1125
  _FlatModel.SPECIAL_FLATS = SPECIAL_FLATS;
@@ -1592,6 +1580,9 @@ function epochToReadableDate(epoch, format = "iso") {
1592
1580
  return date.toISOString();
1593
1581
  }
1594
1582
  }
1583
+ function roundToTwoDecimals(value) {
1584
+ return Math.round((value + Number.EPSILON) * 100) / 100;
1585
+ }
1595
1586
 
1596
1587
  // src/utils/relation-config.utils.ts
1597
1588
  var RelationType = /* @__PURE__ */ ((RelationType2) => {
@@ -2070,6 +2061,7 @@ function validateFlatOrThrow(input) {
2070
2061
  groupBy,
2071
2062
  isSpecialFlatLabel,
2072
2063
  isValidFlatWing,
2064
+ roundToTwoDecimals,
2073
2065
  serializeXlsx,
2074
2066
  validateFlatOrThrow
2075
2067
  });