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