diff --git a/server/src/internal/api/entities/handlers/handleDeleteEntity.ts b/server/src/internal/api/entities/handlers/handleDeleteEntity.ts index fb78600c4..b7e8cc102 100644 --- a/server/src/internal/api/entities/handlers/handleDeleteEntity.ts +++ b/server/src/internal/api/entities/handlers/handleDeleteEntity.ts @@ -172,99 +172,6 @@ export const handleDeleteEntity = async (req: any, res: any) => { return res.status(200).json({ success: true, }); - - // const linkedCusEnts = findLinkedCusEnts({ - // cusEnts: cusEnt.customer_product.customer_entitlements, - // feature: cusEnt.entitlement.feature, - // }); - - // if (!cusPriceExists || org.config.prorate_unused) { - // let cusEnts = cusProductsToCusEnts({ cusProducts }); - // for (const cusEnt of cusEnts) { - // let relatedCusPrice = getRelatedCusPrice( - // cusEnt, - // cusProducts.flatMap((p: any) => p.customer_prices), - // ); - // await removeEntityFromCusEnt({ - // db, - // cusEnt, - // entity, - // logger, - // cusPrice: relatedCusPrice, - // customer, - // org, - // env, - // }); - // } - - // try { - // let stripeCli = createStripeCli({ org, env }); - // let curSubs = await getStripeSubs({ - // stripeCli, - // subIds: cusProducts.flatMap((p: any) => p.subscription_ids), - // }); - - // for (const cusProduct of cusProducts) { - // if (cusProduct.internal_entity_id !== entity.internal_id) { - // continue; - // } - - // if (cusProduct.status == CusProductStatus.Scheduled) { - // await removeScheduledProduct({ - // req, - // db, - // cusProduct, - // cusProducts, - // org, - // env, - // logger, - // renewCurProduct: false, - // }); - // } else { - // await cancelCurSubs({ - // curCusProduct: cusProduct, - // curSubs, - // stripeCli, - // }); - // } - // } - // } catch (error) { - // logger.error("FAILED TO CANCEL SUBS FOR DELETED ENTITY", error); - // } - - // // Perform deduction on cus ent - // let updateCusEnt = cusEnts.find( - // (e: any) => e.entitlement.feature.id === entity.feature_id, - // ); - // if (updateCusEnt) { - // await CusEntService.increment({ - // db, - // id: updateCusEnt.id, - // amount: 1, - // }); - // } - - // await EntityService.deleteInInternalIds({ - // db, - // internalIds: [entity.internal_id], - // orgId: req.orgId, - // env: req.env, - // }); - // } else { - // await EntityService.update({ - // db, - // internalId: entity.internal_id, - // update: { - // deleted: true, - // }, - // }); - // } - - // logger.info(` ✅ Finished deleting entity ${entity_id}`); - - // res.status(200).json({ - // success: true, - // }); } catch (error) { handleRequestError({ error, req, res, action: "delete entity" }); } diff --git a/server/src/middleware/refreshCacheMiddleware.ts b/server/src/middleware/refreshCacheMiddleware.ts index d511f80b3..0b3170d74 100644 --- a/server/src/middleware/refreshCacheMiddleware.ts +++ b/server/src/middleware/refreshCacheMiddleware.ts @@ -34,6 +34,11 @@ const cusPrefixedUrls = [ url: "/customers/:customer_id/entities", type: "delete", }, + { + method: "DELETE", + url: "/customers/:customer_id/entities/:entity_id", + type: "delete", + }, { method: "POST", url: "/customers/:customer_id/transfer_product",