From d78d32b8de7f4a48dd2bc1dca1a75dc69c7f52ce Mon Sep 17 00:00:00 2001 From: Sainan Date: Tue, 11 Mar 2025 16:54:01 +0100 Subject: [PATCH] use the expiry from the offer --- src/services/purchaseService.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 6a24b6c6..07d46ef5 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -28,7 +28,6 @@ import { import { config } from "./configService"; import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel"; import { fromStoreItem, toStoreItem } from "./itemDataService"; -import { toMongoDate } from "../helpers/inventoryHelpers"; export const getStoreItemCategory = (storeItem: string): string => { const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); @@ -83,7 +82,6 @@ export const handlePurchase = async ( }) - 1 ]; } - const expiry = new Date(offer.RotatedWeekly ? Date.now() + 7 * 24 * 3600 * 1000 : 2051240400000); const historyEntry = vendorPurchases.PurchaseHistory.find(x => x.ItemId == ItemId); let numPurchased = purchaseRequest.PurchaseParams.Quantity; if (historyEntry) { @@ -93,7 +91,7 @@ export const handlePurchase = async ( vendorPurchases.PurchaseHistory.push({ ItemId: ItemId, NumPurchased: purchaseRequest.PurchaseParams.Quantity, - Expiry: expiry + Expiry: new Date(parseInt(offer.Expiry.$date.$numberLong)) }); } inventoryChanges.RecentVendorPurchases = [ @@ -103,7 +101,7 @@ export const handlePurchase = async ( { ItemId: ItemId, NumPurchased: numPurchased, - Expiry: toMongoDate(expiry) + Expiry: offer.Expiry } ] }