From 0ce2fea56d9545aedb5688e3df9e7d3e428aa14c Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Wed, 10 Dec 2025 16:57:57 +0330 Subject: [PATCH] not round price --- src/modules/product/models/productVariant.model.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/product/models/productVariant.model.ts b/src/modules/product/models/productVariant.model.ts index d3c9086..e1a1248 100644 --- a/src/modules/product/models/productVariant.model.ts +++ b/src/modules/product/models/productVariant.model.ts @@ -67,11 +67,11 @@ const productVariantSchema = new Schema( productVariantSchema.pre("save", function (next) { if (this.price) { if (this.price.retailPrice) { - this.price.retailPrice = Math.round(this.price.retailPrice / 10000) * 10000; + this.price.retailPrice = Number(this.price.retailPrice); const sellingPrice = this.price.discount_percent > 0 ? this.price.retailPrice * ((100 - this.price.discount_percent) / 100) : this.price.retailPrice; - this.price.selling_price = Math.round(sellingPrice / 10000) * 10000; + this.price.selling_price = Number(sellingPrice); } } @@ -84,15 +84,15 @@ productVariantSchema.pre(["findOneAndUpdate", "updateOne", "updateMany"], functi // ensure price object exists in the update object if (update.price && update.price.retailPrice !== undefined) { - const retailPrice = Math.round(update.price.retailPrice / 10000) * 10000; - const discountPercent = Math.round(update.price.discount_percent) || 0; + const retailPrice = Number(update.price.retailPrice); + const discountPercent = update.price.discount_percent || 0; // calculate selling price based on retailPrice and discount_percent const sellingPrice = discountPercent > 0 ? retailPrice * ((100 - discountPercent) / 100) : retailPrice; // set the calculated selling price in the update object update.price.retailPrice = retailPrice; - update.price.selling_price = Math.round(sellingPrice / 10000) * 10000; + update.price.selling_price = Number(sellingPrice); update.price.discount_percent = discountPercent; }