Refinamiento de permisos y ajustes en controles. Añade gestión sobre saldos y visualización. Entre otros..
This commit is contained in:
		
							
								
								
									
										31
									
								
								Frontend/src/services/Contables/saldoService.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Frontend/src/services/Contables/saldoService.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| import apiClient from '../apiClient'; | ||||
| import type { SaldoGestionDto } from '../../models/dtos/Contables/SaldoGestionDto'; | ||||
| import type { AjusteSaldoRequestDto } from '../../models/dtos/Contables/AjusteSaldoRequestDto'; | ||||
|  | ||||
| interface GetSaldosParams { | ||||
|     destino?: 'Distribuidores' | 'Canillas' | ''; | ||||
|     idDestino?: number | string; // Puede ser string si viene de un input antes de convertir | ||||
|     idEmpresa?: number | string; | ||||
| } | ||||
|  | ||||
| const getAllSaldosGestion = async (filters?: GetSaldosParams): Promise<SaldoGestionDto[]> => { | ||||
|     const params: Record<string, string | number> = {}; | ||||
|     if (filters?.destino) params.destino = filters.destino; | ||||
|     if (filters?.idDestino) params.idDestino = Number(filters.idDestino); // Asegurar número | ||||
|     if (filters?.idEmpresa) params.idEmpresa = Number(filters.idEmpresa); // Asegurar número | ||||
|  | ||||
|     const response = await apiClient.get<SaldoGestionDto[]>('/saldos', { params }); | ||||
|     return response.data; | ||||
| }; | ||||
|  | ||||
| const ajustarSaldo = async (data: AjusteSaldoRequestDto): Promise<SaldoGestionDto> => { // Esperamos el saldo actualizado | ||||
|     const response = await apiClient.post<SaldoGestionDto>('/saldos/ajustar', data); | ||||
|     return response.data; | ||||
| }; | ||||
|  | ||||
| const saldoService = { | ||||
|     getAllSaldosGestion, | ||||
|     ajustarSaldo, | ||||
| }; | ||||
|  | ||||
| export default saldoService; | ||||
		Reference in New Issue
	
	Block a user