AG Scroll Settings Budget Push und Rechnungsdokumente umsetzen
All checks were successful
CI / Build and Deploy (push) Successful in 2m20s

This commit is contained in:
jan
2026-05-05 21:57:20 +02:00
parent 99d4f6dd22
commit f87a82e02f
21 changed files with 885 additions and 323 deletions

View File

@@ -34,6 +34,7 @@ export function sanitizeDriveFileName(title: string, fallback = "beleg") {
export async function uploadExpenseProofToDrive(input: {
title: string;
invoiceDate: string;
sequence: number;
fileName: string;
mimeType: string;
buffer: Buffer;
@@ -42,7 +43,7 @@ export async function uploadExpenseProofToDrive(input: {
const folderId = process.env.GOOGLE_DRIVE_FOLDER_ID || DEFAULT_DRIVE_FOLDER_ID;
const extension = input.fileName.includes(".") ? `.${input.fileName.split(".").pop()}` : "";
const baseName = sanitizeDriveFileName(input.title);
const name = `${input.invoiceDate}-${baseName}${extension}`;
const name = `${input.invoiceDate}-${baseName}-${String(input.sequence).padStart(2, "0")}${extension}`;
const response = await drive.files.create({
requestBody: {
@@ -68,5 +69,9 @@ export async function uploadExpenseProofToDrive(input: {
}
});
return response.data.webViewLink ?? `https://drive.google.com/file/d/${response.data.id}/view`;
return {
driveFileId: response.data.id,
proofUrl: response.data.webViewLink ?? `https://drive.google.com/file/d/${response.data.id}/view`,
storedFileName: name
};
}