feat(backend,manager): the business day opens and closes by itself (opening hours, a time, or only an alert)

- services/day_auto.py: a minute loop (venue time, offline) opens the day when the opening
  hours start (or at business_day.auto_open_time) and closes it when they end (or at
  auto_close_time); 'alert' only tells the managers. Offsets before / after, one day across
  the break or one per span, spans past midnight belong to the day they start, a day closed
  by hand isn't reopened in the same span, a restart catches up the open (until the business
  date changes for 'time') and alerts a missed close instead of doing it late.
- The close runs only when no order of the day is unclosed (Q-10): otherwise a sticky alert
  and a new try every 15 minutes. A locked / expired license turns the open into an alert.
- Sticky notifications: notifications.resolved_at + core.notifications.resolve(); the
  alerts resolve when the day opens / closes (by hand or by itself).
- services/business_days.py: the one open / close path (the routes and the loop); days opened
  or closed by the system have no opener / closer and opened_auto / closed_auto (Alembic 0052).
- Manager: Settings -> Operation "Opening and closing the day"; the bell's action buttons
  ("Open now", "Go to the overview"); Reports -> Days marks days opened / closed by itself.

Plan platform-v2 6F.8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 13:17:15 +02:00
co-authored by Claude Opus 5.5
parent 7706bf2470
commit 096bd53dbd
21 changed files with 856 additions and 117 deletions
+16
View File
@@ -777,6 +777,22 @@ try {
r.check(`${st6} Operation: splitting by amount into up to 6 equal parts`, await settingValue2('payments.split_amount') === 'multiple_equal' && sMax === '6')
await page.getByTestId('setting-payments.split_amount').selectOption('off')
r.check(`${st6} …"the most parts" hides when equal parts are off`, await page.getByTestId('setting-payments.split_max_parts').waitFor({ state: 'detached', timeout: 5000 }).then(() => true).catch(() => false))
// 6F.8: the day opens / closes by itself; the close says it waits for every table (Q-10)
await page.getByTestId('setting-business_day.auto_open').selectOption('schedule')
await page.getByTestId('setting-business_day.auto_open_offset_min').selectOption('30', { timeout: 5000 }).catch(() => {})
await page.getByTestId('setting-business_day.auto_close').selectOption('time')
const closeAt = page.getByTestId('setting-business_day.auto_close_time')
await closeAt.fill('23:45', { timeout: 5000 }).catch(() => {})
let dayOff = ''
for (let i = 0; i < 30 && dayOff !== '30'; i++) { await sleep(150); dayOff = await settingValue2('business_day.auto_open_offset_min') }
const autoCard = await page.getByTestId('settings-auto-day').innerText()
r.check(`${st6} 6F.8: the day opens at the hours (30 min before) and closes at 23:45, saved`, await settingValue2('business_day.auto_open') === 'schedule'
&& dayOff === '30' && await settingValue2('business_day.auto_close') === 'time' && await settingValue2('business_day.auto_close_time') === '23:45')
r.check(`${st6} 6F.8: beside the close: "only when every table is closed"`, autoCard.includes('Closes only when every table is closed'), autoCard.replace(/\s+/g, ' ').slice(0, 300))
await page.getByTestId('settings-auto-day').screenshot({ path: path.join(OUT, 'manager-settings-auto-day.png') })
await page.getByTestId('setting-business_day.auto_open').selectOption('off')
await page.getByTestId('setting-business_day.auto_close').selectOption('off')
await sleep(500)
await page.getByTestId('flag-new').click()
await page.getByTestId('flag-save').click()
r.check(`${st6} a table flag needs a name`, (await page.getByTestId('flag-dialog').textContent()).includes('Enter a name'))