feat: track vendor purchases #1153
| @ -28,7 +28,6 @@ import { | |||||||
| import { config } from "./configService"; | import { config } from "./configService"; | ||||||
| import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel"; | import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel"; | ||||||
| import { fromStoreItem, toStoreItem } from "./itemDataService"; | import { fromStoreItem, toStoreItem } from "./itemDataService"; | ||||||
| import { toMongoDate } from "../helpers/inventoryHelpers"; |  | ||||||
| 
 | 
 | ||||||
| export const getStoreItemCategory = (storeItem: string): string => { | export const getStoreItemCategory = (storeItem: string): string => { | ||||||
|     const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); |     const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); | ||||||
| @ -83,7 +82,6 @@ export const handlePurchase = async ( | |||||||
|                             }) - 1 |                             }) - 1 | ||||||
|                         ]; |                         ]; | ||||||
|                 } |                 } | ||||||
|                 const expiry = new Date(offer.RotatedWeekly ? Date.now() + 7 * 24 * 3600 * 1000 : 2051240400000); |  | ||||||
|                 const historyEntry = vendorPurchases.PurchaseHistory.find(x => x.ItemId == ItemId); |                 const historyEntry = vendorPurchases.PurchaseHistory.find(x => x.ItemId == ItemId); | ||||||
|                 let numPurchased = purchaseRequest.PurchaseParams.Quantity; |                 let numPurchased = purchaseRequest.PurchaseParams.Quantity; | ||||||
|                 if (historyEntry) { |                 if (historyEntry) { | ||||||
| @ -93,7 +91,7 @@ export const handlePurchase = async ( | |||||||
|                     vendorPurchases.PurchaseHistory.push({ |                     vendorPurchases.PurchaseHistory.push({ | ||||||
|                         ItemId: ItemId, |                         ItemId: ItemId, | ||||||
|                         NumPurchased: purchaseRequest.PurchaseParams.Quantity, |                         NumPurchased: purchaseRequest.PurchaseParams.Quantity, | ||||||
|                         Expiry: expiry |                         Expiry: new Date(parseInt(offer.Expiry.$date.$numberLong)) | ||||||
|                     }); |                     }); | ||||||
|                 } |                 } | ||||||
|                 inventoryChanges.RecentVendorPurchases = [ |                 inventoryChanges.RecentVendorPurchases = [ | ||||||
| @ -103,7 +101,7 @@ export const handlePurchase = async ( | |||||||
|                             { |                             { | ||||||
|                                 ItemId: ItemId, |                                 ItemId: ItemId, | ||||||
|                                 NumPurchased: numPurchased, |                                 NumPurchased: numPurchased, | ||||||
|                                 Expiry: toMongoDate(expiry) |                                 Expiry: offer.Expiry | ||||||
|                             } |                             } | ||||||
|                         ] |                         ] | ||||||
|                     } |                     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user