feat(manager): expenses, the supplier book and tabs on v2 (platform-v2 step 6.13a)
- Finance -> Expenses: still owed, late, filters, new/edit (supplier picked or added there), pay in parts, details with payments, delete - CRM -> Contacts: the supplier book with what each one is owed - Finance -> Tabs: open (who owes most first) / settled, charges and payments, pay (cash/card/other), close, forgive - backend: expenses.manage / tabs.manage (the list also reports.view, a customer's tabs also crm.manage, put-on-tab needs tabs.manage); payment <= due (expense.over_due), total >= paid (expense.below_paid), categories/kinds/methods checked, null clears a field; live events expenses.changed / tabs.changed; GET /api/expenses ?from=&to= venue dates (the report uses it); tab_status=settled - fix: an expense with a due date failed to save (naive date refused by D-11) - @xenia/i18n/number subpath; tests: test_finance.py (6), finance.test.mjs (5), e2e manager.mjs finance flow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { useState } from 'react'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import toast from 'react-hot-toast'
|
||||
import { Ban, CreditCard, Percent, Printer, Receipt } from 'lucide-react'
|
||||
import { useCan } from '@xenia/access'
|
||||
import { useCan, useModule } from '@xenia/access'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, EmptyState, Field, Input, cx } from '@xenia/ui'
|
||||
@@ -21,6 +21,8 @@ export default function OrderLines({ order, open, priceEvents, onPay, onChanged
|
||||
const { t } = useTranslation('manager')
|
||||
const { formatMoney, formatTime } = useFormat()
|
||||
const canDiscount = useCan('pricing.discounts.apply')
|
||||
const tabsOn = useModule('tabs')
|
||||
const canTab = useCan('tabs.manage') && tabsOn // what the tab route checks (6.13a)
|
||||
const [selected, setSelected] = useState([])
|
||||
const [cancelling, setCancelling] = useState(false)
|
||||
const [discounting, setDiscounting] = useState(false)
|
||||
@@ -94,7 +96,7 @@ export default function OrderLines({ order, open, priceEvents, onPay, onChanged
|
||||
<div className="sticky bottom-0 flex flex-wrap items-center gap-2 px-4 py-3 border-t border-line bg-surface-2" data-testid="line-actions">
|
||||
<span className="flex-1 text-label text-ink-2">{t('orders.lines.picked', { count: picked.length, amount: formatMoney(amount) })}</span>
|
||||
<Button size="sm" variant="ghost" onClick={() => setSelected([])}>{t('orders.lines.clear')}</Button>
|
||||
{order.customer_id && <Button size="sm" variant="secondary" icon={<Receipt size={14} />} loading={toTab.isPending} onClick={() => toTab.mutate()}>{t('orders.lines.toTab')}</Button>}
|
||||
{order.customer_id && canTab && <Button size="sm" variant="secondary" icon={<Receipt size={14} />} loading={toTab.isPending} onClick={() => toTab.mutate()}>{t('orders.lines.toTab')}</Button>}
|
||||
{canDiscount && <Button size="sm" variant="secondary" icon={<Percent size={14} />} onClick={() => setDiscounting(true)} data-testid="lines-discount">{t('orders.lines.discount')}</Button>}
|
||||
<Button size="sm" variant="danger" icon={<Ban size={14} />} onClick={() => setCancelling(true)} data-testid="lines-cancel">{t('orders.lines.cancel')}</Button>
|
||||
<Button size="sm" icon={<CreditCard size={14} />} onClick={() => onPay(picked, amount, () => setSelected([]))} data-testid="lines-pay">{t('orders.lines.pay')}</Button>
|
||||
|
||||
Reference in New Issue
Block a user