feat: add payment report notes
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user