Add balance adjustments (M8)
- New balance_adjustments table with CRUD store, sync logging, and service methods
- SQL migrations restructured: embed fs.FS from internal/store/migrations/, apply in order via user_version
- WeekService.Balance combines closed-weeks delta + adjustments delta; BalanceSummary breakdown
- Four REST routes: GET/POST /api/balance/adjustments, PUT/DELETE /api/balance/adjustments/{id}
- Dexie schema v2 + sync apply cases for balance_adjustments
- API client: BalanceAdjustment type, balance namespace (list/create/update/delete)
- utils: composeDeltaMs / decomposeDeltaMs helpers + 8 new Vitest tests (19 total, all passing)
- History page: balance card breakdown line + full adjustments section with inline add/edit/delete
This commit is contained in:
@@ -109,6 +109,18 @@ func (s *Settings) IsWorkday(wd int) bool {
|
||||
return s.WorkdaysMask&bit != 0
|
||||
}
|
||||
|
||||
// BalanceAdjustment is a manual corrective entry that adjusts the overall
|
||||
// overtime balance without touching week math. DeltaMs is signed: positive
|
||||
// credits time, negative debits time.
|
||||
type BalanceAdjustment struct {
|
||||
ID string `json:"id"` // UUIDv7, client-generated
|
||||
DeltaMs int64 `json:"delta_ms"` // signed, non-zero
|
||||
Note string `json:"note"` // optional free-text reason
|
||||
EffectiveAt int64 `json:"effective_at"` // unix ms, backdatable
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
}
|
||||
|
||||
func popcount(n int) int {
|
||||
count := 0
|
||||
for n != 0 {
|
||||
|
||||
Reference in New Issue
Block a user