Documentation
¶
Index ¶
- Constants
- Variables
- func NewBusinessHoursView(caller router.Caller, opts ...view.Option) view.Presenter
- func NewClosuresView(caller router.Caller, opts ...view.Option) view.Presenter
- func NewHolidaysView(caller router.Caller, opts ...view.Option) view.Presenter
- type BusinessHours
- func (*BusinessHours) Allow() model.Action
- func (p *BusinessHours) Create(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
- func (m *BusinessHours) DecodeFields(r model.FieldReader)
- func (m *BusinessHours) EncodeFields(w model.FieldWriter)
- func (m *BusinessHours) IsNil() bool
- func (m *BusinessHours) Item() model.Item
- func (m *BusinessHours) ModelName() string
- func (m *BusinessHours) Pointers() []any
- func (m *BusinessHours) Schema() []model.Field
- func (next *BusinessHours) Update(a crud.CurrentUser, tx crud.Tx, old *BusinessHours, fields []string, m *Module) (crud.RuleAnswer, error)
- func (m *BusinessHours) Validate(action byte) error
- type BusinessHoursList
- func (*BusinessHoursList) Allow() model.Action
- func (s *BusinessHoursList) Append() model.Fielder
- func (s *BusinessHoursList) At(i int) model.Fielder
- func (s *BusinessHoursList) DecodeFields(_ model.FieldReader)
- func (s *BusinessHoursList) EncodeFields(_ model.FieldWriter)
- func (s *BusinessHoursList) IsNil() bool
- func (s *BusinessHoursList) Len() int
- type CalendarChangedPayload
- type ClosedReason
- type Closure
- func (*Closure) Allow() model.Action
- func (p *Closure) Create(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
- func (m *Closure) DecodeFields(r model.FieldReader)
- func (p *Closure) Delete(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
- func (m *Closure) EncodeFields(w model.FieldWriter)
- func (m *Closure) IsNil() bool
- func (m *Closure) Item() model.Item
- func (m *Closure) ModelName() string
- func (m *Closure) Pointers() []any
- func (m *Closure) Schema() []model.Field
- func (m *Closure) Validate(action byte) error
- type ClosureList
- func (*ClosureList) Allow() model.Action
- func (s *ClosureList) Append() model.Fielder
- func (s *ClosureList) At(i int) model.Fielder
- func (s *ClosureList) DecodeFields(_ model.FieldReader)
- func (s *ClosureList) EncodeFields(_ model.FieldWriter)
- func (s *ClosureList) IsNil() bool
- func (s *ClosureList) Len() int
- type DayDetail
- type DayStatus
- func (m *DayStatus) DecodeFields(r model.FieldReader)
- func (m *DayStatus) EncodeFields(w model.FieldWriter)
- func (m *DayStatus) IsNil() bool
- func (m *DayStatus) ModelName() string
- func (m *DayStatus) Pointers() []any
- func (p *DayStatus) Read(a crud.CurrentUser, filter *DayStatus, args crud.ReadArgs, m *Module) (model.ModelSlice, error)
- func (m *DayStatus) Schema() []model.Field
- func (m *DayStatus) Validate(action byte) error
- func (m *DayStatus) Wire() bool
- type DayStatusList
- type Deps
- type Holiday
- func (*Holiday) Allow() model.Action
- func (p *Holiday) Create(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
- func (m *Holiday) DecodeFields(r model.FieldReader)
- func (p *Holiday) Delete(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
- func (m *Holiday) EncodeFields(w model.FieldWriter)
- func (m *Holiday) IsNil() bool
- func (m *Holiday) Item() model.Item
- func (m *Holiday) ModelName() string
- func (m *Holiday) Pointers() []any
- func (m *Holiday) Schema() []model.Field
- func (m *Holiday) Validate(action byte) error
- type HolidayList
- func (*HolidayList) Allow() model.Action
- func (s *HolidayList) Append() model.Fielder
- func (s *HolidayList) At(i int) model.Fielder
- func (s *HolidayList) DecodeFields(_ model.FieldReader)
- func (s *HolidayList) EncodeFields(_ model.FieldWriter)
- func (s *HolidayList) IsNil() bool
- func (s *HolidayList) Len() int
- type Module
- func (m *Module) AddClosure(c Closure) error
- func (m *Module) AddHoliday(h Holiday) error
- func (m *Module) BankDayAfter(from time.Unix, days int) (time.Unix, error)
- func (m *Module) ClosedDates(from, to time.Unix) (holidays, closures []string, err error)
- func (m *Module) DayLimits(date time.Unix) (time.DayLimits, error)
- func (m *Module) Definition() model.ModuleDefinition
- func (m *Module) GetDayDetail(date time.Unix) (DayDetail, error)
- func (m *Module) ListBusinessHours(after string, limit int64) ([]BusinessHours, error)
- func (m *Module) ListClosures(from, to int64, search, after string, limit int64) ([]Closure, error)
- func (m *Module) ListHolidays(from, to int64, search, after string, limit int64) ([]Holiday, error)
- func (m *Module) ModelName() string
- func (m *Module) MountOperations(reg crud.Registry)
- func (m *Module) RemoveClosure(id string) error
- func (m *Module) RemoveHoliday(id string) error
- func (m *Module) StoreBusinessHours() crud.Store
- func (m *Module) StoreClosure() crud.Store
- func (m *Module) StoreHoliday() crud.Store
- func (m *Module) UpsertBusinessHours(h BusinessHours) error
- func (m *Module) WeekdayLimits(dayOfWeek int) (time.DayLimits, error)
Constants ¶
const ( ErrNotFound model.NotFound = "business_calendar: record not found" ErrInvalidDay model.Invalid = "business_calendar: day_of_week must be 0..6" ErrInvalidWeekday model.Invalid = "business_calendar: day_of_week must be 0..6" ErrInvalidMinutes model.Invalid = "business_calendar: minutes must be 0..1439 and open_min < close_min" ErrDuplicateDate model.Conflict = "business_calendar: a record already exists for that date" ErrCannotRead model.Invalid = "business_calendar: cannot read the request" ErrFieldNotEditable model.Invalid = "business_calendar: that field cannot be changed" ErrDateRequired model.Invalid = "business_calendar: date is required" )
const ( CalendarKindBusinessHours = "BUSINESS_HOURS" CalendarKindHoliday = "HOLIDAY" CalendarKindClosure = "CLOSURE" )
const ErrNegativeDays = model.Invalid("business_calendar: days must be zero or more")
ErrNegativeDays: BankDayAfter con días negativos.
const EventCalendarChanged = "business.calendar.changed"
const ModelName = "business_calendar"
ModelName is the module identity: Definition.Name.
Variables ¶
var BusinessHoursModel = model.Definition{ Name: "business_hours", Allow: model.Create | model.Read | model.Update, Rules: model.Rules{Create: model.AddMyBusinessRule, Read: model.HaveNoBusinessRule, Update: model.AddMyBusinessRule}, Fields: model.Fields{ {Name: "id", Type: model.Text(), OmitEmpty: true, ServerOnly: true, DB: &model.FieldDB{PK: true}}, {Name: "day_of_week", Type: input.Number(), Label: "Day of week", DB: &model.FieldDB{Unique: true}, Item: model.ItemLabel}, {Name: "open_min", Type: input.Hour(), Label: "Opens at", OmitEmpty: true, Item: model.ItemDescription}, {Name: "close_min", Type: input.Hour(), Label: "Closes at", OmitEmpty: true, Item: model.ItemDescription}, {Name: "is_open", Type: input.Checkbox(), Label: "Open", Item: model.ItemDescription}, {Name: "notes", Type: input.Textarea(), Label: "Notes", Item: model.ItemDescription}, {Name: "updated_at", Type: model.NanoTime(), NotNull: true, ServerOnly: true}, }, }
var BusinessHours_ = struct { Id string DayOfWeek string OpenMin string CloseMin string IsOpen string Notes string UpdatedAt string }{ Id: "id", DayOfWeek: "day_of_week", OpenMin: "open_min", CloseMin: "close_min", IsOpen: "is_open", Notes: "notes", UpdatedAt: "updated_at", }
var ClosureModel = model.Definition{ Name: "closure", Allow: model.Create | model.Read | model.Delete, Rules: model.Rules{Create: model.AddMyBusinessRule, Read: model.HaveNoBusinessRule, Delete: model.AddMyBusinessRule}, Fields: model.Fields{ {Name: "id", Type: model.Text(), OmitEmpty: true, ServerOnly: true, DB: &model.FieldDB{PK: true}}, {Name: "specific_date", Type: input.Number(), Label: "Date", NotNull: true, Item: model.ItemDescription}, {Name: "reason", Type: input.Text(), Label: "Reason", NotNull: true, Item: model.ItemLabel}, {Name: "updated_at", Type: model.NanoTime(), NotNull: true, ServerOnly: true}, }, }
var Closure_ = struct { Id string SpecificDate string Reason string UpdatedAt string }{ Id: "id", SpecificDate: "specific_date", Reason: "reason", UpdatedAt: "updated_at", }
var DayStatusModel = model.Definition{ Name: "day_detail", Wire: true, Allow: model.Read, Rules: model.Rules{Read: model.AddMyBusinessRule}, Fields: model.Fields{ {Name: "date", Type: model.Int(), OmitEmpty: true}, {Name: "open", Type: model.Bool(), OmitEmpty: true}, {Name: "open_min", Type: model.Int(), OmitEmpty: true}, {Name: "close_min", Type: model.Int(), OmitEmpty: true}, {Name: "closed_by", Type: model.Text(), OmitEmpty: true}, }, }
var Definition = model.ModuleDefinition{ Name: "business_calendar", Entities: []model.Definition{BusinessHoursModel, HolidayModel, ClosureModel, DayStatusModel}, }
var HolidayModel = model.Definition{ Name: "holiday", Allow: model.Create | model.Read | model.Delete, Rules: model.Rules{Create: model.AddMyBusinessRule, Read: model.HaveNoBusinessRule, Delete: model.AddMyBusinessRule}, Fields: model.Fields{ {Name: "id", Type: model.Text(), OmitEmpty: true, ServerOnly: true, DB: &model.FieldDB{PK: true}}, {Name: "specific_date", Type: input.Number(), Label: "Date", NotNull: true, Item: model.ItemDescription}, {Name: "name", Type: input.Text(), Label: "Name", NotNull: true, Item: model.ItemLabel}, {Name: "notes", Type: input.Textarea(), Label: "Notes"}, {Name: "updated_at", Type: model.NanoTime(), NotNull: true, ServerOnly: true}, }, }
Functions ¶
func NewBusinessHoursView ¶ added in v0.0.2
func NewClosuresView ¶ added in v0.0.2
Types ¶
type BusinessHours ¶ added in v0.0.2
type BusinessHours struct {
Id string
DayOfWeek int64
OpenMin string
CloseMin string
IsOpen bool
Notes string
UpdatedAt time.Nano
}
func ReadOneBusinessHours ¶ added in v0.0.2
func ReadOneBusinessHours(qb *orm.QB, model *BusinessHours) (*BusinessHours, error)
func (*BusinessHours) Allow ¶ added in v0.5.62
func (*BusinessHours) Allow() model.Action
func (*BusinessHours) Create ¶ added in v0.5.62
func (p *BusinessHours) Create(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
func (*BusinessHours) DecodeFields ¶ added in v0.0.2
func (m *BusinessHours) DecodeFields(r model.FieldReader)
func (*BusinessHours) EncodeFields ¶ added in v0.0.2
func (m *BusinessHours) EncodeFields(w model.FieldWriter)
func (*BusinessHours) IsNil ¶ added in v0.0.2
func (m *BusinessHours) IsNil() bool
func (*BusinessHours) Item ¶ added in v0.0.2
func (m *BusinessHours) Item() model.Item
func (*BusinessHours) ModelName ¶ added in v0.0.2
func (m *BusinessHours) ModelName() string
func (*BusinessHours) Pointers ¶ added in v0.0.2
func (m *BusinessHours) Pointers() []any
func (*BusinessHours) Schema ¶ added in v0.0.2
func (m *BusinessHours) Schema() []model.Field
func (*BusinessHours) Update ¶ added in v0.5.62
func (next *BusinessHours) Update(a crud.CurrentUser, tx crud.Tx, old *BusinessHours, fields []string, m *Module) (crud.RuleAnswer, error)
func (*BusinessHours) Validate ¶ added in v0.0.2
func (m *BusinessHours) Validate(action byte) error
type BusinessHoursList ¶ added in v0.0.2
type BusinessHoursList []*BusinessHours
func ReadAllBusinessHours ¶ added in v0.0.2
func ReadAllBusinessHours(qb *orm.QB) (BusinessHoursList, error)
func (*BusinessHoursList) Allow ¶ added in v0.5.62
func (*BusinessHoursList) Allow() model.Action
func (*BusinessHoursList) Append ¶ added in v0.0.2
func (s *BusinessHoursList) Append() model.Fielder
func (*BusinessHoursList) DecodeFields ¶ added in v0.0.2
func (s *BusinessHoursList) DecodeFields(_ model.FieldReader)
func (*BusinessHoursList) EncodeFields ¶ added in v0.0.2
func (s *BusinessHoursList) EncodeFields(_ model.FieldWriter)
func (*BusinessHoursList) IsNil ¶ added in v0.0.2
func (s *BusinessHoursList) IsNil() bool
func (*BusinessHoursList) Len ¶ added in v0.0.2
func (s *BusinessHoursList) Len() int
type CalendarChangedPayload ¶ added in v0.0.2
func (*CalendarChangedPayload) DecodeFields ¶ added in v0.0.2
func (p *CalendarChangedPayload) DecodeFields(r model.FieldReader)
func (*CalendarChangedPayload) EncodeFields ¶ added in v0.0.2
func (p *CalendarChangedPayload) EncodeFields(w model.FieldWriter)
func (*CalendarChangedPayload) IsNil ¶ added in v0.0.2
func (p *CalendarChangedPayload) IsNil() bool
type ClosedReason ¶ added in v0.0.2
type ClosedReason string
const ( ClosedWeekly ClosedReason = "WEEKLY" ClosedHoliday ClosedReason = "HOLIDAY" ClosedLocal ClosedReason = "CLOSURE" )
type Closure ¶ added in v0.0.2
func ReadOneClosure ¶ added in v0.0.2
func (*Closure) Create ¶ added in v0.5.62
func (p *Closure) Create(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
func (*Closure) DecodeFields ¶ added in v0.0.2
func (m *Closure) DecodeFields(r model.FieldReader)
func (*Closure) Delete ¶ added in v0.5.62
func (p *Closure) Delete(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
func (*Closure) EncodeFields ¶ added in v0.0.2
func (m *Closure) EncodeFields(w model.FieldWriter)
type ClosureList ¶ added in v0.0.2
type ClosureList []*Closure
func ReadAllClosure ¶ added in v0.0.2
func ReadAllClosure(qb *orm.QB) (ClosureList, error)
func (*ClosureList) Allow ¶ added in v0.5.62
func (*ClosureList) Allow() model.Action
func (*ClosureList) Append ¶ added in v0.0.2
func (s *ClosureList) Append() model.Fielder
func (*ClosureList) DecodeFields ¶ added in v0.0.2
func (s *ClosureList) DecodeFields(_ model.FieldReader)
func (*ClosureList) EncodeFields ¶ added in v0.0.2
func (s *ClosureList) EncodeFields(_ model.FieldWriter)
func (*ClosureList) IsNil ¶ added in v0.0.2
func (s *ClosureList) IsNil() bool
func (*ClosureList) Len ¶ added in v0.0.2
func (s *ClosureList) Len() int
type DayDetail ¶ added in v0.0.4
type DayDetail struct {
Limits time.DayLimits
ClosedBy ClosedReason
}
func (*DayDetail) EncodeFields ¶ added in v0.0.4
func (d *DayDetail) EncodeFields(w model.FieldWriter)
type DayStatus ¶ added in v0.5.62
func (*DayStatus) DecodeFields ¶ added in v0.5.62
func (m *DayStatus) DecodeFields(r model.FieldReader)
func (*DayStatus) EncodeFields ¶ added in v0.5.62
func (m *DayStatus) EncodeFields(w model.FieldWriter)
type DayStatusList ¶ added in v0.5.62
type DayStatusList []*DayStatus
func (*DayStatusList) Append ¶ added in v0.5.62
func (s *DayStatusList) Append() model.Fielder
func (*DayStatusList) DecodeFields ¶ added in v0.5.62
func (s *DayStatusList) DecodeFields(_ model.FieldReader)
func (*DayStatusList) EncodeFields ¶ added in v0.5.62
func (s *DayStatusList) EncodeFields(_ model.FieldWriter)
func (*DayStatusList) IsNil ¶ added in v0.5.62
func (s *DayStatusList) IsNil() bool
func (*DayStatusList) Len ¶ added in v0.5.62
func (s *DayStatusList) Len() int
type Holiday ¶ added in v0.0.2
func ReadOneHoliday ¶ added in v0.0.2
func (*Holiday) Create ¶ added in v0.5.62
func (p *Holiday) Create(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
func (*Holiday) DecodeFields ¶ added in v0.0.2
func (m *Holiday) DecodeFields(r model.FieldReader)
func (*Holiday) Delete ¶ added in v0.5.62
func (p *Holiday) Delete(a crud.CurrentUser, tx crud.Tx, m *Module) (crud.RuleAnswer, error)
func (*Holiday) EncodeFields ¶ added in v0.0.2
func (m *Holiday) EncodeFields(w model.FieldWriter)
type HolidayList ¶ added in v0.0.2
type HolidayList []*Holiday
func ReadAllHoliday ¶ added in v0.0.2
func ReadAllHoliday(qb *orm.QB) (HolidayList, error)
func (*HolidayList) Allow ¶ added in v0.5.62
func (*HolidayList) Allow() model.Action
func (*HolidayList) Append ¶ added in v0.0.2
func (s *HolidayList) Append() model.Fielder
func (*HolidayList) DecodeFields ¶ added in v0.0.2
func (s *HolidayList) DecodeFields(_ model.FieldReader)
func (*HolidayList) EncodeFields ¶ added in v0.0.2
func (s *HolidayList) EncodeFields(_ model.FieldWriter)
func (*HolidayList) IsNil ¶ added in v0.0.2
func (s *HolidayList) IsNil() bool
func (*HolidayList) Len ¶ added in v0.0.2
func (s *HolidayList) Len() int
type Module ¶ added in v0.0.2
type Module struct {
// contains filtered or unexported fields
}
func (*Module) AddClosure ¶ added in v0.0.2
func (*Module) AddHoliday ¶ added in v0.0.2
func (*Module) BankDayAfter ¶ added in v0.5.0
BankDayAfter devuelve la medianoche UTC del día hábil bancario que está days días hábiles después de from. Día hábil bancario: lunes a viernes que no es feriado legal (Holiday). El horario y los cierres propios del establecimiento no cuentan. days == 0 devuelve el mismo día si es hábil, si no el siguiente hábil. Ejemplo: deposito, err := cal.BankDayAfter(cobradoEl, 2) // cobro del viernes con abono a 2 días → martes
func (*Module) ClosedDates ¶ added in v0.5.41
func (*Module) Definition ¶ added in v0.5.62
func (m *Module) Definition() model.ModuleDefinition
Definition is the module's declaration (definition.go); crud.Mount compares it with what MountOperations mounted.
func (*Module) GetDayDetail ¶ added in v0.0.4
func (*Module) ListBusinessHours ¶ added in v0.0.2
func (m *Module) ListBusinessHours(after string, limit int64) ([]BusinessHours, error)
func (*Module) ListClosures ¶ added in v0.0.2
func (*Module) ListHolidays ¶ added in v0.0.2
func (*Module) MountOperations ¶ added in v0.0.2
MountOperations offers every entity of the module: the actions its model allows, with crud's validation and the rules written in rule_*.go.
func (*Module) RemoveClosure ¶ added in v0.0.2
func (*Module) RemoveHoliday ¶ added in v0.0.2
func (*Module) StoreBusinessHours ¶ added in v0.5.62
func (*Module) StoreClosure ¶ added in v0.5.62
func (*Module) StoreHoliday ¶ added in v0.5.62
func (*Module) UpsertBusinessHours ¶ added in v0.0.2
func (m *Module) UpsertBusinessHours(h BusinessHours) error