feat(manager): online ordering settings in tabs beside Test an order; expense lines and documents

- Online orders -> Settings: takeaway / delivery / any time side by side (wrapping, with room),
  the days of the week apart; fee rules, delivery areas and fee settings (the fee line) as tabs
  on the left, Test an order on the right; a rule's switch at the far right, equal padding,
  'Order price from' / 'Total items count from' in the rule editor.
- Expenses: the dialog lists what was bought (quantity, price before VAT, VAT; they make the
  total, with net / VAT / total) and keeps documents (attach a PDF or photo, open, remove;
  picked for a new expense, uploaded when it's saved); a paperclip in the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 14:57:58 +02:00
co-authored by Claude Opus 5.5
parent 9297cbcd3b
commit f3fc3340d2
10 changed files with 318 additions and 87 deletions
+17 -2
View File
@@ -3,7 +3,7 @@ import { test } from 'node:test'
import assert from 'node:assert/strict'
import {
contactBody, contactForm, contactProblems, daysBetween, expenseBody, expenseForm, expenseProblems, expenseTotals,
filterContacts, filterExpenses, filterTabs, isLate, owedByContact, paymentAmount, tabActions, tabTotals,
filterContacts, filterExpenses, filterTabs, isLate, lineMoney, linesTotal, owedByContact, paymentAmount, tabActions, tabTotals,
} from '../src/pages/finance/financeLogic.js'
const key = iso => iso.slice(0, 10)
@@ -21,7 +21,7 @@ test('an expense form: typed amounts with a comma, the due date as a venue date,
assert.deepEqual(expenseProblems({ ...f, description: ' ', total_amount: '0' }), ['description', 'total_amount'])
assert.deepEqual(expenseProblems({ ...f, total_amount: '60' }, 70), ['below_paid'])
assert.deepEqual(expenseBody({ ...f, total_amount: '120,50', contact_id: '', due_date: '', notes: ' ' }),
{ description: 'Γάλα Νοεμβρίου', category: 'supplier', contact_id: null, total_amount: 120.5, due_date: null, notes: null })
{ description: 'Γάλα Νοεμβρίου', category: 'supplier', contact_id: null, total_amount: 120.5, lines: [], due_date: null, notes: null })
assert.equal(expenseForm(null).category, 'supplier')
})
@@ -68,3 +68,18 @@ test('tabs: what can be done, days open, search and what is owed', () => {
assert.equal(filterTabs(tabs, 'big').length, 1)
assert.deepEqual(tabTotals(tabs), { owed: 15.5, count: 2 })
})
test('the lines of an expense make its total, VAT rounded half up as on an invoice', () => {
const lines = [{ description: 'Tomatoes', quantity: '3', unit_price: '2,50', vat_rate: '13' }, { description: 'Bags', quantity: '1', unit_price: '10', vat_rate: '24' }]
assert.deepEqual(lineMoney(lines[0]), { net: 7.5, vat: 0.98, total: 8.48 })
assert.deepEqual(linesTotal(lines), { net: 17.5, vat: 3.38, total: 20.88 })
const f = { ...expenseForm(null), description: 'Market', lines }
assert.deepEqual(expenseProblems(f), [])
const body = expenseBody(f)
assert.equal(body.total_amount, null)
assert.deepEqual(body.lines[0], { description: 'Tomatoes', quantity: 3, unit_price: 2.5, vat_rate: 13 })
// a line without a description, and lines below what was paid
assert.deepEqual(expenseProblems({ ...f, lines: [{ ...lines[0], description: ' ' }] }), ['line.0'])
assert.deepEqual(expenseProblems(f, 30), ['below_paid'])
})