fix(contribution-service): fix toRecordDto using wrong property name

- Changed `record.finalContribution` to `record.amount` for getting final contribution value
- Added optional chaining to prevent undefined errors
- Added default values for safety

The ContributionRecordAggregate uses `amount` property, not `finalContribution`.
This was causing "Cannot read properties of undefined (reading 'value')" errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-14 08:43:14 -08:00
parent ed9f817fae
commit f2692a50ed
1 changed files with 5 additions and 5 deletions

View File

@ -183,16 +183,16 @@ export class GetContributionAccountQuery {
private toRecordDto(record: any): ContributionRecordDto { private toRecordDto(record: any): ContributionRecordDto {
return { return {
id: record.id, id: record.id?.toString() ?? '',
sourceType: record.sourceType, sourceType: record.sourceType,
sourceAdoptionId: record.sourceAdoptionId, sourceAdoptionId: record.sourceAdoptionId?.toString() ?? '',
sourceAccountSequence: record.sourceAccountSequence, sourceAccountSequence: record.sourceAccountSequence,
treeCount: record.treeCount, treeCount: record.treeCount,
baseContribution: record.baseContribution.value.toString(), baseContribution: record.baseContribution?.value?.toString() ?? '0',
distributionRate: record.distributionRate.value.toString(), distributionRate: record.distributionRate?.value?.toString() ?? '0',
levelDepth: record.levelDepth, levelDepth: record.levelDepth,
bonusTier: record.bonusTier, bonusTier: record.bonusTier,
finalContribution: record.finalContribution.value.toString(), finalContribution: record.amount?.value?.toString() ?? '0',
effectiveDate: record.effectiveDate, effectiveDate: record.effectiveDate,
expireDate: record.expireDate, expireDate: record.expireDate,
isExpired: record.isExpired, isExpired: record.isExpired,