Commit Graph

72 Commits

Author SHA1 Message Date
Алекс d1f793b1e3 feat: rol de terceros, webhook mejorado y fix pagos
Terceros:
- ClientResponse: campo fournisseur añadido
- CreateClientDto: campo Role (client/supplier/both)
- ClientDto / ClientDetailDto: campo Role devuelto en respuesta
- ClientMapper: ResolveRole() calcula rol desde client+fournisseur de Dolibarr
- ClientService: CreateClientAsync mapea Role a client/fournisseur en Dolibarr

Webhook:
- WebhookSettings: persistencia en archivo data/webhook_url.txt (volumen Docker)
- WebhookNotificationService: fire-and-forget, Adaptive Card 1.2, timeout 8s
- SettingsController: usa UpdateUrl(), endpoint test añadido
- Program.cs: HttpClient Webhook con timeout de 8s
- InvoiceService: notificación también al registrar pago (AddInvoicePaymentAsync)
  + datepaye enviado como Unix timestamp (fix 400 de Dolibarr)
- SupplierInvoiceService: notificación webhook en cambios de estado,
  pago vía payments endpoint con Unix timestamp

compose.yaml: volumen bff_data para persistir webhook_url.txt entre rebuilds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 16:35:17 +02:00
Алекс 9f1295e7d0 Merge branch 'main' of https://github.com/JavMB/dolibarr-bff 2026-05-24 23:57:33 +02:00
Алекс e0ab16f82d ajustes sobre verifactu y el banco 2026-05-24 23:57:22 +02:00
javiermengual 9f12f582a3 actualizar presentacion 2026-05-24 13:32:08 +02:00
Алекс 62bc070115 añadir cosas, apis y ajustes 2026-05-17 00:01:26 +02:00
Алекс 7c6ed689f6 Merge branch 'main' of https://github.com/JavMB/dolibarr-bff 2026-05-15 21:52:37 +02:00
Алекс f2030977ff feat: módulo banco completo (GET/POST/PUT cuentas y movimientos), campos TotalHt/TotalTax en facturas 2026-05-15 21:50:16 +02:00
javiermengual 9d88e475a9 puerto 5000 ocupado cambio a 5001 2026-05-15 20:19:29 +02:00
JavMB 341b0b3841 cors funcionaras o no 2026-05-15 19:59:31 +02:00
JavMB 8f0fff3953 Merge branch 'main' of https://github.com/JavMB/dolibarr-bff 2026-05-15 19:52:20 +02:00
JavMB 8fb5d801cf fix CORS 2026-05-15 19:52:04 +02:00
javiermengual 4e7a97a3b1 presentacion 2026-05-15 19:23:21 +02:00
JavMB 12b1755e86 merge: resolve conflicts with remote — keep local CORS config, merge webhook notifications
- Resolved merge conflicts in Program.cs (kept configurable CORS from local)
- Resolved merge conflicts in DocumentController.cs (kept full controller
  with list/download endpoints from local)
- Integrated remote webhook notification system:
  * INotificationService interface + WebhookNotificationService
  * InvoiceService now sends Teams/Slack webhook on status changes
  * appsettings.json: added Notifications:WebhookUrl config
  * Program.cs: registered INotificationService + Webhook HttpClient
2026-05-15 19:02:32 +02:00
JavMB 545df6d489 feat: add API documentation, fix HttpClient BaseAddress trailing slash
- API_ENDPOINTS.md: complete reference of all 23 endpoints for frontend team
- Program.cs: ensure BaseAddress ends with '/' so relative URLs like
  'login' resolve correctly to 'api/index.php/login' instead of 'api/login'
- DolibarrTokenCacheService: no logic change (same file touched in earlier
  commit for token cache duration)
2026-05-15 18:59:10 +02:00
JavMB fe6bd57796 feat: configure Swagger Bearer auth, fix CORS, Docker and deployment
- Program.cs: added Swagger with JWT Bearer security definition using
  OpenApi v2 API (OpenApiSecuritySchemeReference), enabled Swagger in all
  environments (not just Development), registered all new services
  (ContactService, SetupService) in DI
- CORS: configurable via Cors__AllowedOrigins env var, allows all
  when empty (dev-friendly)
- DoliMiddlewareApi.csproj: removed Microsoft.AspNetCore.OpenApi (conflicts
  with Swashbuckle v10), kept Swashbuckle.AspNetCore 10.1.0
- appsettings.json: fixed Dolibarr ApiUrl to /api/index.php (was /explorer)
- compose.yaml: fixed Dolibarr ApiUrl, added JWT_SECRET default for dev,
  added healthcheck for Dolibarr container, BFF waits for Dolibarr healthy
- .dockerignore: added to keep Docker build clean
- .env.example: template with instructions for JWT_SECRET
2026-05-15 18:58:43 +02:00
JavMB fbbbce3574 feat: add Contacts & Setup controllers, extend Clients/Invoices/Document controllers
- ContactsController: full CRUD (list, get, get by email, create, update, delete)
- SetupController: dictionary endpoints (payment-types, countries, civilities,
  contact-types, payment-terms, company)
- ClientsController: added GET/{id}, POST, PUT/{id}, DELETE/{id}
- InvoicesController: added PUT/{id}/lines/{lineId}, GET /templates
- DocumentController: added GET /list and GET /download endpoints
- ClientService: added GetClientAsync, CreateClientAsync, UpdateClientAsync,
  DeleteClientAsync
- InvoiceService: added UpdateInvoiceLineAsync, GetInvoiceTemplatesAsync
- DocumentService: added GetDocumentsAsync, DownloadDocumentAsync (using
  new GetAsyncRaw on IDolibarrApiClient)
- ContactService: new service with CRUD operations
- SetupService: new service for Dolibarr dictionary data
- IDolibarrApiClient: added GetAsyncRaw method for raw string responses
- DolibarrApiClient: implemented GetAsyncRaw
- JwtTokenProvider: extended token expiry from 30 min to 8 hours
- AuthApplicationService: extended Dolibarr token cache from 30 min to 8 hours
2026-05-15 18:58:35 +02:00
JavMB 32028e21e1 feat: add DTOs, Dolibarr response types and mappers for Contacts, Clients, Setup and invoice lines
- New command DTOs: CreateClientDto, UpdateClientDto, CreateContactDto,
  UpdateContactDto, UpdateInvoiceLineDto
- New query DTOs: ClientDetailDto, ContactDetailDto, Setup dictionaries
  (PaymentTypeDto, CountryDto, CivilityDto, ContactTypeDto,
  PaymentTermDto, CompanyDto)
- New Dolibarr response types for setup endpoints
- SetupMapper for all dictionary transforms
- Extended ClientResponse and ContactResponse with additional fields
  (address, town, zip, country_code, note_public, note_private, etc.)
- ClientMapper: added MapToClientDetailDto for GET /Clients/{id}
- ContactMapper: added MapToContactDetailDto for GET /Contacts/{id}
2026-05-15 18:58:26 +02:00
javiermengual f5ff724341 chore: ignore appsettings.Development.json to prevent secrets leak 2026-05-14 23:00:34 +02:00
javiermengual ef42797b31 feat: add webhook notifications for invoice status changes
Implements INotificationService with Teams/Slack-compatible WebhookNotificationService.
Fires on ValidateInvoice and ChangeInvoiceStatus. Silently skipped if WebhookUrl not configured.
2026-05-14 22:59:31 +02:00
JavMB 256a07f68c Add auth and response docs to DocumentController endpoints 2026-05-14 22:58:43 +02:00
JavMB e58b6c0679 Add auth and response docs to DocumentController endpoints 2026-05-14 20:48:35 +02:00
JavMB a37cb64a19 Add Reveal.js presentation and architecture diagram 2026-05-14 20:48:01 +02:00
JavMB 7c5d24aaa8 quito la api key LOCAL , que puse para debuggear 2026-04-16 19:06:42 +02:00
JM 98312846fa Modifico el endpoint de descargas de pdf , convirtiendo el base64 a binario 2026-04-16 09:41:46 +02:00
JM 6bac2c63fb añado el Controller y metodo para comprobar desde el servicio si existe x documento 2026-04-15 16:49:41 +02:00
JM 0e7bee7e43 empiezo el servicio para descarga de pdfs 2026-04-15 16:29:05 +02:00
javiermengual b7adb8e9cc fix: arreglado error de editar facturas 2026-02-10 12:39:04 +01:00
javiermengual 305a69667d bug: arreglado de perdida de precision en amount , y ajuste de la fecha devuelta de pagos. 2026-02-06 18:47:39 +01:00
javiermengual 0b098376c5 feat : Agrego endpoint Post para Payments 2026-02-06 15:24:47 +01:00
javiermengual 26ad842256 feat : Endpoint Get para los pagos de factura 2026-02-06 13:01:20 +01:00
javiermengual eef2c9954c quito anotaciones de los Controllers para mayor legibilidad. 2026-02-05 14:38:47 +01:00
javiermengual 45913112be feat: Añadido endpoints para Delete Invoice y sus Lines , tambien corregido orden de Dto de GetById 2026-02-05 14:33:03 +01:00
javiermengual 45e4af5b39 feat: Añado mas campos utiles para los terceros 2026-02-05 14:25:13 +01:00
javiermengual 9e888ee985 fix: formateo y eliminar estado invalido cancelled 2026-02-03 17:19:53 +01:00
javiermengual c1c7d4bb37 añado endpoint para validar factura y campo de notas publicas y privadas en los Dtos 2026-02-03 16:50:44 +01:00
javiermengual 7e7a4f48fa fix: Dejo el Like completo porque dolibar lo hace asi internamente. 2026-02-02 11:24:20 +01:00
javiermengual 60a9a7f7db feat: Patch para el status que no dejaba por Update 2026-02-02 11:01:40 +01:00
javiermengual c674ac66d9 fix: las facturas ahora devuelven tmb el nombre del cliente. 2026-01-30 16:52:28 +01:00
javiermengual e729388981 feat : Añado endpoint Get para Clients de dolibar. 2026-01-30 16:34:23 +01:00
javiermengual 161696269d fix: add optional search parameter to GET invoices 2026-01-29 13:26:54 +01:00
javiermengual 8c781308e7 fix: update CORS configuration to include additional origin 2026-01-16 19:07:40 +01:00
javiermengual 72b15eeff6 feat: add CORS configuration and implement unit tests for InvoiceMapper and InvoiceService 2026-01-16 15:43:28 +01:00
javiermengual a1fd7c6418 Arreglar bug de validación de estado y limpiar código de cache
- Añadir método ConvertStatusToDolibarr en InvoiceMapper para mapear todos los estados correctamente (draft, unpaid, paid, cancelled)
- Mover lógica de mapeo de estado desde InvoiceService a InvoiceMapper para seguir principios de SRP
- Arreglar bug donde el estado 'paid' y 'cancelled' se mapeaban incorrectamente a '0' (draft)
- Añadir validación de estado con mensaje de error claro para valores inválidos
- Limpiar código de DolibarrTokenCacheService eliminando bloque anidado innecesario
2026-01-03 20:46:13 +01:00
javiermengual 9a06cc945e fix: arreglo bug porque dolibar devuelve un objeto anidado 2026-01-03 20:31:53 +01:00
javiermengual 283a9e7f5f Implementar autenticación JWT con caché de tokens de Dolibarr por sesión
- Añadir autenticación estándar JWT Bearer con ASP.NET Core
- Crear DolibarrTokenCacheService para la lógica de caché de tokens
- Refactorizar DolibarrApiClient para usar TokenCacheService con SRP limpio
- Actualizar Program.cs con registros de servicios y comentarios apropiados
- Añadir AuthController para el endpoint de login
- Actualizar InvoiceService para usar DolibarrApiClient
2026-01-03 19:55:04 +01:00
javiermengual a80d41feab feat: Primera parte de la implementacion de autentificacion, para obtener la DOLIAPIKEY del cliente la cual cachearemos asociada a un Id que devolveremos en el JWT de nuestro servidor. 2026-01-03 18:12:40 +01:00
javiermengual f28461ae0c refactor: extraer interfaz IDolibarrApiClient para facilitar testing
- Crear IDolibarrApiClient con métodos de la API de Dolibarr
- Implementar interfaz en DolibarrApiClient
- Modificar InvoiceService para depender de IDolibarrApiClient en lugar de la clase concreta
- Actualizar Program.cs para registrar IDolibarrApiClient en el contenedor DI

Esto sigue el Principio de Inversión de Dependencias (DIP) de SOLID,
permitiendo mockear el cliente API en tests unitarios sin conectividad externa.
2026-01-03 14:57:23 +01:00
javiermengual 2e1062cc71 feat: Implemento el subendpoint de POST para las lineas de facturas. 2026-01-02 21:05:46 +01:00
javiermengual a06ac2bdd9 feat: Implementar endpoint PUT para actualizar facturas draft, limitado a campos permitidos por Dolibarr (ref, notas, estado, fecha expiración) y unificar campo 'number' para consistencia 2026-01-02 20:20:58 +01:00
javiermengual 1fd331ac17 feat: Implemento completamente el POST de facturas , usando un objeto anonimo para la request, y devuelvo el id creado. 2026-01-02 19:01:04 +01:00