feat: add payment report notes

This commit is contained in:
Jose Selesan
2026-10-28 16:45:55 -03:00
parent b22b6da2e1
commit b6f22ae67d
13 changed files with 64 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ route.get('/fees', studentSession, validate.query(StudentAttendeeQuerySchema), a
return resultJson(c, await new GetStudentFees().execute(accountId, attendeeId));
});
// multipart/form-data: attendeeId, paymentIds (repeated) and file.
// multipart/form-data: attendeeId, paymentIds (repeated), file and an optional note.
route.post('/payment-reports', studentSession, async (c) => {
const { accountId } = currentStudent(c);
// Reject oversized bodies before buffering them (10 MB + room for the fields).
@@ -35,6 +35,7 @@ route.post('/payment-reports', studentSession, async (c) => {
const attendeeId = form.get('attendeeId');
const paymentIds = form.getAll('paymentIds').filter((value): value is string => typeof value === 'string' && value.length > 0);
const file = form.get('file');
const note = form.get('note');
if (typeof attendeeId !== 'string' || paymentIds.length === 0 || !(file instanceof File)) {
return problemJson(c, validationProblem({ detail: 'Elegí al menos una cuota y adjuntá el comprobante.' }));
}
@@ -42,6 +43,7 @@ route.post('/payment-reports', studentSession, async (c) => {
const result = await new ReportStudentPayment().execute(accountId, {
attendeeId,
paymentIds,
note: typeof note === 'string' ? note : null,
file: { name: file.name, bytes: new Uint8Array(await file.arrayBuffer()) },
});
return resultJson(c, result, { status: 201 });