-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.go
49 lines (43 loc) · 827 Bytes
/
payment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package datastore
import (
"time"
"github.com/google/uuid"
)
type PaymentStatus int
const (
PaymentStatusInit PaymentStatus = iota
PaymentStatusPending
PaymentStatusSuccess
PaymentStatusError
PaymentStatusDelinquent
)
type Payment struct {
ID int64
GUID uuid.UUID
Amount float64
Status PaymentStatus
PaymentAt time.Time
BorrowerID int64
LenderID int64
Breakdown interface{} // Not Yet Implemented
CreatedAt time.Time
UpdatedAt time.Time
}
func (d datastore) GetPayments(loanID int64) (payments []Payment, err error) {
rows, err := d.Query(`
SELECT
id, guid, loan_id, iso_currency_code, amount, status, borrower_id,
created_at, updated_at
FROM
payments
WHERE
loan_id = $1
ORDER BY
id desc;
`, loanID)
defer rows.Close()
if err != nil {
return
}
return
}