Checkpoint: Ajout de 3 champs métier aux factures (Service concerné, Type d'achat, Ventilation comptable) avec interface d'administration pour gérer les listes enrichissables. Les champs apparaissent dans la liste des factures et dans le formulaire d'édition.
This commit is contained in:
@@ -29,6 +29,13 @@ import {
|
||||
getLlmLogsByInvoice,
|
||||
getImportSettingsByUser,
|
||||
upsertImportSettings,
|
||||
getDepartmentsByUser,
|
||||
createDepartment,
|
||||
deleteDepartment,
|
||||
getAccountingAllocationsByUser,
|
||||
createAccountingAllocation,
|
||||
deleteAccountingAllocation,
|
||||
initializeDefaultLists,
|
||||
} from "./db";
|
||||
import { loginLocal, hashPassword, getAzureAuthUrl, isAzureAdConfigured, generateToken } from "./auth";
|
||||
import { extractInvoicesWithMistral, generateMetadataJSON } from "./invoiceExtractor";
|
||||
@@ -297,6 +304,9 @@ export const appRouter = router({
|
||||
deliveryNoteNumber: z.string().optional(),
|
||||
orderNumber: z.string().optional(),
|
||||
totalAmount: z.string().optional(),
|
||||
serviceConcerne: z.string().optional(),
|
||||
typeAchat: z.enum(["CAPEX", "OPEX"]).optional(),
|
||||
ventilationComptable: z.string().optional(),
|
||||
}),
|
||||
}))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
@@ -670,6 +680,72 @@ export const appRouter = router({
|
||||
return settings;
|
||||
}),
|
||||
}),
|
||||
|
||||
// ============= DEPARTMENT LIST ROUTES =============
|
||||
departments: router({
|
||||
getByUser: protectedProcedure.query(async ({ ctx }) => {
|
||||
return await getDepartmentsByUser(ctx.user.id);
|
||||
}),
|
||||
|
||||
create: protectedProcedure
|
||||
.input(z.object({
|
||||
name: z.string().min(1).max(100),
|
||||
}))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
// Initialize default lists if this is the first department
|
||||
const existing = await getDepartmentsByUser(ctx.user.id);
|
||||
if (existing.length === 0) {
|
||||
await initializeDefaultLists(ctx.user.id);
|
||||
}
|
||||
|
||||
return await createDepartment({
|
||||
userId: ctx.user.id,
|
||||
name: input.name,
|
||||
});
|
||||
}),
|
||||
|
||||
delete: protectedProcedure
|
||||
.input(z.object({
|
||||
id: z.number(),
|
||||
}))
|
||||
.mutation(async ({ input }) => {
|
||||
await deleteDepartment(input.id);
|
||||
return { success: true };
|
||||
}),
|
||||
}),
|
||||
|
||||
// ============= ACCOUNTING ALLOCATION LIST ROUTES =============
|
||||
accountingAllocations: router({
|
||||
getByUser: protectedProcedure.query(async ({ ctx }) => {
|
||||
return await getAccountingAllocationsByUser(ctx.user.id);
|
||||
}),
|
||||
|
||||
create: protectedProcedure
|
||||
.input(z.object({
|
||||
name: z.string().min(1).max(100),
|
||||
}))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
// Initialize default lists if this is the first allocation
|
||||
const existing = await getAccountingAllocationsByUser(ctx.user.id);
|
||||
if (existing.length === 0) {
|
||||
await initializeDefaultLists(ctx.user.id);
|
||||
}
|
||||
|
||||
return await createAccountingAllocation({
|
||||
userId: ctx.user.id,
|
||||
name: input.name,
|
||||
});
|
||||
}),
|
||||
|
||||
delete: protectedProcedure
|
||||
.input(z.object({
|
||||
id: z.number(),
|
||||
}))
|
||||
.mutation(async ({ input }) => {
|
||||
await deleteAccountingAllocation(input.id);
|
||||
return { success: true };
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export type AppRouter = typeof appRouter;
|
||||
|
||||
Reference in New Issue
Block a user