Checkpoint: Ajout du filtre destinataire dans la liste des factures (dropdown + recherche textuelle), graphique "Top 10 destinataires" et liste détaillée dans le dashboard, filtre destinataire dans les paramètres SFTP (sftpRecipientFilter) avec application lors de l'export
This commit is contained in:
@@ -463,6 +463,7 @@ export const appRouter = router({
|
||||
totalAmountKeywords: z.string().optional(),
|
||||
subscriptionKeywords: z.string().optional(),
|
||||
recipientKeywords: z.string().optional(),
|
||||
sftpRecipientFilter: z.string().optional(),
|
||||
sftpHost: z.string().optional(),
|
||||
sftpPort: z.number().optional(),
|
||||
sftpUsername: z.string().optional(),
|
||||
@@ -750,9 +751,14 @@ export const appRouter = router({
|
||||
if (!config) {
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: "SFTP not configured" });
|
||||
}
|
||||
|
||||
// Load user settings to check recipient filter
|
||||
const userSettings = await getUserSettings(ctx.user.id);
|
||||
const recipientFilter = (userSettings as any)?.sftpRecipientFilter?.trim() || "";
|
||||
|
||||
let successCount = 0;
|
||||
let errorCount = 0;
|
||||
let filteredCount = 0;
|
||||
|
||||
for (const invoiceId of input.invoiceIds) {
|
||||
try {
|
||||
@@ -761,6 +767,15 @@ export const appRouter = router({
|
||||
errorCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Apply recipient filter if configured
|
||||
if (recipientFilter) {
|
||||
const invoiceRecipient = ((invoice as any).recipientName || "").toLowerCase();
|
||||
if (!invoiceRecipient.includes(recipientFilter.toLowerCase())) {
|
||||
filteredCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
await exportInvoiceToSftp(
|
||||
config,
|
||||
@@ -782,7 +797,7 @@ export const appRouter = router({
|
||||
}
|
||||
}
|
||||
|
||||
return { successCount, errorCount };
|
||||
return { successCount, errorCount, filteredCount };
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user