Files
tehran_taj/apps/api/src/modules/accounting-sync/accounting-admin.controller.ts
T
s.esmaeiliandClaude Opus 4.6 19d490e790 feat: accounting integration (D27), SMS relay driver (D26), rebuild user apps
- Add Tahesab/Zarrin accounting sync module with admin panel UI
- Add SMS relay driver as default provider, refactor SMS into driver pattern
- Update customer services, orders, products, and catalog queries
- Rebuild user-app and user-app-v2 dist assets
- Add Prisma migration for accounting tables
- Update docker-compose and env examples
- Update parity docs (DECISIONS, ISSUES, PROGRESS)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-10-06 16:48:36 +03:30

108 lines
2.7 KiB
TypeScript

import { Body, Controller, Delete, Get, HttpCode, Param, Post, Put, Query } from '@nestjs/common';
import { CurrentAdmin, RequirePermission } from '../auth/guards';
import type { AuthenticatedAdmin } from '../auth/jwt.strategy';
import { AccountingAdminService } from './accounting-admin.service';
/**
* «اتصال حسابداری» (D27) — every route behind `config.accounting`. Nothing
* here ever returns a token: the configuration comes back with tokens reduced
* to `tokenSet` / `tokenReadable` flags.
*/
@Controller('admin/accounting')
@RequirePermission('config.accounting')
export class AccountingAdminController {
constructor(private readonly admin: AccountingAdminService) {}
@Get()
overview() {
return this.admin.overview();
}
@Put('config')
save(@Body() body: Record<string, unknown>) {
return this.admin.save(body);
}
@Post('test')
@HttpCode(200)
test(@Body() body: { provider?: string; connection?: Record<string, unknown> }) {
return this.admin.test(body?.provider, body?.connection);
}
@Post('certificate')
@HttpCode(200)
certificate(@Body() body: { baseUrl?: string }) {
return this.admin.certificate(body?.baseUrl);
}
@Get('options')
options(@Query('provider') provider?: string) {
return this.admin.options(provider);
}
@Post('run/:job')
@HttpCode(200)
run(@Param('job') job: string) {
return this.admin.run(job);
}
@Get('outbox')
outbox(@Query() q: Record<string, unknown>) {
return this.admin.outbox(q);
}
@Post('outbox/:id/retry')
@HttpCode(200)
retry(@Param('id') id: string) {
return this.admin.retry(id);
}
@Post('outbox/:id/resolve')
@HttpCode(200)
resolve(@Param('id') id: string, @CurrentAdmin() me: AuthenticatedAdmin, @Body() body: { note?: string }) {
return this.admin.resolve(id, me.id, body?.note);
}
@Get('issues')
issues(@Query() q: Record<string, unknown>) {
return this.admin.issues(q);
}
@Post('issues/:id/resolve')
@HttpCode(200)
resolveIssue(@Param('id') id: string) {
return this.admin.resolveIssue(id);
}
@Get('links')
links(@Query() q: Record<string, unknown>) {
return this.admin.links(q);
}
@Post('links')
@HttpCode(200)
link(@Body() body: Record<string, unknown>) {
return this.admin.manualLink(body);
}
@Delete('links/:id')
unlink(@Param('id') id: string) {
return this.admin.unlink(id);
}
@Get('customers/:id')
customer(@Param('id') id: string) {
return this.admin.customer(id);
}
@Get('products/status')
productsStatus(@Query('ids') ids: string) {
return this.admin.productsStatus(ids);
}
@Get('movement')
movement(@Query() q: Record<string, unknown>) {
return this.admin.movement(q);
}
}