import React from 'react'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import Table from '@mui/material/Table'; import TableBody from '@mui/material/TableBody'; import TableCell from '@mui/material/TableCell'; import TableRow from '@mui/material/TableRow'; const OrderSummary = ({ deliveryCost, cartItems = [] }) => { const currencyFormatter = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }); // Calculate VAT breakdown for cart items (similar to CartDropdown) const cartVatCalculations = cartItems.reduce((acc, item) => { const totalItemPrice = item.price * item.quantity; const netPrice = totalItemPrice / (1 + item.vat / 100); const vatAmount = totalItemPrice - netPrice; acc.totalGross += totalItemPrice; acc.totalNet += netPrice; if (item.vat === 7) { acc.vat7 += vatAmount; } else if (item.vat === 19) { acc.vat19 += vatAmount; } return acc; }, { totalGross: 0, totalNet: 0, vat7: 0, vat19: 0 }); // Calculate shipping VAT (19% VAT for shipping costs) const shippingNetPrice = deliveryCost / (1 + 19 / 100); const shippingVat = deliveryCost - shippingNetPrice; // Combine totals - add shipping VAT to the 19% VAT total const totalVat7 = cartVatCalculations.vat7; const totalVat19 = cartVatCalculations.vat19 + shippingVat; const totalGross = cartVatCalculations.totalGross + deliveryCost; return ( Bestellübersicht Waren (netto): {currencyFormatter.format(cartVatCalculations.totalNet)} {deliveryCost > 0 && ( Versandkosten (netto): {currencyFormatter.format(shippingNetPrice)} )} {totalVat7 > 0 && ( 7% Mehrwertsteuer: {currencyFormatter.format(totalVat7)} )} {totalVat19 > 0 && ( 19% Mehrwertsteuer (inkl. Versand): {currencyFormatter.format(totalVat19)} )} Gesamtsumme Waren: {currencyFormatter.format(cartVatCalculations.totalGross)} {deliveryCost > 0 && ( Versandkosten: {currencyFormatter.format(deliveryCost)} )} Gesamtsumme: {currencyFormatter.format(totalGross)}
); }; export default OrderSummary;