feat: Implementación CRUD Canillitas, Distribuidores y Precios de Publicación
Backend API:
- Canillitas (`dist_dtCanillas`):
- Implementado CRUD completo (Modelos, DTOs, Repositorio, Servicio, Controlador).
- Lógica para manejo de `Accionista`, `Baja`, `FechaBaja`.
- Auditoría en `dist_dtCanillas_H`.
- Validación de legajo único y lógica de empresa vs accionista.
- Distribuidores (`dist_dtDistribuidores`):
- Implementado CRUD completo (Modelos, DTOs, Repositorio, Servicio, Controlador).
- Auditoría en `dist_dtDistribuidores_H`.
- Creación de saldos iniciales para el nuevo distribuidor en todas las empresas.
- Verificación de NroDoc único y Nombre opcionalmente único.
- Precios de Publicación (`dist_Precios`):
- Implementado CRUD básico (Modelos, DTOs, Repositorio, Servicio, Controlador).
- Endpoints anidados bajo `/publicaciones/{idPublicacion}/precios`.
- Lógica de negocio para cerrar período de precio anterior al crear uno nuevo.
- Lógica de negocio para reabrir período de precio anterior al eliminar el último.
- Auditoría en `dist_Precios_H`.
- Auditoría en Eliminación de Publicaciones:
- Extendido `PublicacionService.EliminarAsync` para eliminar en cascada registros de precios, recargos, porcentajes de pago (distribuidores y canillitas) y secciones de publicación.
- Repositorios correspondientes (`PrecioRepository`, `RecargoZonaRepository`, `PorcPagoRepository`, `PorcMonCanillaRepository`, `PubliSeccionRepository`) actualizados con métodos `DeleteByPublicacionIdAsync` que registran en sus respectivas tablas `_H` (si existen y se implementó la lógica).
- Asegurada la correcta propagación del `idUsuario` para la auditoría en cascada.
- Correcciones de Nulabilidad:
- Ajustados los métodos `MapToDto` y su uso en `CanillaService` y `PublicacionService` para manejar correctamente tipos anulables.
Frontend React:
- Canillitas:
- `canillaService.ts`.
- `CanillaFormModal.tsx` con selectores para Zona y Empresa, y lógica de Accionista.
- `GestionarCanillitasPage.tsx` con filtros, paginación, y acciones (editar, toggle baja).
- Distribuidores:
- `distribuidorService.ts`.
- `DistribuidorFormModal.tsx` con múltiples campos y selector de Zona.
- `GestionarDistribuidoresPage.tsx` con filtros, paginación, y acciones (editar, eliminar).
- Precios de Publicación:
- `precioService.ts`.
- `PrecioFormModal.tsx` para crear/editar períodos de precios (VigenciaD, VigenciaH opcional, precios por día).
- `GestionarPreciosPublicacionPage.tsx` accesible desde la gestión de publicaciones, para listar y gestionar los períodos de precios de una publicación específica.
- Layout:
- Reemplazado el uso de `Grid` por `Box` con Flexbox en `CanillaFormModal`, `GestionarCanillitasPage` (filtros), `DistribuidorFormModal` y `PrecioFormModal` para resolver problemas de tipos y mejorar la consistencia del layout de formularios.
- Navegación:
- Actualizadas las rutas y pestañas para los nuevos módulos y sub-módulos.
This commit is contained in:
46
Frontend/src/services/Distribucion/canillaService.ts
Normal file
46
Frontend/src/services/Distribucion/canillaService.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { CanillaDto } from '../../models/dtos/Distribucion/CanillaDto';
|
||||
import type { CreateCanillaDto } from '../../models/dtos/Distribucion/CreateCanillaDto';
|
||||
import type { UpdateCanillaDto } from '../../models/dtos/Distribucion/UpdateCanillaDto';
|
||||
import type { ToggleBajaCanillaDto } from '../../models/dtos/Distribucion/ToggleBajaCanillaDto';
|
||||
|
||||
|
||||
const getAllCanillas = async (nomApeFilter?: string, legajoFilter?: number, soloActivos?: boolean): Promise<CanillaDto[]> => {
|
||||
const params: Record<string, string | number | boolean> = {};
|
||||
if (nomApeFilter) params.nomApe = nomApeFilter;
|
||||
if (legajoFilter !== undefined && legajoFilter !== null) params.legajo = legajoFilter;
|
||||
if (soloActivos !== undefined) params.soloActivos = soloActivos;
|
||||
|
||||
const response = await apiClient.get<CanillaDto[]>('/canillas', { params });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getCanillaById = async (id: number): Promise<CanillaDto> => {
|
||||
const response = await apiClient.get<CanillaDto>(`/canillas/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createCanilla = async (data: CreateCanillaDto): Promise<CanillaDto> => {
|
||||
const response = await apiClient.post<CanillaDto>('/canillas', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const updateCanilla = async (id: number, data: UpdateCanillaDto): Promise<void> => {
|
||||
await apiClient.put(`/canillas/${id}`, data);
|
||||
};
|
||||
|
||||
const toggleBajaCanilla = async (id: number, data: ToggleBajaCanillaDto): Promise<void> => {
|
||||
// El backend espera el DTO en el cuerpo para este endpoint específico.
|
||||
await apiClient.post(`/canillas/${id}/toggle-baja`, data);
|
||||
};
|
||||
|
||||
|
||||
const canillaService = {
|
||||
getAllCanillas,
|
||||
getCanillaById,
|
||||
createCanilla,
|
||||
updateCanilla,
|
||||
toggleBajaCanilla,
|
||||
};
|
||||
|
||||
export default canillaService;
|
||||
41
Frontend/src/services/Distribucion/distribuidorService.ts
Normal file
41
Frontend/src/services/Distribucion/distribuidorService.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { DistribuidorDto } from '../../models/dtos/Distribucion/DistribuidorDto';
|
||||
import type { CreateDistribuidorDto } from '../../models/dtos/Distribucion/CreateDistribuidorDto';
|
||||
import type { UpdateDistribuidorDto } from '../../models/dtos/Distribucion/UpdateDistribuidorDto';
|
||||
|
||||
const getAllDistribuidores = async (nombreFilter?: string, nroDocFilter?: string): Promise<DistribuidorDto[]> => {
|
||||
const params: Record<string, string> = {};
|
||||
if (nombreFilter) params.nombre = nombreFilter;
|
||||
if (nroDocFilter) params.nroDoc = nroDocFilter;
|
||||
|
||||
const response = await apiClient.get<DistribuidorDto[]>('/distribuidores', { params });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getDistribuidorById = async (id: number): Promise<DistribuidorDto> => {
|
||||
const response = await apiClient.get<DistribuidorDto>(`/distribuidores/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createDistribuidor = async (data: CreateDistribuidorDto): Promise<DistribuidorDto> => {
|
||||
const response = await apiClient.post<DistribuidorDto>('/distribuidores', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const updateDistribuidor = async (id: number, data: UpdateDistribuidorDto): Promise<void> => {
|
||||
await apiClient.put(`/distribuidores/${id}`, data);
|
||||
};
|
||||
|
||||
const deleteDistribuidor = async (id: number): Promise<void> => {
|
||||
await apiClient.delete(`/distribuidores/${id}`);
|
||||
};
|
||||
|
||||
const distribuidorService = {
|
||||
getAllDistribuidores,
|
||||
getDistribuidorById,
|
||||
createDistribuidor,
|
||||
updateDistribuidor,
|
||||
deleteDistribuidor,
|
||||
};
|
||||
|
||||
export default distribuidorService;
|
||||
46
Frontend/src/services/Distribucion/empresaService.ts
Normal file
46
Frontend/src/services/Distribucion/empresaService.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { EmpresaDto } from '../../models/dtos/Distribucion/EmpresaDto';
|
||||
import type { CreateEmpresaDto } from '../../models/dtos/Distribucion/CreateEmpresaDto';
|
||||
import type { UpdateEmpresaDto } from '../../models/dtos/Distribucion/UpdateEmpresaDto';
|
||||
|
||||
const getAllEmpresas = async (nombreFilter?: string, detalleFilter?: string): Promise<EmpresaDto[]> => {
|
||||
const params: Record<string, string> = {};
|
||||
if (nombreFilter) params.nombre = nombreFilter;
|
||||
if (detalleFilter) params.detalle = detalleFilter; // Asegúrate que la API soporte esto
|
||||
|
||||
// Llama a GET /api/empresas
|
||||
const response = await apiClient.get<EmpresaDto[]>('/empresas', { params });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getEmpresaById = async (id: number): Promise<EmpresaDto> => {
|
||||
// Llama a GET /api/empresas/{id}
|
||||
const response = await apiClient.get<EmpresaDto>(`/empresas/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createEmpresa = async (data: CreateEmpresaDto): Promise<EmpresaDto> => {
|
||||
// Llama a POST /api/empresas
|
||||
const response = await apiClient.post<EmpresaDto>('/empresas', data);
|
||||
return response.data; // La API devuelve el objeto creado (201 Created)
|
||||
};
|
||||
|
||||
const updateEmpresa = async (id: number, data: UpdateEmpresaDto): Promise<void> => {
|
||||
// Llama a PUT /api/empresas/{id} (204 No Content en éxito)
|
||||
await apiClient.put(`/empresas/${id}`, data);
|
||||
};
|
||||
|
||||
const deleteEmpresa = async (id: number): Promise<void> => {
|
||||
// Llama a DELETE /api/empresas/{id} (204 No Content en éxito)
|
||||
await apiClient.delete(`/empresas/${id}`);
|
||||
};
|
||||
|
||||
const empresaService = {
|
||||
getAllEmpresas,
|
||||
getEmpresaById,
|
||||
createEmpresa,
|
||||
updateEmpresa,
|
||||
deleteEmpresa,
|
||||
};
|
||||
|
||||
export default empresaService;
|
||||
45
Frontend/src/services/Distribucion/otroDestinoService.ts
Normal file
45
Frontend/src/services/Distribucion/otroDestinoService.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { OtroDestinoDto } from '../../models/dtos/Distribucion/OtroDestinoDto';
|
||||
import type { CreateOtroDestinoDto } from '../../models/dtos/Distribucion/CreateOtroDestinoDto';
|
||||
import type { UpdateOtroDestinoDto } from '../../models/dtos/Distribucion/UpdateOtroDestinoDto';
|
||||
|
||||
const getAllOtrosDestinos = async (nombreFilter?: string): Promise<OtroDestinoDto[]> => {
|
||||
const params: Record<string, string> = {};
|
||||
if (nombreFilter) params.nombre = nombreFilter;
|
||||
|
||||
// Llama a GET /api/otrosdestinos
|
||||
const response = await apiClient.get<OtroDestinoDto[]>('/otrosdestinos', { params });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getOtroDestinoById = async (id: number): Promise<OtroDestinoDto> => {
|
||||
// Llama a GET /api/otrosdestinos/{id}
|
||||
const response = await apiClient.get<OtroDestinoDto>(`/otrosdestinos/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createOtroDestino = async (data: CreateOtroDestinoDto): Promise<OtroDestinoDto> => {
|
||||
// Llama a POST /api/otrosdestinos
|
||||
const response = await apiClient.post<OtroDestinoDto>('/otrosdestinos', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const updateOtroDestino = async (id: number, data: UpdateOtroDestinoDto): Promise<void> => {
|
||||
// Llama a PUT /api/otrosdestinos/{id}
|
||||
await apiClient.put(`/otrosdestinos/${id}`, data);
|
||||
};
|
||||
|
||||
const deleteOtroDestino = async (id: number): Promise<void> => {
|
||||
// Llama a DELETE /api/otrosdestinos/{id}
|
||||
await apiClient.delete(`/otrosdestinos/${id}`);
|
||||
};
|
||||
|
||||
const otroDestinoService = {
|
||||
getAllOtrosDestinos,
|
||||
getOtroDestinoById,
|
||||
createOtroDestino,
|
||||
updateOtroDestino,
|
||||
deleteOtroDestino,
|
||||
};
|
||||
|
||||
export default otroDestinoService;
|
||||
40
Frontend/src/services/Distribucion/precioService.ts
Normal file
40
Frontend/src/services/Distribucion/precioService.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { PrecioDto } from '../../models/dtos/Distribucion/PrecioDto';
|
||||
import type { CreatePrecioDto } from '../../models/dtos/Distribucion/CreatePrecioDto';
|
||||
import type { UpdatePrecioDto } from '../../models/dtos/Distribucion/UpdatePrecioDto';
|
||||
|
||||
// El idPublicacion se pasa en la URL para estos endpoints
|
||||
const getPreciosPorPublicacion = async (idPublicacion: number): Promise<PrecioDto[]> => {
|
||||
const response = await apiClient.get<PrecioDto[]>(`/publicaciones/${idPublicacion}/precios`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getPrecioById = async (idPublicacion: number, idPrecio: number): Promise<PrecioDto> => {
|
||||
const response = await apiClient.get<PrecioDto>(`/publicaciones/${idPublicacion}/precios/${idPrecio}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createPrecio = async (idPublicacion: number, data: CreatePrecioDto): Promise<PrecioDto> => {
|
||||
// Asegurarse que el DTO también contenga el idPublicacion si el backend lo espera en el cuerpo.
|
||||
// En nuestro caso, el CreatePrecioDto ya tiene IdPublicacion.
|
||||
const response = await apiClient.post<PrecioDto>(`/publicaciones/${idPublicacion}/precios`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const updatePrecio = async (idPublicacion: number, idPrecio: number, data: UpdatePrecioDto): Promise<void> => {
|
||||
await apiClient.put(`/publicaciones/${idPublicacion}/precios/${idPrecio}`, data);
|
||||
};
|
||||
|
||||
const deletePrecio = async (idPublicacion: number, idPrecio: number): Promise<void> => {
|
||||
await apiClient.delete(`/publicaciones/${idPublicacion}/precios/${idPrecio}`);
|
||||
};
|
||||
|
||||
const precioService = {
|
||||
getPreciosPorPublicacion,
|
||||
getPrecioById,
|
||||
createPrecio,
|
||||
updatePrecio,
|
||||
deletePrecio,
|
||||
};
|
||||
|
||||
export default precioService;
|
||||
46
Frontend/src/services/Distribucion/publicacionService.ts
Normal file
46
Frontend/src/services/Distribucion/publicacionService.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { PublicacionDto } from '../../models/dtos/Distribucion/PublicacionDto';
|
||||
import type { CreatePublicacionDto } from '../../models/dtos/Distribucion/CreatePublicacionDto';
|
||||
import type { UpdatePublicacionDto } from '../../models/dtos/Distribucion/UpdatePublicacionDto';
|
||||
|
||||
const getAllPublicaciones = async (
|
||||
nombreFilter?: string,
|
||||
idEmpresaFilter?: number,
|
||||
soloHabilitadas?: boolean
|
||||
): Promise<PublicacionDto[]> => {
|
||||
const params: Record<string, string | number | boolean> = {};
|
||||
if (nombreFilter) params.nombre = nombreFilter;
|
||||
if (idEmpresaFilter) params.idEmpresa = idEmpresaFilter;
|
||||
if (soloHabilitadas !== undefined) params.soloHabilitadas = soloHabilitadas;
|
||||
|
||||
const response = await apiClient.get<PublicacionDto[]>('/publicaciones', { params });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getPublicacionById = async (id: number): Promise<PublicacionDto> => {
|
||||
const response = await apiClient.get<PublicacionDto>(`/publicaciones/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createPublicacion = async (data: CreatePublicacionDto): Promise<PublicacionDto> => {
|
||||
const response = await apiClient.post<PublicacionDto>('/publicaciones', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const updatePublicacion = async (id: number, data: UpdatePublicacionDto): Promise<void> => {
|
||||
await apiClient.put(`/publicaciones/${id}`, data);
|
||||
};
|
||||
|
||||
const deletePublicacion = async (id: number): Promise<void> => {
|
||||
await apiClient.delete(`/publicaciones/${id}`);
|
||||
};
|
||||
|
||||
const publicacionService = {
|
||||
getAllPublicaciones,
|
||||
getPublicacionById,
|
||||
createPublicacion,
|
||||
updatePublicacion,
|
||||
deletePublicacion,
|
||||
};
|
||||
|
||||
export default publicacionService;
|
||||
46
Frontend/src/services/Distribucion/zonaService.ts
Normal file
46
Frontend/src/services/Distribucion/zonaService.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import apiClient from '../apiClient';
|
||||
import type { ZonaDto } from '../../models/dtos/Zonas/ZonaDto'; // DTO para recibir listas
|
||||
import type { CreateZonaDto } from '../../models/dtos/Zonas/CreateZonaDto';
|
||||
import type { UpdateZonaDto } from '../../models/dtos/Zonas/UpdateZonaDto';
|
||||
|
||||
const getAllZonas = async (nombreFilter?: string, descripcionFilter?: string): Promise<ZonaDto[]> => {
|
||||
const params: Record<string, string> = {};
|
||||
if (nombreFilter) params.nombre = nombreFilter;
|
||||
if (descripcionFilter) params.descripcion = descripcionFilter; // Asegúrate que la API soporte este filtro si lo necesitas
|
||||
|
||||
// Llama al GET /api/zonas (que por defecto devuelve solo activas según el servicio)
|
||||
const response = await apiClient.get<ZonaDto[]>('/zonas', { params });
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const getZonaById = async (id: number): Promise<ZonaDto> => {
|
||||
// Llama al GET /api/zonas/{id} (que por defecto devuelve solo activas según el servicio)
|
||||
const response = await apiClient.get<ZonaDto>(`/zonas/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const createZona = async (data: CreateZonaDto): Promise<ZonaDto> => {
|
||||
// Llama a POST /api/zonas
|
||||
const response = await apiClient.post<ZonaDto>('/zonas', data);
|
||||
return response.data; // La API devuelve el objeto creado
|
||||
};
|
||||
|
||||
const updateZona = async (id: number, data: UpdateZonaDto): Promise<void> => {
|
||||
// Llama a PUT /api/zonas/{id}
|
||||
await apiClient.put(`/zonas/${id}`, data);
|
||||
};
|
||||
|
||||
const deleteZona = async (id: number): Promise<void> => {
|
||||
// Llama a DELETE /api/zonas/{id} (que hará el soft delete)
|
||||
await apiClient.delete(`/zonas/${id}`);
|
||||
};
|
||||
|
||||
const zonaService = {
|
||||
getAllZonas,
|
||||
getZonaById,
|
||||
createZona,
|
||||
updateZona,
|
||||
deleteZona,
|
||||
};
|
||||
|
||||
export default zonaService;
|
||||
Reference in New Issue
Block a user