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,15 +115,16 @@ 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
tax_id: t.id, ?.filter((t) => t.is_active === 1)
percentage: t.percentage, .map((t) => ({
amount: tax_id: t.id,
((typeof t.percentage === "number" ? t.percentage : 0) as number) * percentage: t.percentage,
Number(subtotal - discountAmount), amount:
})) || [], ((Number(t.percentage) || 0) / 100) * (subtotal - discountAmount),
})) || [],
...(orderType === OrderType.Gift ...(orderType === OrderType.Gift
? { ? {
receiverName: giftDetails?.receiverName, receiverName: giftDetails?.receiverName,