chore(merge): integrate origin/staging into local staging
All checks were successful
Staging Build / build (push) Successful in 2m57s

Resolved conflict in customer-accordion-list.tsx by keeping
the per-device flattening (DeviceCard) implementation.
This commit is contained in:
DanielS
2026-07-23 09:47:37 +02:00
16 changed files with 255 additions and 50 deletions

View File

@@ -182,17 +182,22 @@ export function OrdersTable({ initialOrders }: OrdersTableProps) {
</div>
</TableCell>
<TableCell className="max-w-[200px]">
<div className="flex flex-wrap gap-1">
{items.map((item: any) => (
<span
key={item.product_id}
className="text-[10px] bg-white/5 border border-white/10 rounded-full px-2 py-0.5 text-slate-300 inline-block"
<div className="flex flex-col gap-1.5">
{items.map((item: any, idx: number) => (
<div
key={idx}
className="text-[10px] text-slate-300 leading-tight"
>
{item.product_name}
<span className="font-semibold text-white block">
{item.device_name || 'Kasse'}:
</span>
<span>{item.product_name}</span>
{item.selected_modules?.length > 0 && (
<span className="text-slate-500 ml-1">+{item.selected_modules.length}</span>
<span className="text-slate-500 block text-[9px] mt-0.5">
+ {item.selected_modules.map((m: any) => m.module_name || m.name).join(', ')}
</span>
)}
</span>
</div>
))}
</div>
</TableCell>

View File

@@ -176,7 +176,7 @@ export const InvoicePDF = ({ order, orderSnapshot, customer }: any) => {
<View key={groupIdx} style={{ marginBottom: 12, borderWidth: 1, borderColor: '#e2e8f0', borderRadius: 4, padding: 8, backgroundColor: '#f8fafc' }}>
<View style={{ borderBottomWidth: 1, borderBottomColor: '#cbd5e1', paddingBottom: 4, marginBottom: 6 }}>
<Text style={{ fontSize: 10, fontWeight: 'bold', color: '#1e3a8a' }}>
Kasse: {deviceName}
{deviceName === 'Zusatzleistung' ? 'Backoffice' : `Kasse: ${deviceName}`}
</Text>
</View>
{devItems.map((item: any, idx: number) => (

View File

@@ -360,6 +360,8 @@ export function OrderWizard({
return { monthlyTotal: monthly, oneTimeTotal: oneTime }
}, [selections, products, categories, moduleQuantities])
// Ermittlung der Update-Faktoren basierend auf dem Lizenzdatum (nur für Kauf/einmalig relevant)
const updatePriceModifier = useMemo(() => {
if (selectedBillingInterval !== 'one_time' || !lastLicenseDate) return { factor: 1 }
@@ -413,6 +415,96 @@ export function OrderWizard({
})
}, [visibleCategories, selections, products, selectedBillingInterval])
const finalItemsToShow = basketItems.length > 0
? basketItems
: (allCategoriesFilled && productValidationErrors.length === 0
? [{ deviceName: deviceName || 'Kasse 1', selections, moduleQuantities, billingInterval: selectedBillingInterval }]
: [])
// Gesamtsummen für alle Items in der Bestellung (finalItemsToShow)
const { overallMonthlyTotal, overallOneTimeTotal, linkedFeeProducts } = useMemo(() => {
let monthly = 0
let oneTime = 0
const feeProductIds = new Set<string>()
finalItemsToShow.forEach(item => {
categories.forEach(cat => {
const sel = item.selections[cat.id]
if (!sel) return
const selectedProds: Product[] = []
if (cat.allow_multiselect && sel.productIds && sel.productIds.length > 0) {
sel.productIds.forEach((pId: string) => {
const p = products.find(prod => prod.id === pId)
if (p) selectedProds.push(p)
})
} else if (sel.productId) {
const p = products.find(prod => prod.id === sel.productId)
if (p) selectedProds.push(p)
}
const freeLimit = cat.allow_multiselect ? cat.free_items_limit : 0
const sortedProds = [...selectedProds].sort((a, b) => a.base_price - b.base_price)
sortedProds.forEach((prod, idx) => {
const isFree = idx < freeLimit
const basePrice = isFree ? 0 : prod.base_price
if (prod.billing_interval === 'monthly') {
monthly += basePrice
} else {
oneTime += basePrice
}
if (prod.linked_fee_product_id) {
feeProductIds.add(prod.linked_fee_product_id)
}
// Module
sel.moduleIds?.forEach((mId: string) => {
const mod = prod.modules?.find(m => m.id === mId)
if (mod) {
const qty = item.moduleQuantities?.[mId] || 1
if (prod.billing_interval === 'monthly') {
monthly += mod.price * qty
} else {
oneTime += mod.price * qty
}
}
})
})
})
})
const feeProducts: Product[] = []
feeProductIds.forEach(id => {
const p = products.find(prod => prod.id === id)
if (p) {
feeProducts.push(p)
if (p.billing_interval === 'monthly') {
monthly += p.base_price
} else {
oneTime += p.base_price
}
}
})
return {
overallMonthlyTotal: monthly,
overallOneTimeTotal: oneTime,
linkedFeeProducts: feeProducts
}
}, [finalItemsToShow, products, categories])
// Gesamte Endbeträge ermitteln
const overallOneTimeNet = overallOneTimeTotal * discountFactor
const overallOneTimeTax = overallOneTimeNet * 0.19
const overallOneTimeGross = overallOneTimeNet + overallOneTimeTax
const overallMonthlyNet = overallMonthlyTotal
const overallMonthlyTax = overallMonthlyNet * 0.19
const overallMonthlyGross = overallMonthlyNet + overallMonthlyTax
const isNextStepDisabled = !allCategoriesFilled || productValidationErrors.length > 0
// Helper: toggle module for a category's selected product
@@ -614,11 +706,7 @@ export function OrderWizard({
}
}
const finalItemsToShow = basketItems.length > 0
? basketItems
: (allCategoriesFilled && productValidationErrors.length === 0
? [{ deviceName: deviceName || 'Kasse 1', selections, moduleQuantities, billingInterval: selectedBillingInterval }]
: [])
function selectProduct(catId: string, productId: string) {
setSelections(prev => {
@@ -856,14 +944,14 @@ export function OrderWizard({
finalItemsToShow={finalItemsToShow}
visibleCategories={visibleCategories}
products={products}
oneTimeTotal={oneTimeTotal}
monthlyTotal={monthlyTotal}
oneTimeNet={oneTimeNet}
oneTimeTax={oneTimeTax}
oneTimeGross={oneTimeGross}
monthlyNet={monthlyNet}
monthlyTax={monthlyTax}
monthlyGross={monthlyGross}
oneTimeTotal={overallOneTimeTotal}
monthlyTotal={overallMonthlyTotal}
oneTimeNet={overallOneTimeNet}
oneTimeTax={overallOneTimeTax}
oneTimeGross={overallOneTimeGross}
monthlyNet={overallMonthlyNet}
monthlyTax={overallMonthlyTax}
monthlyGross={overallMonthlyGross}
updatePriceModifier={updatePriceModifier}
selectedEndCustomer={selectedEndCustomer}
customerData={customerData}
@@ -872,6 +960,7 @@ export function OrderWizard({
isSubmitting={isSubmitting}
initialOrder={initialOrder}
prevStep={prevStep}
linkedFeeProducts={linkedFeeProducts}
/>
</motion.div>
)}

View File

@@ -242,7 +242,7 @@ export function LicenseLookupPanel({ onLicenseResolved }: LicenseLookupPanelProp
setNotFound(false)
}}
onKeyDown={handleKeyDown}
placeholder="z. B. 995502-00"
placeholder="z. B. 995500-00"
className="pl-9 pr-8 bg-white/5 border-white/10 text-white placeholder:text-slate-500
focus:border-violet-500/60 focus:ring-violet-500/20 rounded-xl text-sm h-10"
/>
@@ -287,7 +287,7 @@ export function LicenseLookupPanel({ onLicenseResolved }: LicenseLookupPanelProp
className="font-mono text-amber-400/80 cursor-pointer hover:text-amber-400 transition-colors"
onClick={() => setLicenseKey('995501-00')}
>
995500-00
995501-00 (abgelaufen)
</span>
</p>
</div>

View File

@@ -177,7 +177,7 @@ export function StepCustomer({
<div className="relative flex-1">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" />
<Input
placeholder="Partner suchen nach Name oder ID..."
placeholder="Partner suchen..."
value={partnerSearchTerm}
onChange={(e) => setPartnerSearchTerm(e.target.value)}
className="pl-9 bg-white/5 border-white/10 text-white placeholder:text-slate-500 focus:border-primary text-sm h-9"
@@ -202,7 +202,10 @@ export function StepCustomer({
<div className="space-y-2 max-h-72 overflow-y-auto pr-1">
{/* Reserved Fixed Card: Alle Partner */}
<div
onClick={() => setSelectedCompanyId('all')}
onClick={() => {
setSelectedCompanyId('all')
setSelectedEndCustomerId(null)
}}
className={`flex items-center justify-between p-3.5 rounded-xl border-2 cursor-pointer transition-all select-none ${
selectedCompanyId === 'all' || !selectedCompanyId
? 'border-primary bg-primary/10 shadow-lg shadow-primary/5'
@@ -240,7 +243,10 @@ export function StepCustomer({
return (
<div
key={c.id}
onClick={() => setSelectedCompanyId(c.id)}
onClick={() => {
setSelectedCompanyId(c.id)
setSelectedEndCustomerId(null)
}}
className={`flex items-center justify-between p-3.5 rounded-xl border-2 cursor-pointer transition-all select-none ${
isSelected
? 'border-primary bg-primary/10 shadow-lg shadow-primary/5'
@@ -253,7 +259,11 @@ export function StepCustomer({
</div>
<div>
<p className="font-semibold text-white text-sm">{c.name}</p>
<p className="text-xs text-slate-500 font-mono">ID: {c.id}</p>
{(c.street || c.zip || c.city) && (
<p className="text-xs text-slate-400 mt-0.5">
{[c.street, [c.zip, c.city].filter(Boolean).join(' ')].filter(Boolean).join(', ')}
</p>
)}
</div>
</div>
@@ -592,9 +602,7 @@ export function StepCustomer({
onClick={nextStep}
disabled={
customerMode === 'create' ||
(customerMode === 'select' &&
customersByCompany.length > 0 &&
!selectedEndCustomerId)
!selectedEndCustomerId
}
>
Weiter zum Abrechnungsmodell <ChevronRight className="ml-2 w-4 h-4" />

View File

@@ -28,6 +28,7 @@ interface StepSummaryProps {
isSubmitting: boolean
initialOrder: any
prevStep: () => void
linkedFeeProducts?: Product[]
}
function CategoryIcon({ icon, className }: { icon?: string | null; className?: string }) {
@@ -56,6 +57,7 @@ export function StepSummary({
isSubmitting,
initialOrder,
prevStep,
linkedFeeProducts = [],
}: StepSummaryProps) {
return (
<Card className="glass-dark border-primary/30 max-w-2xl mx-auto shadow-primary/10 shadow-2xl">
@@ -142,6 +144,24 @@ export function StepSummary({
})}
</div>
))}
{linkedFeeProducts && linkedFeeProducts.length > 0 && (
<div className="space-y-3 border-b border-white/10 pb-4 last:border-0 last:pb-0">
<div className="flex justify-between items-center bg-white/5 p-2 rounded">
<span className="text-white font-bold text-sm">Backoffice</span>
</div>
{linkedFeeProducts.map(p => (
<div key={p.id} className="pl-2 space-y-1">
<div className="flex justify-between font-semibold text-sm text-white pl-3">
<span>{p.name}</span>
<span>
{new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(p.base_price)}
{' '}<span className="text-slate-400 text-[10px] font-normal">{p.billing_interval === 'monthly' ? '/ mtl.' : 'einmalig'}</span>
</span>
</div>
</div>
))}
</div>
)}
<Separator className="bg-white/10" />
<div className="text-sm text-slate-300 space-y-1">
{selectedEndCustomer ? (