feat(manager): customers, throwaways, stock and notes on v2 (platform-v2 step 6.13b)

- CRM -> Customers: search ignoring case and Greek accents (and part of the phone), visits / spent / last visit,
  the card (contact, notes, open tab, every visit with what was on a tab), new/edit/remove
- Inventory -> Throwaways: log (product, quantity with a comma, reason, note) with its cost, today's list (delete today only),
  a period's totals by reason and product, every entry; Inventory -> Stock: an honest 'not available yet'
- Notes: notes (pinned first, edit in place) and to-dos (urgent first, done folded away, who did it kept)
- backend: crm.manage / inventory.manage / notes.use (the customer search also with the dashboard key, for orders);
  spending counted by services/sales.py (refunds off, tab lines in); null clears a field; names/notes not blank, priorities checked;
  waste ?date_from=&date_to= venue dates; the Greek reason labels left the API; live customers.changed / waste.changed / notes.changed
- the overview's notes card needs notes.use and refreshes live
- tests: test_customers_waste_notes.py (4), crm.test.mjs (3), e2e manager.mjs (customers, throwaways, notes, stock, Greek)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 18:36:27 +02:00
co-authored by Claude Opus 5.5
parent 07c9a0aecf
commit bde125bf09
28 changed files with 1356 additions and 1244 deletions
+65
View File
@@ -1339,6 +1339,71 @@ try {
await page.getByTestId('user-menu').click()
await page.getByRole('menuitemradio', { name: 'English' }).click()
// ── 6.13b: a customer found without accents, a throwaway with its cost, a note and a to-do done ──
const cr = 'customers, waste, notes:'
for (const m of ['crm', 'inventory', 'notes']) await api('PUT', `/api/platform/modules/${m}`, { token: boss, body: { enabled: true } }).catch(() => {})
await page.goto(`${APP}/crm/customers`)
await page.getByTestId('customer-new').click()
await page.getByTestId('customer-save').click()
r.check(`${cr} a customer needs a name`, (await page.getByTestId('customer-dialog').textContent()).includes('Enter a name'))
await page.getByTestId('customer-name').fill('Γιώργος Ε2Ε')
await page.getByTestId('customer-phone').fill('697 700 1122')
await page.getByTestId('customer-notes').fill('Nut allergy')
await page.getByTestId('customer-save').click()
await page.getByTestId('customer-dialog').waitFor({ state: 'detached', timeout: 8000 }).catch(() => {})
await page.getByTestId('customer-search').fill('γιωργος ε2ε')
const georgeRow = page.locator('[data-testid="customer-row"]', { hasText: 'Γιώργος Ε2Ε' })
r.check(`${cr} found by typing the name without accents, in lower case`, await georgeRow.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
&& await page.getByTestId('customer-row').count() === 1)
await page.getByTestId('customer-search').fill('7001122')
r.check(`${cr} found by part of the phone number`, await georgeRow.waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
await georgeRow.click()
r.check(`${cr} the card shows the allergy`, await page.getByTestId('customer-card').waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
&& (await page.getByTestId('customer-card').textContent()).includes('Nut allergy'))
await page.screenshot({ path: path.join(OUT, 'manager-customer-card.png'), fullPage: true })
await page.keyboard.press('Escape')
await page.goto(`${APP}/inventory/throwaways`)
const wasteProduct = page.getByTestId('waste-product')
await wasteProduct.waitFor({ timeout: 10_000 }).catch(() => {})
await page.getByTestId('waste-log').click()
r.check(`${cr} a throwaway needs a product`, (await page.getByTestId('waste-form').textContent()).includes('Choose what was thrown away'))
const wasteOption = await wasteProduct.locator('option:not([value=""])').first().getAttribute('value')
await wasteProduct.selectOption(wasteOption)
await page.getByTestId('waste-qty').fill('1,5')
await page.getByRole('radio', { name: 'Dropped' }).click()
await page.getByTestId('waste-log').click()
const wasteRow = page.getByTestId('waste-today-row').first()
await wasteRow.waitFor({ timeout: 8000 }).catch(() => {})
const dayNow = await api('GET', '/api/business-day/current', { token: boss })
const logged = (await api('GET', `/api/waste/?business_day_id=${dayNow?.id}`, { token: boss })).entries.find(e => String(e.product_id) === wasteOption)
r.check(`${cr} logged from the page: 1.5, dropped, in today's list`, logged?.quantity === 1.5 && logged.reason === 'dropped' && (await wasteRow.textContent()).includes('Dropped'), JSON.stringify(logged))
await page.screenshot({ path: path.join(OUT, 'manager-throwaways.png'), fullPage: true })
await page.goto(`${APP}/notes`)
await page.getByTestId('note-new').fill('E2E: the fridge door sticks')
await page.getByTestId('note-add').click()
await page.getByTestId('todo-new').fill('E2E: call the plumber')
await page.getByRole('switch', { name: 'Urgent' }).click()
await page.getByTestId('todo-add').click()
const todoRow = page.locator('[data-testid="todo-row"]', { hasText: 'E2E: call the plumber' })
await todoRow.waitFor({ timeout: 8000 }).catch(() => {})
r.check(`${cr} the note and the urgent to-do are listed`, await page.locator('[data-testid="note-card"]', { hasText: 'the fridge door sticks' }).count() === 1
&& (await todoRow.textContent()).includes('URGENT'))
await todoRow.getByTestId('todo-done').click()
let plumber = null
for (let i = 0; i < 20 && !plumber?.is_done; i++) { await sleep(250); plumber = (await api('GET', '/api/notes/todos', { token: boss })).find(x => x.body === 'E2E: call the plumber') }
r.check(`${cr} the to-do ticked: done, and who did it is kept`, plumber?.is_done === true && !!plumber.done_by_name, JSON.stringify(plumber))
await page.screenshot({ path: path.join(OUT, 'manager-notes.png'), fullPage: true })
await page.goto(`${APP}/inventory/stock`)
r.check(`${cr} Stock says it isn't available yet`, await page.getByTestId('stock-page').waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
await page.getByTestId('user-menu').click()
await page.getByRole('menuitemradio', { name: 'Ελληνικά' }).click()
await page.goto(`${APP}/crm/customers`)
r.check(`${cr} Customers in Greek`, await page.locator('[data-testid="customers-page"] h1', { hasText: 'Πελάτες' }).waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
await page.goto(`${APP}/notes`)
r.check(`${cr} Notes in Greek`, await page.locator('[data-testid="notes-page"] h1', { hasText: 'Σημειώσεις' }).waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
await page.getByTestId('user-menu').click()
await page.getByRole('menuitemradio', { name: 'English' }).click()
await api('PUT', '/api/platform/modules/connect_orders', { token: boss, body: { enabled: true } })
await page.goto(`${APP}/online-orders`)
await page.getByTestId('online-orders').waitFor({ timeout: 10_000 }).catch(() => {})