2.2.1 - Misc improvements and cleanup
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m3s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m3s
This commit is contained in:
@@ -14,7 +14,6 @@ export const POST: APIRoute = async ({ redirect, locals, params }) => {
|
||||
return new Response("Invoice ID required", { status: 400 });
|
||||
}
|
||||
|
||||
// Fetch invoice to verify existence
|
||||
const invoice = await db
|
||||
.select()
|
||||
.from(invoices)
|
||||
@@ -31,7 +30,6 @@ export const POST: APIRoute = async ({ redirect, locals, params }) => {
|
||||
});
|
||||
}
|
||||
|
||||
// Verify membership
|
||||
const membership = await db
|
||||
.select()
|
||||
.from(members)
|
||||
@@ -48,7 +46,6 @@ export const POST: APIRoute = async ({ redirect, locals, params }) => {
|
||||
}
|
||||
|
||||
try {
|
||||
// Generate next invoice number
|
||||
const lastInvoice = await db
|
||||
.select()
|
||||
.from(invoices)
|
||||
@@ -74,11 +71,6 @@ export const POST: APIRoute = async ({ redirect, locals, params }) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert quote to invoice:
|
||||
// 1. Change type to 'invoice'
|
||||
// 2. Set status to 'draft' (so user can review before sending)
|
||||
// 3. Update number to next invoice sequence
|
||||
// 4. Update issue date to today
|
||||
await db
|
||||
.update(invoices)
|
||||
.set({
|
||||
|
||||
@@ -20,7 +20,6 @@ export const GET: APIRoute = async ({ params, locals }) => {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
// Fetch invoice with related data
|
||||
const invoiceResult = await db
|
||||
.select({
|
||||
invoice: invoices,
|
||||
@@ -39,7 +38,6 @@ export const GET: APIRoute = async ({ params, locals }) => {
|
||||
|
||||
const { invoice, client, organization } = invoiceResult;
|
||||
|
||||
// Verify access
|
||||
const membership = await db
|
||||
.select()
|
||||
.from(members)
|
||||
@@ -55,7 +53,6 @@ export const GET: APIRoute = async ({ params, locals }) => {
|
||||
return new Response("Forbidden", { status: 403 });
|
||||
}
|
||||
|
||||
// Fetch items
|
||||
const items = await db
|
||||
.select()
|
||||
.from(invoiceItems)
|
||||
@@ -66,8 +63,6 @@ export const GET: APIRoute = async ({ params, locals }) => {
|
||||
return new Response("Client not found", { status: 404 });
|
||||
}
|
||||
|
||||
// Generate PDF using Vue PDF
|
||||
// Suppress verbose logging from PDF renderer
|
||||
const originalConsoleLog = console.log;
|
||||
const originalConsoleWarn = console.warn;
|
||||
console.log = () => {};
|
||||
@@ -83,7 +78,6 @@ export const GET: APIRoute = async ({ params, locals }) => {
|
||||
|
||||
const stream = await renderToStream(pdfDocument);
|
||||
|
||||
// Restore console.log
|
||||
console.log = originalConsoleLog;
|
||||
console.warn = originalConsoleWarn;
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ export const POST: APIRoute = async ({
|
||||
const quantity = parseFloat(quantityStr);
|
||||
const unitPriceMajor = parseFloat(unitPriceStr);
|
||||
|
||||
// Convert to cents
|
||||
const unitPrice = Math.round(unitPriceMajor * 100);
|
||||
const amount = Math.round(quantity * unitPrice);
|
||||
|
||||
@@ -77,7 +76,6 @@ export const POST: APIRoute = async ({
|
||||
amount,
|
||||
});
|
||||
|
||||
// Update invoice totals
|
||||
await recalculateInvoiceTotals(invoiceId);
|
||||
|
||||
return redirect(`/dashboard/invoices/${invoiceId}`);
|
||||
|
||||
@@ -20,7 +20,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Invoice ID required", { status: 400 });
|
||||
}
|
||||
|
||||
// Fetch invoice to verify existence and check status
|
||||
const invoice = await db
|
||||
.select()
|
||||
.from(invoices)
|
||||
@@ -31,7 +30,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Invoice not found", { status: 404 });
|
||||
}
|
||||
|
||||
// Verify membership
|
||||
const membership = await db
|
||||
.select()
|
||||
.from(members)
|
||||
@@ -47,7 +45,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
// Only allow editing if draft
|
||||
if (invoice.status !== "draft") {
|
||||
return new Response("Cannot edit a finalized invoice", { status: 400 });
|
||||
}
|
||||
@@ -59,7 +56,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Item ID required", { status: 400 });
|
||||
}
|
||||
|
||||
// Verify item belongs to invoice
|
||||
const item = await db
|
||||
.select()
|
||||
.from(invoiceItems)
|
||||
@@ -73,7 +69,6 @@ export const POST: APIRoute = async ({
|
||||
try {
|
||||
await db.delete(invoiceItems).where(eq(invoiceItems.id, itemId));
|
||||
|
||||
// Update invoice totals
|
||||
await recalculateInvoiceTotals(invoiceId);
|
||||
|
||||
return redirect(`/dashboard/invoices/${invoiceId}`);
|
||||
|
||||
@@ -35,7 +35,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Invalid status", { status: 400 });
|
||||
}
|
||||
|
||||
// Fetch invoice to verify existence and check ownership
|
||||
const invoice = await db
|
||||
.select()
|
||||
.from(invoices)
|
||||
@@ -46,7 +45,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Invoice not found", { status: 404 });
|
||||
}
|
||||
|
||||
// Verify membership
|
||||
const membership = await db
|
||||
.select()
|
||||
.from(members)
|
||||
|
||||
@@ -20,7 +20,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Invoice ID required", { status: 400 });
|
||||
}
|
||||
|
||||
// Fetch invoice to verify existence
|
||||
const invoice = await db
|
||||
.select()
|
||||
.from(invoices)
|
||||
@@ -31,7 +30,6 @@ export const POST: APIRoute = async ({
|
||||
return new Response("Invoice not found", { status: 404 });
|
||||
}
|
||||
|
||||
// Verify membership
|
||||
const membership = await db
|
||||
.select()
|
||||
.from(members)
|
||||
|
||||
Reference in New Issue
Block a user