-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
52 lines (45 loc) · 1.47 KB
/
types.go
File metadata and controls
52 lines (45 loc) · 1.47 KB
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
50
51
52
package fsb
import (
"encoding/json"
"github.com/google/uuid"
"github.com/shopspring/decimal"
"time"
)
// BillingPeriod represents the period of time for which a bill is generated
// It can be monthly, yearly
type BillingPeriod string
const (
PeriodMonthly BillingPeriod = "monthly"
PeriodYearly BillingPeriod = "yearly"
)
type Bill struct {
PartyId uuid.UUID `db:"party_id" json:"party_id"`
BillingPeriod BillingPeriod `db:"billing_period" json:"billing_period"`
Amount decimal.Decimal `db:"amount" json:"amount"`
}
func periodToDateTrunc(period BillingPeriod) string {
switch period {
case PeriodMonthly:
return "month"
case PeriodYearly:
return "year"
default:
return ""
}
}
type Invoice struct {
Id uuid.UUID `db:"id" json:"id"`
PartyId uuid.UUID `db:"party_id" json:"party_id"`
Amount decimal.Decimal `db:"amount" json:"amount"`
Meta *json.RawMessage `db:"meta" json:"meta" sql:"type:jsonb"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
DeletedAt *time.Time `db:"deleted_at" json:"deleted_at"`
}
type Payment struct {
Id uuid.UUID `db:"id" json:"id"`
InvoiceId uuid.UUID `db:"invoice_id" json:"invoice_id"`
Meta *json.RawMessage `db:"meta" json:"meta" sql:"type:jsonb"`
Success bool `db:"success" json:"success"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
DeletedAt *time.Time `db:"deleted_at" json:"deleted_at"`
}