feat: billing period for subscriptions, costs in redundancy analysis

This commit is contained in:
root
2026-07-29 23:46:58 +02:00
parent deabe36727
commit 44cc29b8fe
6 changed files with 109 additions and 14 deletions
+4 -2
View File
@@ -30,11 +30,12 @@ router.post("/tools/:id/costs", requireAuth, requireFeature("costs"), async (req
const [tool] = await db.select().from(toolsTable).where(eq(toolsTable.id, toolId));
if (!tool) { res.status(404).json({ error: "Tool not found" }); return; }
const { licenseType, cost, currency, renewalDate, notes } = req.body;
const { licenseType, billingPeriod, cost, currency, renewalDate, notes } = req.body;
const [entry] = await db.insert(toolCostsTable).values({
toolId,
licenseType: licenseType ?? "free",
billingPeriod: billingPeriod ?? null,
cost: cost ?? null,
currency: currency ?? "EUR",
renewalDate: renewalDate ? new Date(renewalDate) : null,
@@ -53,9 +54,10 @@ router.patch("/costs/:id", requireAuth, async (req, res): Promise<void> => {
const [existing] = await db.select().from(toolCostsTable).where(eq(toolCostsTable.id, id));
if (!existing) { res.status(404).json({ error: "Cost entry not found" }); return; }
const { licenseType, cost, currency, renewalDate, notes } = req.body;
const { licenseType, billingPeriod, cost, currency, renewalDate, notes } = req.body;
const updateData: Record<string, unknown> = {};
if (licenseType !== undefined) updateData.licenseType = licenseType;
if (billingPeriod !== undefined) updateData.billingPeriod = billingPeriod;
if (cost !== undefined) updateData.cost = cost;
if (currency !== undefined) updateData.currency = currency;
if (renewalDate !== undefined) updateData.renewalDate = renewalDate ? new Date(renewalDate) : null;