diff --git a/Screenshot 2026-09-30 at 13.53.59.png b/Screenshot 2026-09-30 at 13.53.59.png deleted file mode 100644 index ae595b6..0000000 Binary files a/Screenshot 2026-09-30 at 13.53.59.png and /dev/null differ diff --git a/internal/lending/loanpaidletter/db/postgresql.go b/internal/lending/loanpaidletter/db/postgresql.go index 518384d..3eaabb9 100644 --- a/internal/lending/loanpaidletter/db/postgresql.go +++ b/internal/lending/loanpaidletter/db/postgresql.go @@ -82,8 +82,9 @@ func (r *repository) List(ctx context.Context, filter loanpaidletter.ListFilter) limitPlaceholder := len(args) + 1 offsetPlaceholder := len(args) + 2 query := fmt.Sprintf( - `SELECT %s%s%s ORDER BY l.id DESC LIMIT $%d OFFSET $%d`, - letterSelectColumns, letterFromClause, whereClause, limitPlaceholder, offsetPlaceholder, + `SELECT l.id, l.unique_id, l.customer_name, l.customer_surname, l.phone, l.status + FROM loan_paid_off_letters l%s ORDER BY l.id DESC LIMIT $%d OFFSET $%d`, + whereClause, limitPlaceholder, offsetPlaceholder, ) rows, err := r.client.Query(ctx, query, append(args, filter.Limit, offset)...) @@ -92,10 +93,12 @@ func (r *repository) List(ctx context.Context, filter loanpaidletter.ListFilter) } defer rows.Close() - var items []loanpaidletter.LoanPaidLetterDTO + items := []loanpaidletter.LoanPaidLetterListItemDTO{} for rows.Next() { - item, err := scanLoanPaidLetter(rows) - if err != nil { + var item loanpaidletter.LoanPaidLetterListItemDTO + if err := rows.Scan( + &item.Id, &item.UniqueId, &item.CustomerName, &item.CustomerSurname, &item.Phone, &item.Status, + ); err != nil { return loanpaidletter.ListLoanPaidLetterDTO{}, err } items = append(items, item) diff --git a/internal/lending/loanpaidletter/dto.go b/internal/lending/loanpaidletter/dto.go index 0562e91..76c3950 100644 --- a/internal/lending/loanpaidletter/dto.go +++ b/internal/lending/loanpaidletter/dto.go @@ -89,9 +89,20 @@ type ListFilter struct { Limit int } +// LoanPaidLetterListItemDTO is the list row; branch, passport and loan +// details come from GET /loan-paid-off-letters/:id. +type LoanPaidLetterListItemDTO struct { + Id int64 `json:"id"` + UniqueId *string `json:"uniqueId"` + CustomerName string `json:"customerName"` + CustomerSurname string `json:"customerSurname"` + Phone string `json:"phone"` + Status *string `json:"status"` +} + type ListLoanPaidLetterDTO struct { - Count int64 `json:"count"` - LoanPaidLetters []LoanPaidLetterDTO `json:"loanPaidLetters"` + Count int64 `json:"count"` + LoanPaidLetters []LoanPaidLetterListItemDTO `json:"loanPaidLetters"` } // BranchByProvinceDTO is a compact branch row for province-scoped pickers.