change product and razorpay
This commit is contained in:
parent
150a8320e7
commit
0a493c6e95
@ -80,32 +80,85 @@ export const checkout = async (req, res) => {
|
||||
const orderItems = await cart.map((item) => ({
|
||||
product: item.product._id,
|
||||
name: item.product.name,
|
||||
variant_Name: item.variant.variant_Name,
|
||||
price: Number(item.variant.price),
|
||||
total_price: item.quantity * Number(item.variant.price),
|
||||
variant_Name: item?.variant?.variant_Name
|
||||
? item?.variant?.variant_Name
|
||||
: "",
|
||||
price: Number(
|
||||
item?.variant?.price
|
||||
? item?.variant?.price
|
||||
: item?.product?.master_price
|
||||
),
|
||||
total_price:
|
||||
item.quantity *
|
||||
Number(
|
||||
item?.variant?.price
|
||||
? item?.variant?.price
|
||||
: item?.product?.master_price
|
||||
),
|
||||
|
||||
image: item.product.image,
|
||||
quantity: item.quantity,
|
||||
image: item.product?.image,
|
||||
quantity: item?.quantity,
|
||||
gst_amount: Number(
|
||||
(Number(item.variant.price) * item.variant.gst_Id?.tax) / 100
|
||||
)?.toFixed(3),
|
||||
total_gst_amount: Number(
|
||||
Number(item.quantity) *
|
||||
(Number(
|
||||
item?.variant?.price
|
||||
? item?.variant?.price
|
||||
: item?.product?.master_price
|
||||
) *
|
||||
Number(
|
||||
(Number(item.variant.price) * item.variant.gst_Id?.tax) / 100
|
||||
item?.variant?.gst_Id?.tax
|
||||
? item?.variant?.gst_Id?.tax
|
||||
: item?.product?.master_GST?.tax
|
||||
)) /
|
||||
100
|
||||
)?.toFixed(2),
|
||||
total_gst_amount: Number(
|
||||
Number(item?.quantity) *
|
||||
Number(
|
||||
(Number(
|
||||
item?.variant?.price
|
||||
? item?.variant?.price
|
||||
: item?.product?.master_price
|
||||
) *
|
||||
Number(
|
||||
item?.variant?.gst_Id?.tax
|
||||
? item?.variant?.gst_Id?.tax
|
||||
: item?.product?.master_GST?.tax
|
||||
)) /
|
||||
100
|
||||
)
|
||||
)?.toFixed(3),
|
||||
gst_rate: item.variant.gst_Id?.tax,
|
||||
tax_Name: item.variant?.gst_Id?.name,
|
||||
)?.toFixed(2),
|
||||
gst_rate: item?.variant?.gst_Id?.tax
|
||||
? item?.variant?.gst_Id?.tax
|
||||
: item?.product?.master_GST?.tax,
|
||||
tax_Name: item?.variant?.gst_Id?.name
|
||||
? item?.variant?.gst_Id?.name
|
||||
: item?.product?.master_GST?.name,
|
||||
product_Subtotal: Number(
|
||||
Number(item.quantity * Number(item.variant.price)) +
|
||||
Number(
|
||||
item.quantity *
|
||||
Number(
|
||||
item?.variant?.price
|
||||
? item?.variant?.price
|
||||
: item?.product?.master_price
|
||||
)
|
||||
) +
|
||||
Number(
|
||||
Number(item.quantity) *
|
||||
Number(
|
||||
(Number(item.variant.price) * item.variant.gst_Id?.tax) / 100
|
||||
(Number(
|
||||
item?.variant?.price
|
||||
? item?.variant?.price
|
||||
: item?.product?.master_price
|
||||
) *
|
||||
Number(
|
||||
item?.variant?.gst_Id?.tax
|
||||
? item?.variant?.gst_Id?.tax
|
||||
: item?.product?.master_GST?.tax
|
||||
)) /
|
||||
100
|
||||
)
|
||||
)
|
||||
).toFixed(3),
|
||||
)?.toFixed(2),
|
||||
}));
|
||||
|
||||
// console.log("line", lineItems[0]);
|
||||
|
@ -129,7 +129,7 @@ export const getAllProductAdmin = async (req, res) => {
|
||||
const total = await Product.countDocuments(obj);
|
||||
const product = await Product.find(obj)
|
||||
.populate({
|
||||
path: "category addedBy variants.gst_Id",
|
||||
path: "category addedBy master_GST variants.gst_Id",
|
||||
select: "name categoryName tax",
|
||||
})
|
||||
.limit(PAGE_SIZE)
|
||||
@ -175,7 +175,7 @@ export const getAllProductUser = async (req, res) => {
|
||||
const total = await Product.countDocuments(obj);
|
||||
const product = await Product.find(obj)
|
||||
.populate({
|
||||
path: "category addedBy variants.gst_Id",
|
||||
path: "category addedBy master_GST variants.gst_Id",
|
||||
select: "name categoryName tax",
|
||||
})
|
||||
.limit(PAGE_SIZE)
|
||||
@ -283,7 +283,7 @@ export const ChangeFeatueProductStatus = async (req, res) => {
|
||||
export const getOneProduct = async (req, res) => {
|
||||
try {
|
||||
const data = await Product.findById(req.params.id).populate({
|
||||
path: "category addedBy variants.gst_Id",
|
||||
path: "category addedBy master_GST variants.gst_Id",
|
||||
select: "name categoryName tax",
|
||||
});
|
||||
if (data) {
|
||||
|
@ -9,32 +9,26 @@ const productSchema = new Schema(
|
||||
required: [true, "Please Enter product Name"],
|
||||
trim: true,
|
||||
},
|
||||
// uniqueId: {
|
||||
// type: String,
|
||||
// required: true,
|
||||
// },
|
||||
|
||||
category: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "CategoryModel",
|
||||
},
|
||||
|
||||
master_price: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
master_GST: {
|
||||
type: mongoose.Schema.ObjectId,
|
||||
ref: "Tax",
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
maxLength: [400, "description cannot exceed 100 characters"],
|
||||
required: [true, "Please Enter product Description"],
|
||||
},
|
||||
|
||||
category: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "CategoryModel",
|
||||
},
|
||||
// gst: {
|
||||
// type: Schema.Types.ObjectId,
|
||||
// ref: "Tax",
|
||||
// },
|
||||
// total_amount: {
|
||||
// type: Number,
|
||||
// required: true,
|
||||
// },
|
||||
// gst_amount: {
|
||||
// type: Number,
|
||||
// required: true,
|
||||
// },
|
||||
special_instructions: {
|
||||
type: String,
|
||||
},
|
||||
@ -48,8 +42,7 @@ const productSchema = new Schema(
|
||||
weight: { type: Number, default: 0 },
|
||||
volume: { type: Number, default: 0 },
|
||||
price: { type: String, default: "" },
|
||||
// gst_Name: { type: String, default: "" },
|
||||
// gst_Rate: { type: String, default: "" },
|
||||
|
||||
gst_Id: {
|
||||
type: mongoose.Schema.ObjectId,
|
||||
ref: "Tax",
|
||||
|
Loading…
Reference in New Issue
Block a user