Files
backend_fiesta/models/posshift.go

54 lines
2.5 KiB
Go

package models
import "time"
// StaffShifts is a working window at one outlet.
//
// Separate from `ridershifts`, which already exists and was the obvious thing
// to reuse — but is the wrong shape twice over. It carries delivery economics
// (`basefare`, `fuelcharge`, `additionalkm`, `firstmilecharge`) that mean
// nothing at a counter, and it is scoped by `applocationid`, a city, where a
// shop's hours belong to the shop. A supermarket in Selvapuram and one in
// Gandhipuram do not open at the same time because they share a city.
//
// A person is assigned exactly one of these via `app_users.shiftid`, which is
// the column that already existed. That makes a shift a *template* — "the
// morning shift" — rather than a roster of dated assignments. A roster is the
// richer model and the one to reach for if per-date planning is ever wanted;
// this is the smaller thing that answers "who is on the early shift" without a
// second table and a second screen.
//
// Informational. Nothing refuses a bill rung outside a shift: the terminal has
// never been run against this, and a cashier locked out mid-queue by a clock is
// a worse failure than a bill filed against the wrong window.
type StaffShifts struct {
Staffshiftid int `json:"staff_shift_id" gorm:"primaryKey;autoIncrement;column:staffshiftid"`
Tenantid int `json:"tenantid" gorm:"column:tenantid;index"`
Locationid int `json:"locationid" gorm:"column:locationid;index"`
// What a person calls it — "Morning", "Evening", "Weekend cover".
Name string `json:"name" gorm:"column:name"`
// Stored as text in 24-hour `HH:MM`, matching how `ridershifts` already
// holds its own times. Not a `time` column: these are wall-clock windows
// that repeat, not instants, and a date component on them invites exactly
// the timezone confusion that put a day of POS bills under the wrong
// business date.
Starttime string `json:"start_time" gorm:"column:starttime"`
Endtime string `json:"end_time" gorm:"column:endtime"`
// Which days it runs, as a 7-character mask starting Monday — "1111100"
// is Monday to Friday. Empty means every day, so a shop that never varies
// its week does not have to say so.
Weekdays string `json:"weekdays" gorm:"column:weekdays"`
Status string `json:"status" gorm:"column:status"`
Created time.Time `json:"created" gorm:"column:created;autoCreateTime"`
Updated time.Time `json:"updated" gorm:"column:updated;autoUpdateTime"`
}
func (StaffShifts) TableName() string {
return "staffshifts"
}