feat: data import module and payment fixes

- Add import module with CSV/Excel template download and bulk import endpoints
- Support client+subscription and outstanding invoice imports with per-row error handling
- Templates include Field Guide sheet with valid plan/area names
- Add manager role to unremitted payments endpoint
- Add createdAt field to remittance history response
This commit is contained in:
kevin-asprec
2026-05-07 06:19:43 +08:00
parent 7f9beaac2b
commit 6ea1f412a1
8 changed files with 8141 additions and 3 deletions

View File

@@ -41,9 +41,10 @@ export class PaymentController {
}
@Get('unremitted')
@Roles('technician', 'collector')
@Roles('technician', 'collector', 'manager')
async getUnremitted(@CurrentUser() user: CurrentUserPayload) {
return this.paymentService.getUnremittedPayments(user.tenantId, user.sub);
const isManager = user.roles?.some((r: string) => ['manager', 'tenant_admin', 'super_admin'].includes(r));
return this.paymentService.getUnremittedPayments(user.tenantId, isManager ? null : user.sub);
}
@Get('remittances')

View File

@@ -151,6 +151,7 @@ export class PaymentService {
// Attach full payment details to each remittance's join records
return remittances.map((r) => ({
...r,
createdAt: r.submittedAt.toISOString(),
payments: r.payments.map((rp) => ({
...rp,
payment: paymentMap.get(rp.paymentId) ?? null,