fix vat and taxes sending
This commit is contained in:
@@ -2,6 +2,8 @@ import { message } from "antd";
|
|||||||
import {
|
import {
|
||||||
clearCart,
|
clearCart,
|
||||||
selectCart,
|
selectCart,
|
||||||
|
selectCartTotal,
|
||||||
|
selectDiscountTotal,
|
||||||
selectGrandTotal,
|
selectGrandTotal,
|
||||||
selectHighestPricedLoyaltyItem,
|
selectHighestPricedLoyaltyItem,
|
||||||
} from "features/order/orderSlice";
|
} from "features/order/orderSlice";
|
||||||
@@ -41,11 +43,14 @@ export default function useOrder() {
|
|||||||
pickupType,
|
pickupType,
|
||||||
giftDetails,
|
giftDetails,
|
||||||
order,
|
order,
|
||||||
|
restaurant,
|
||||||
} = useAppSelector(selectCart);
|
} = useAppSelector(selectCart);
|
||||||
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
|
const highestLoyaltyItem = useAppSelector(selectHighestPricedLoyaltyItem);
|
||||||
const { useLoyaltyPoints } = useAppSelector(selectCart);
|
const { useLoyaltyPoints } = useAppSelector(selectCart);
|
||||||
|
|
||||||
const orderPrice = useAppSelector(selectGrandTotal);
|
const orderPrice = useAppSelector(selectGrandTotal);
|
||||||
|
const subtotal = useAppSelector(selectCartTotal);
|
||||||
|
const discountAmount = useAppSelector(selectDiscountTotal);
|
||||||
|
|
||||||
const [createOrder] = useCreateOrderMutation();
|
const [createOrder] = useCreateOrderMutation();
|
||||||
|
|
||||||
@@ -90,10 +95,9 @@ export default function useOrder() {
|
|||||||
})),
|
})),
|
||||||
office_no: order?.officeNumber || "",
|
office_no: order?.officeNumber || "",
|
||||||
room_no: order?.roomNumber || "",
|
room_no: order?.roomNumber || "",
|
||||||
vatvalue: 0,
|
|
||||||
...(discount.isDiscount ? { couponID: coupon } : {}),
|
...(discount.isDiscount ? { couponID: coupon } : {}),
|
||||||
...(discount.isGift ? { discountGiftCode: coupon } : {}),
|
...(discount.isGift ? { discountGiftCode: coupon } : {}),
|
||||||
discountAmount: discount.value || 0,
|
discountAmount: discountAmount || 0,
|
||||||
paymentType: "cod",
|
paymentType: "cod",
|
||||||
uuid: user_uuid,
|
uuid: user_uuid,
|
||||||
pickup_comments: "",
|
pickup_comments: "",
|
||||||
@@ -111,6 +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,
|
||||||
|
taxes:
|
||||||
|
restaurant?.taxes?.map((t) => ({
|
||||||
|
tax_id: t.id,
|
||||||
|
percentage: t.percentage,
|
||||||
|
amount:
|
||||||
|
((typeof t.percentage === "number" ? t.percentage : 0) as number) *
|
||||||
|
Number(subtotal - discountAmount),
|
||||||
|
})) || [],
|
||||||
...(orderType === OrderType.Gift
|
...(orderType === OrderType.Gift
|
||||||
? {
|
? {
|
||||||
receiverName: giftDetails?.receiverName,
|
receiverName: giftDetails?.receiverName,
|
||||||
|
|||||||
Reference in New Issue
Block a user