Skip to content

Commit

Permalink
変数名修正financialRecordList
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubosaka committed Jan 9, 2025
1 parent 08658b9 commit 38c277b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions api/internals/usecase/financial_record_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (fru *financialRecordUseCase) GetFinancialRecords(
c context.Context,
) (FinancialRecordDetails, error) {
var financialRecordDetails FinancialRecordDetails
var financialRecordList []FinancialRecordWithBalance
var financialRecords []FinancialRecordWithBalance
var total Total

rows, err := fru.rep.All(c)
Expand All @@ -64,15 +64,15 @@ func (fru *financialRecordUseCase) GetFinancialRecords(
if err != nil {
return financialRecordDetails, errors.Wrapf(err, "can not connect SQL")
}
financialRecordList = append(financialRecordList, financialRecord)
financialRecords = append(financialRecords, financialRecord)
}

// totalを求める
budgetTotal := 0
expenseTotal := 0
balanceTotal := 0

for _, financialRecord := range financialRecordList {
for _, financialRecord := range financialRecords {
budgetTotal += *financialRecord.Budget
expenseTotal += *financialRecord.Expense
balanceTotal += *financialRecord.Balance
Expand All @@ -83,7 +83,7 @@ func (fru *financialRecordUseCase) GetFinancialRecords(
total.Balance = &balanceTotal

financialRecordDetails.Total = &total
financialRecordDetails.FinancialRecords = &financialRecordList
financialRecordDetails.FinancialRecords = &financialRecords

return financialRecordDetails, err
}
Expand All @@ -93,7 +93,7 @@ func (fru *financialRecordUseCase) GetFinancialRecordsByYears(
year string,
) (FinancialRecordDetails, error) {
var financialRecordDetails FinancialRecordDetails
var financialRecordList []FinancialRecordWithBalance
var financialRecords []FinancialRecordWithBalance
var total Total

rows, err := fru.rep.AllByPeriod(c, year)
Expand All @@ -117,15 +117,15 @@ func (fru *financialRecordUseCase) GetFinancialRecordsByYears(
if err != nil {
return financialRecordDetails, errors.Wrapf(err, "can not connect SQL")
}
financialRecordList = append(financialRecordList, financialRecord)
financialRecords = append(financialRecords, financialRecord)
}

// totalを求める
budgetTotal := 0
expenseTotal := 0
balanceTotal := 0

for _, financialRecord := range financialRecordList {
for _, financialRecord := range financialRecords {
budgetTotal += *financialRecord.Budget
expenseTotal += *financialRecord.Expense
balanceTotal += *financialRecord.Balance
Expand All @@ -136,7 +136,7 @@ func (fru *financialRecordUseCase) GetFinancialRecordsByYears(
total.Balance = &balanceTotal

financialRecordDetails.Total = &total
financialRecordDetails.FinancialRecords = &financialRecordList
financialRecordDetails.FinancialRecords = &financialRecords

return financialRecordDetails, err
}
Expand Down

0 comments on commit 38c277b

Please sign in to comment.