Archived
Polish onboarding, invoices, and time clock while promoting the first registrant to admin.
Refresh onboarding wizard and shell, tighten invoice edit/detail flows, align timer widgets with the redesigned clock panel, and assign admin role on first signup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -440,20 +440,10 @@ export const invoicesRouter = createTRPCRouter({
|
||||
});
|
||||
}
|
||||
|
||||
if (items && existingInvoice.status !== "draft") {
|
||||
if (existingInvoice.status !== "draft") {
|
||||
throw new TRPCError({
|
||||
code: "FORBIDDEN",
|
||||
message: "Line items can only be edited on draft invoices",
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
cleanInvoiceData.sendReminderAt !== undefined &&
|
||||
existingInvoice.status !== "draft"
|
||||
) {
|
||||
throw new TRPCError({
|
||||
code: "FORBIDDEN",
|
||||
message: "Send reminders can only be set on draft invoices",
|
||||
message: "Only draft invoices can be edited",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { TRPCError } from "@trpc/server";
|
||||
import type { db } from "~/server/db";
|
||||
import {
|
||||
computeTrackedHours,
|
||||
resolveBillingDescription,
|
||||
type ClockOutOutcome,
|
||||
} from "~/lib/time-clock";
|
||||
import { defaultDueDate, generateInvoiceNumber } from "~/lib/draft-invoice";
|
||||
@@ -457,12 +458,13 @@ export const timeEntriesRouter = createTRPCRouter({
|
||||
|
||||
const endedAt = new Date();
|
||||
const hours = computeHours(entry.startedAt, endedAt);
|
||||
const description = input?.description?.trim() ?? entry.description;
|
||||
const rawDescription = input?.description?.trim() ?? entry.description?.trim() ?? "";
|
||||
const billingDescription = resolveBillingDescription(rawDescription);
|
||||
const rate = entry.rate ?? 0;
|
||||
|
||||
const [updated] = await ctx.db
|
||||
.update(timeEntries)
|
||||
.set({ endedAt, hours, description, updatedAt: new Date() })
|
||||
.set({ endedAt, hours, description: rawDescription, updatedAt: new Date() })
|
||||
.where(eq(timeEntries.id, entry.id))
|
||||
.returning();
|
||||
|
||||
@@ -478,7 +480,7 @@ export const timeEntriesRouter = createTRPCRouter({
|
||||
ctx.session.user.id,
|
||||
entry.invoiceId,
|
||||
updated.id,
|
||||
description,
|
||||
billingDescription,
|
||||
hours,
|
||||
rate,
|
||||
endedAt,
|
||||
@@ -490,7 +492,7 @@ export const timeEntriesRouter = createTRPCRouter({
|
||||
ctx.session.user.id,
|
||||
entry.clientId,
|
||||
updated.id,
|
||||
description,
|
||||
billingDescription,
|
||||
hours,
|
||||
rate,
|
||||
endedAt,
|
||||
|
||||
Reference in New Issue
Block a user