Merge pull request #51 from Danakcorp/mrtz

Mrtz
This commit is contained in:
morteza-mortezai
2025-11-05 17:10:00 +03:30
committed by GitHub
2 changed files with 7 additions and 10 deletions
+4 -10
View File
@@ -310,15 +310,7 @@ class CartRepository extends BaseRepository<ICart> {
},
total_discount: {
$sum: {
$add: [
{
$subtract: [
{ $multiply: ["$items.quantity", "$variantDetails.price.retailPrice"] },
{ $multiply: ["$items.quantity", "$variantDetails.price.selling_price"] },
],
},
{ $divide: ["$coupon_discount", { $literal: 1 }] }, // safely adds coupon_discount
],
$multiply: ["$items.quantity", { $subtract: ["$variantDetails.price.retailPrice", "$variantDetails.price.selling_price"] }],
},
},
coupon_discount: { $first: "$coupon_discount" },
@@ -339,7 +331,9 @@ class CartRepository extends BaseRepository<ICart> {
items_count: 1,
payable_price: { $subtract: ["$payable_price", { $ifNull: ["$coupon_discount", 0] }] },
retail_price: 1,
total_discount: 1,
total_discount: {
$add: ["$total_discount", { $ifNull: ["$coupon_discount", 0] }],
},
coupon_discount: 1,
items: 1,
isWholeSale: 1,
+3
View File
@@ -282,6 +282,9 @@ export class ReturnOrderRepo extends BaseRepository<IReturnOrder> {
createdAt: { $first: "$createdAt" },
updatedAt: { $first: "$updatedAt" },
returnOrderItems: { $push: "$returnOrderItems" },
refundReceipt: { $first: "$refundReceipt" },
refundComment: { $first: "$refundComment" },
refundDate: { $first: "$refundDate" },
},
},
]);