calcualte tax before sending it

This commit is contained in:
2026-01-14 15:56:16 +03:00
parent 6bf4cb6399
commit e87c3e0783

View File

@@ -115,14 +115,15 @@ export default function useOrder() {
? `${location?.lat},${location?.lng}` ? `${location?.lat},${location?.lng}`
: "", : "",
delivery_address: location?.address, delivery_address: location?.address,
vatvalue: restaurant?.vat || 0, vatvalue: ((restaurant?.vat || 0) / 100) * (subtotal - discountAmount),
taxes: taxes:
restaurant?.taxes?.map((t) => ({ restaurant?.taxes
?.filter((t) => t.is_active === 1)
.map((t) => ({
tax_id: t.id, tax_id: t.id,
percentage: t.percentage, percentage: t.percentage,
amount: amount:
((typeof t.percentage === "number" ? t.percentage : 0) as number) * ((Number(t.percentage) || 0) / 100) * (subtotal - discountAmount),
Number(subtotal - discountAmount),
})) || [], })) || [],
...(orderType === OrderType.Gift ...(orderType === OrderType.Gift
? { ? {