Documentation
¶
Index ¶
- func CalculateNextInvoiceDate(lastInvoiceDate, now time.Time, period BillingPeriod) (*time.Time, bool)
- type Bill
- type Biller
- func (b *Biller) CreateInvoice(ctx context.Context, timeNow time.Time, bill *Bill) error
- func (b *Biller) CreateSchema(ctx context.Context, pool *pgxpool.Pool) error
- func (b *Biller) GetUnpaidInvoices(ctx context.Context) ([]*Invoice, error)
- func (b *Biller) RecordPayment(ctx context.Context, invoice *Invoice, meta interface{}, timeNow time.Time) error
- type BillingPeriod
- type Db
- type ErrResponse
- type Handler
- type IBillerDb
- type IHttpDb
- type IPaymentProvider
- type ISubscriptionProvider
- type ITimeProvider
- type Invoice
- type Payment
- type Scheduler
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bill ¶
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"`
}
type Biller ¶
type Biller struct {
// contains filtered or unexported fields
}
func (*Biller) CreateInvoice ¶
func (*Biller) CreateSchema ¶
CreateSchema creates the fsb schema and runs migrations
func (*Biller) GetUnpaidInvoices ¶
type BillingPeriod ¶
type BillingPeriod string
BillingPeriod represents the period of time for which a bill is generated It can be monthly, yearly
const ( PeriodMonthly BillingPeriod = "monthly" PeriodYearly BillingPeriod = "yearly" )
type ErrResponse ¶
type ErrResponse struct {
Error string `json:"error"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) GetInvoicePayments ¶
func (h *Handler) GetInvoicePayments(w http.ResponseWriter, r *http.Request)
func (*Handler) SetupRoutes ¶
type IPaymentProvider ¶
type ISubscriptionProvider ¶
type ITimeProvider ¶
type Invoice ¶
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 ¶
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"`
}
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func NewScheduler(tp ITimeProvider, biller *Biller, payment IPaymentProvider, subs ISubscriptionProvider) *Scheduler
func (*Scheduler) RunInvoiceJob ¶
func (*Scheduler) RunPaymentJob ¶
Click to show internal directories.
Click to hide internal directories.