Documentation
¶
Index ¶
- func CoverCredit(store PurchaseStore, existingPayment *ClaimPayment, ...) error
- func DebtBalanced(payments ...FinancialInstrument) (bool, int64)
- func PaymentBalanced(amount int64, payments ...FinancialInstrument) (bool, int64)
- func TransferClaims(storer PurchaseStore, source, target *Attendee, claims []SlotClaim) (*Attendee, *Attendee, error)
- type AssetType
- type Attendee
- type ClaimPayment
- type ErrInvalidCurrency
- type EventSlot
- type FinancialInstrument
- type PaymentMethodConferenceDiscount
- type PaymentMethodCreditNote
- type PaymentMethodMoney
- type PurchaseStore
- type SQLStorage
- func (s *SQLStorage) AtomicOperation() (func() error, func() error, PurchaseStore, error)
- func (s *SQLStorage) ChangeSlotClaimOwner(slots []SlotClaim, source *Attendee, target *Attendee) (*Attendee, *Attendee, error)
- func (s *SQLStorage) CreateAttendee(a *Attendee) (*Attendee, error)
- func (s *SQLStorage) CreateClaimPayment(c *ClaimPayment) (*ClaimPayment, error)
- func (s *SQLStorage) CreateEventSlot(e *EventSlot) (*EventSlot, error)
- func (s *SQLStorage) CreateSlotClaim(slotClaim *SlotClaim) (*SlotClaim, error)
- func (s *SQLStorage) ReadAttendeeByEmail(email string) (*Attendee, error)
- func (s *SQLStorage) ReadAttendeeByID(id uint64) (*Attendee, error)
- func (s *SQLStorage) ReadEventSlotByID(id uint64) (*EventSlot, error)
- func (s *SQLStorage) UpdateAttendee(attendee *Attendee) (*Attendee, error)
- func (s *SQLStorage) UpdateClaimPayment(c *ClaimPayment) (*ClaimPayment, error)
- func (s *SQLStorage) UpdateEventSlot(e *EventSlot) error
- type SlotClaim
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CoverCredit ¶
func CoverCredit(store PurchaseStore, existingPayment *ClaimPayment, payments []FinancialInstrument) error
CoverCredit adds funds to a payment to cover for receivables.
func DebtBalanced ¶
func DebtBalanced(payments ...FinancialInstrument) (bool, int64)
DebtBalanced returns true if all cretid notes or similar instruments have been covered or an amount if not.
func PaymentBalanced ¶
func PaymentBalanced(amount int64, payments ...FinancialInstrument) (bool, int64)
PaymentBalanced returns true or false depending on balancing status and missing payment amount if any.
func TransferClaims ¶
func TransferClaims(storer PurchaseStore, source, target *Attendee, claims []SlotClaim) (*Attendee, *Attendee, error)
TransferClaims transfer claims from one user the the other, assuming they belong to the first.
Types ¶
type AssetType ¶
type AssetType string
AssetType is a type of accounting asset.
const ( // ATCash in this context means it is money, like a stripe payment ATCash AssetType = "cash" // ATReceivable in this context means it is a promise of payment ATReceivable AssetType = "receivable" // ATDiscount in this context means an issued discount (represented as a fixed amount for // accounting's sake) ATDiscount AssetType = "discount" )
type Attendee ¶
type Attendee struct {
ID uint64 `gaum:"field_name:id"`
Email string `gaum:"field_name:email"`
// CoCAccepted, claims cannot be used without this.
CoCAccepted bool `gaum:"field_name:co_c_accepted"`
Claims []SlotClaim
}
Attendee is a person attending one or more Slots of the Conference.
type ClaimPayment ¶
type ClaimPayment struct {
ID uint64 `gaum:"field_name:id"`
// ClaimsPayed would be what in a bill one see as detail.
ClaimsPayed []*SlotClaim
Payment []FinancialInstrument
Invoice string `gaum:"field_name:invoice"` // let us fill this once we know how to invoice
}
ClaimPayment represents a payment for N claims
func PayClaims ¶
func PayClaims(store PurchaseStore, attendee *Attendee, claims []SlotClaim, payments []FinancialInstrument) (*ClaimPayment, error)
PayClaims assigns payments and/or credits to a set of claims.
func (*ClaimPayment) Fulfilled ¶
func (c *ClaimPayment) Fulfilled() bool
Fulfilled returns true if the payment of this invoice has been fulfilled
func (*ClaimPayment) TotalDue ¶
func (c *ClaimPayment) TotalDue() int64
TotalDue returns the total cost to cover by this payment.
type ErrInvalidCurrency ¶
type ErrInvalidCurrency struct {
// contains filtered or unexported fields
}
ErrInvalidCurrency should be returned when paying with the wrong kind of instrument for instance covering credit with credit.
func (*ErrInvalidCurrency) Error ¶
func (e *ErrInvalidCurrency) Error() string
type EventSlot ¶
type EventSlot struct {
ID uint64 `gaum:"field_name:id"`
Event *def.Event `gaum:"field_name:event"`
Name string `gaum:"field_name:name"`
Description string `gaum:"field_name:description"`
Cost int64 `gaum:"field_name:cost"`
Capacity int `gaum:"field_name:capacity"` // int should be enough even if we organize glastonbury
StartDate uint64 `gaum:"field_name:start_date"` // StartDate is Unix timestamp, seconds since Epoch (1/1/1970 UTC)
EndDate uint64 `gaum:"field_name:end_date"` // EndDate is Unix timestamp, seconds since Epoch (1/1/1970 UTC)
// DependsOn means that these two Slots need to be acquired together, user must either buy
// both Slots or pre-own one of the one it depends on.
DependsOn *EventSlot
// PurchaseableFrom indicates when this item is on sale, for instance early bird tickets are the first
// ones to go on sale.
PurchaseableFrom uint64 `gaum:"field_name:purchaseable_from"` // PurchaseableFrom is Unix timestamp, seconds since Epoch (1/1/1970 UTC)
// PuchaseableUntil indicates when this item stops being on sale, for instance early bird tickets can
// no loger be purchased N months before event.
PurchaseableUntil uint64 `gaum:"field_name:purchaseable_until"` // PurchaseableUntil is Unix timestamp, seconds since Epoch (1/1/1970 UTC)
// AvailableToPublic indicates is this is something that will appear on the tickets purchase page (ie, we can
// issue sponsor tickets and those cannot be bought individually)
AvailableToPublic bool `gaum:"field_name:available_to_public"`
}
EventSlot holds information for any sellable/giftable slot we have in the event for a Talk or any other activity that requires admission.
type FinancialInstrument ¶
type FinancialInstrument interface {
// Total is the total amount fulfilled by this instrument
Total() int64
// Type is the type of asset represented
Type() AssetType
}
FinancialInstrument represents any kind of instrument used to cover a debt. oto: "skip"
type PaymentMethodConferenceDiscount ¶
type PaymentMethodConferenceDiscount struct {
ID uint64 `gaum:"field_name:id"`
// Detail describes what kind of discount was issued (ie 100% sponsor, 30% grant)
Detail string `gaum:"field_name:detail"`
Amount int64 `gaum:"field_name:amount"` // Money is handled in ints to ease use of OTO, do not divide
}
PaymentMethodConferenceDiscount represents a discount issued by the event.
func (*PaymentMethodConferenceDiscount) Total ¶
func (p *PaymentMethodConferenceDiscount) Total() int64
Total implements FinancialInstrument
func (*PaymentMethodConferenceDiscount) Type ¶
func (p *PaymentMethodConferenceDiscount) Type() AssetType
Type implements FinancialInstrument
type PaymentMethodCreditNote ¶
type PaymentMethodCreditNote struct {
ID uint64 `gaum:"field_name:id"`
Detail string `gaum:"field_name:detail"`
Amount int64 `gaum:"field_name:amount"` // Money is handled in ints to ease use of OTO, do not divide
}
PaymentMethodCreditNote represents credit extended to defer payment.
func (*PaymentMethodCreditNote) Total ¶
func (p *PaymentMethodCreditNote) Total() int64
Total implements FinancialInstrument
func (*PaymentMethodCreditNote) Type ¶
func (p *PaymentMethodCreditNote) Type() AssetType
Type implements FinancialInstrument
type PaymentMethodMoney ¶
type PaymentMethodMoney struct {
ID uint64 `gaum:"field_name:id"`
PaymentRef string `gaum:"field_name:ref"` // stripe payment ID/Log?
Amount int64 `gaum:"field_name:amount"` // Money is handled in ints to ease use of OTO, do not divide
}
PaymentMethodMoney represents a payment in cash.
func (*PaymentMethodMoney) Total ¶
func (p *PaymentMethodMoney) Total() int64
Total implements FinancialInstrument
func (*PaymentMethodMoney) Type ¶
func (p *PaymentMethodMoney) Type() AssetType
Type implements FinancialInstrument
type PurchaseStore ¶
type PurchaseStore interface {
// AtomicOperation returns a store which will act as one single atomic operation.
// It returns a commit and cancel functions and the Store .
AtomicOperation() (func() error, func() error, PurchaseStore, error)
// CreateSlotClaim saves a slot claim and returns it with the populated ID
CreateSlotClaim(*SlotClaim) (*SlotClaim, error)
// UpdateAttendee saves the passed attendee attributes on top of the existing one.
UpdateAttendee(*Attendee) (*Attendee, error)
CreateClaimPayment(*ClaimPayment) (*ClaimPayment, error)
UpdateClaimPayment(*ClaimPayment) (*ClaimPayment, error)
ChangeSlotClaimOwner([]SlotClaim, *Attendee, *Attendee) (*Attendee, *Attendee, error)
CreateAttendee(a *Attendee) (*Attendee, error)
ReadAttendeeByEmail(email string) (*Attendee, error)
ReadAttendeeByID(id uint64) (*Attendee, error)
CreateEventSlot(e *EventSlot) (*EventSlot, error)
ReadEventSlotByID(id uint64) (*EventSlot, error)
UpdateEventSlot(e *EventSlot) error
}
PurchaseStore offers functionality for persistence of ticketing models.
type SQLStorage ¶
type SQLStorage struct {
// contains filtered or unexported fields
}
SQLStorage provides a Postgres Flavored storage backend to store ticketing information.
func NewSQLStorage ¶
func NewSQLStorage(connectionString string, logger *log.Logger) (*SQLStorage, error)
NewSQLStorage returns a new Storage connected to the postgres-like db indicated by the connectionString.
func NewSQLStorageFromConnection ¶
func NewSQLStorageFromConnection(conn connection.DB) *SQLStorage
NewSQLStorageFromConnection returns a new SQLStorage using the passed connection
func (*SQLStorage) AtomicOperation ¶
func (s *SQLStorage) AtomicOperation() (func() error, func() error, PurchaseStore, error)
AtomicOperation begins a transaction and returns commit and rollback functions along with a new SQLStorage wrapping the tx
func (*SQLStorage) ChangeSlotClaimOwner ¶
func (s *SQLStorage) ChangeSlotClaimOwner(slots []SlotClaim, source *Attendee, target *Attendee) (*Attendee, *Attendee, error)
ChangeSlotClaimOwner changes the passed claims owner from source to target
func (*SQLStorage) CreateAttendee ¶
func (s *SQLStorage) CreateAttendee(a *Attendee) (*Attendee, error)
CreateAttendee creates a new attendee in the database and returns it.
func (*SQLStorage) CreateClaimPayment ¶
func (s *SQLStorage) CreateClaimPayment(c *ClaimPayment) (*ClaimPayment, error)
CreateClaimPayment Creates c ClaimPayment record and asociates it with all the relevant payments.
func (*SQLStorage) CreateEventSlot ¶
func (s *SQLStorage) CreateEventSlot(e *EventSlot) (*EventSlot, error)
CreateEventSlot saves a slot in the database.
func (*SQLStorage) CreateSlotClaim ¶
func (s *SQLStorage) CreateSlotClaim(slotClaim *SlotClaim) (*SlotClaim, error)
CreateSlotClaim saves a slot claim and returns it with the populated ID
func (*SQLStorage) ReadAttendeeByEmail ¶
func (s *SQLStorage) ReadAttendeeByEmail(email string) (*Attendee, error)
ReadAttendeeByEmail returns an attendee for that email if one exists.
func (*SQLStorage) ReadAttendeeByID ¶
func (s *SQLStorage) ReadAttendeeByID(id uint64) (*Attendee, error)
ReadAttendeeByID returns an attendee for the given ID if one exists.
func (*SQLStorage) ReadEventSlotByID ¶
func (s *SQLStorage) ReadEventSlotByID(id uint64) (*EventSlot, error)
ReadEventSlotByID returns an event slot identified by the passed ID.
func (*SQLStorage) UpdateAttendee ¶
func (s *SQLStorage) UpdateAttendee(attendee *Attendee) (*Attendee, error)
UpdateAttendee saves the passed attendee attributes on top of the existing one.
func (*SQLStorage) UpdateClaimPayment ¶
func (s *SQLStorage) UpdateClaimPayment(c *ClaimPayment) (*ClaimPayment, error)
UpdateClaimPayment saves the invoice and payments of this claim payment assuming it exists
func (*SQLStorage) UpdateEventSlot ¶
func (s *SQLStorage) UpdateEventSlot(e *EventSlot) error
UpdateEventSlot updates event slot fields from the passed instance
type SlotClaim ¶
type SlotClaim struct {
ID uint64 `gaum:"field_name:id"`
EventSlot *EventSlot
// TicketID should only be valid when combined with the correct Attendee ID/Email
TicketID string `gaum:"field_name:ticket_id"` // uuid
// Redeemed represents whether this has been used (ie the Attendee enrolled in front desk
// or into the online conf system) until this is not true, transfer/refund might be possible.
Redeemed bool `gaum:"field_name:redeemed"`
}
SlotClaim represents one occupancy of one slot.
func ClaimSlots ¶
func ClaimSlots(storer PurchaseStore, attendee *Attendee, slots ...EventSlot) ([]SlotClaim, error)
ClaimSlots claims N slots for an attendee.