AG Scroll Settings Budget Push und Rechnungsdokumente umsetzen
All checks were successful
CI / Build and Deploy (push) Successful in 2m20s
All checks were successful
CI / Build and Deploy (push) Successful in 2m20s
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user