fix: Update finance controllers
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
61c61e4c2f
commit
494a5f2306
@ -66,7 +66,7 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
* GET /accounts/:id
|
||||
* Obtiene una cuenta por ID
|
||||
*/
|
||||
router.get('/accounts/:id', async (req: Request, res: Response) => {
|
||||
router.get('/accounts/:id', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -75,7 +75,8 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
|
||||
const account = await service.findAccountById(ctx, req.params.id);
|
||||
if (!account) {
|
||||
return res.status(404).json({ error: 'Cuenta no encontrada' });
|
||||
res.status(404).json({ error: 'Cuenta no encontrada' });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json(account);
|
||||
@ -88,7 +89,7 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
* GET /accounts/code/:code
|
||||
* Obtiene una cuenta por código
|
||||
*/
|
||||
router.get('/accounts/code/:code', async (req: Request, res: Response) => {
|
||||
router.get('/accounts/code/:code', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -97,7 +98,8 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
|
||||
const account = await service.findAccountByCode(ctx, req.params.code);
|
||||
if (!account) {
|
||||
return res.status(404).json({ error: 'Cuenta no encontrada' });
|
||||
res.status(404).json({ error: 'Cuenta no encontrada' });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json(account);
|
||||
@ -197,7 +199,7 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
* GET /entries/:id
|
||||
* Obtiene una póliza por ID
|
||||
*/
|
||||
router.get('/entries/:id', async (req: Request, res: Response) => {
|
||||
router.get('/entries/:id', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -206,7 +208,8 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
|
||||
const entry = await service.findEntryById(ctx, req.params.id);
|
||||
if (!entry) {
|
||||
return res.status(404).json({ error: 'Póliza no encontrada' });
|
||||
res.status(404).json({ error: 'Póliza no encontrada' });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json(entry);
|
||||
@ -291,7 +294,7 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
* POST /entries/:id/cancel
|
||||
* Cancela una póliza
|
||||
*/
|
||||
router.post('/entries/:id/cancel', async (req: Request, res: Response) => {
|
||||
router.post('/entries/:id/cancel', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -300,7 +303,8 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
|
||||
const { reason } = req.body;
|
||||
if (!reason) {
|
||||
return res.status(400).json({ error: 'Se requiere motivo de cancelación' });
|
||||
res.status(400).json({ error: 'Se requiere motivo de cancelación' });
|
||||
return;
|
||||
}
|
||||
|
||||
const entry = await service.cancelEntry(ctx, req.params.id, reason);
|
||||
@ -314,7 +318,7 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
* POST /entries/:id/reverse
|
||||
* Reversa una póliza
|
||||
*/
|
||||
router.post('/entries/:id/reverse', async (req: Request, res: Response) => {
|
||||
router.post('/entries/:id/reverse', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -323,7 +327,8 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
|
||||
const { reason } = req.body;
|
||||
if (!reason) {
|
||||
return res.status(400).json({ error: 'Se requiere motivo de reverso' });
|
||||
res.status(400).json({ error: 'Se requiere motivo de reverso' });
|
||||
return;
|
||||
}
|
||||
|
||||
const entry = await service.reverseEntry(ctx, req.params.id, reason);
|
||||
@ -360,7 +365,7 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
* GET /reports/account-ledger/:accountId
|
||||
* Obtiene mayor de una cuenta
|
||||
*/
|
||||
router.get('/reports/account-ledger/:accountId', async (req: Request, res: Response) => {
|
||||
router.get('/reports/account-ledger/:accountId', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -371,7 +376,8 @@ export function createAccountingController(dataSource: DataSource): Router {
|
||||
const endDate = new Date(req.query.endDate as string);
|
||||
|
||||
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
||||
return res.status(400).json({ error: 'Fechas inválidas' });
|
||||
res.status(400).json({ error: 'Fechas inválidas' });
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await service.getAccountLedger(ctx, req.params.accountId, startDate, endDate);
|
||||
|
||||
@ -92,7 +92,7 @@ export function createAPController(dataSource: DataSource): Router {
|
||||
* GET /payment-schedule
|
||||
* Obtiene calendario de pagos
|
||||
*/
|
||||
router.get('/payment-schedule', async (req: Request, res: Response) => {
|
||||
router.get('/payment-schedule', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -103,7 +103,8 @@ export function createAPController(dataSource: DataSource): Router {
|
||||
const endDate = new Date(req.query.endDate as string);
|
||||
|
||||
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
||||
return res.status(400).json({ error: 'Fechas inválidas' });
|
||||
res.status(400).json({ error: 'Fechas inválidas' });
|
||||
return;
|
||||
}
|
||||
|
||||
const options = {
|
||||
@ -122,7 +123,7 @@ export function createAPController(dataSource: DataSource): Router {
|
||||
* GET /:id
|
||||
* Obtiene una cuenta por pagar por ID
|
||||
*/
|
||||
router.get('/:id', async (req: Request, res: Response) => {
|
||||
router.get('/:id', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const ctx = {
|
||||
tenantId: req.headers['x-tenant-id'] as string,
|
||||
@ -131,7 +132,8 @@ export function createAPController(dataSource: DataSource): Router {
|
||||
|
||||
const ap = await service.findById(ctx, req.params.id);
|
||||
if (!ap) {
|
||||
return res.status(404).json({ error: 'Cuenta por pagar no encontrada' });
|
||||
res.status(404).json({ error: 'Cuenta por pagar no encontrada' });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json(ap);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user