- Users: add hourly_rate (Float, nullable) — manager-only, not shown to waiter - WaiterShift: add hourly_rate_snapshot — copied from user.hourly_rate at shift open, never updated - Shift start (both /start and /manager/start): snapshot rate at shift creation - compute_shift_pay(): calculates worked hours (minus breaks) × rate_snapshot; returns None if unset - _enrich_shift(): now includes hourly_rate_snapshot, duration_hours, shift_pay - shifts_report in reports.py: delegates to _enrich_shift so all shift endpoints are consistent - Shifts CSV export: adds duration_hours, hourly_rate, shift_pay columns - StaffTab: hourly_rate field in waiter edit modal (Μισθοδοσία section, col 3) - ShiftsOverview report: Αμοιβή/ώρα + Αποδοχές columns; untracked shows 'Δεν παρακολουθείται' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
from pydantic import BaseModel
|
|
from datetime import datetime
|
|
from typing import Optional, List
|
|
from schemas.base import UTCDatetime
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
username: str
|
|
role: str
|
|
is_active: bool = True
|
|
full_name: Optional[str] = None
|
|
nickname: Optional[str] = None
|
|
mobile_phone: Optional[str] = None
|
|
note: Optional[str] = None
|
|
avatar_url: Optional[str] = None
|
|
email: Optional[str] = None
|
|
# Phase 2B — payroll
|
|
hourly_rate: Optional[float] = None
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
pin: str
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
username: Optional[str] = None
|
|
role: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
full_name: Optional[str] = None
|
|
nickname: Optional[str] = None
|
|
mobile_phone: Optional[str] = None
|
|
email: Optional[str] = None
|
|
note: Optional[str] = None
|
|
# Phase 2B — payroll
|
|
hourly_rate: Optional[float] = None
|
|
|
|
|
|
class WaiterZoneOut(BaseModel):
|
|
id: int
|
|
waiter_id: int
|
|
group_id: Optional[int] = None # None = all zones
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class UserOut(UserBase):
|
|
id: int
|
|
created_at: UTCDatetime
|
|
zone_assignments: List[WaiterZoneOut] = []
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class SetZonesRequest(BaseModel):
|
|
"""Replace all zone assignments for a waiter in one call.
|
|
group_ids=[] means remove all (sees nothing).
|
|
group_ids=[null] or all_zones=True means the wildcard 'all zones' sentinel."""
|
|
group_ids: Optional[List[Optional[int]]] = None # list of group ids; None in list = all-zones sentinel
|
|
all_zones: bool = False # convenience flag: if True, set a single NULL-group_id row
|
|
|
|
|
|
class AssistantAssignmentOut(BaseModel):
|
|
id: int
|
|
primary_waiter_id: int
|
|
assistant_waiter_id: int
|
|
assigned_at: UTCDatetime
|
|
|
|
model_config = {"from_attributes": True}
|