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