Commit Graph

291 Commits

Author SHA1 Message Date
5e811c802a Add Tryton synchronization for CatalogSale
- Add external_id field to CatalogSale model for tracking synced sales
- Create migration 0047 for external_id field
- Add TrytonCatalogSale and TrytonCatalogSaleLine classes for Tryton RPC format
- Add send_catalog_sales_to_tryton() method to SaleTrytonService
- Create CatalogSalesToTrytonView API endpoint (POST)
- Register endpoint at /don_confiao/api/enviar_catalog_sales_a_tryton
- Add test for external_id field functionality
- Catalog sales sync to same Tryton model as Sale (model.sale.sale.create)
- Differentiated by reference 'don_confiao_catalog X' and description 'Venta de catálogo'
- Filters only catalog sales without external_id to avoid duplicates
2026-05-30 21:01:29 -05:00
d4a61b8340 Add catalog sale purchase summary endpoint
- Add CatalogSaleSummarySerializer and CatalogSummarySaleLineSerializer
- Add CatalogSaleSummary API view for GET requests
- Register endpoint at /don_confiao/resumen_compra_catalogo_json/<id>
- Add comprehensive test for catalog sale summary
- Include nested customer and product details in response
- Endpoint returns id, date, customer, and lines with products
2026-05-30 20:32:20 -05:00
52ff61354e chore: remove unused export_csv.py file
El archivo export_csv.py solo contenía el shebang y no era utilizado
en ninguna parte del proyecto. Removido durante la refactorización.
2026-05-29 00:22:47 -05:00
47e87e4204 refactor: organize code by domain-driven design
Refactoriza la estructura del proyecto siguiendo principios de Domain-Driven Design,
organizando serializers, API views y servicios por dominios de negocio.

Cambios principales:

## Serializers (serializers/)
- Dividido serializers.py en módulos por dominio:
  * products.py: ProductSerializer, ListProductSerializer
  * customers.py: CustomerSerializer, ListCustomerSerializer
  * sales.py: SaleSerializer, SaleLineSerializer, CatalogSaleSerializer, etc.
  * payments.py: ReconciliationJarSerializer, PaymentMethodSerializer
  * __init__.py: Exporta todos los serializers para mantener compatibilidad

## API Views (api/)
- Dividido api_views.py en módulos por dominio:
  * products.py: ProductView, ProductsFromTrytonView
  * customers.py: CustomerView, CustomersFromTrytonView
  * sales.py: SaleView, CatalogSaleView, SaleSummary, SalesForTrytonView, SalesToTrytonView
  * payments.py: ReconciliateJarView, ReconciliateJarModelView, PaymentMethodView, SalesForReconciliationView
  * admin.py: AdminCodeValidateView
  * __init__.py: Exporta todas las vistas para facilitar importaciones

## Services Layer (services/tryton/)
- Nueva capa de servicios para lógica de negocio Tryton:
  * client.py: get_tryton_client(), TrytonSale, TrytonLineSale, configuración
  * products.py: ProductTrytonService - sincronización de productos
  * customers.py: CustomerTrytonService - sincronización de clientes
  * sales.py: SaleTrytonService - sincronización de ventas
  * __init__.py: Exporta servicios y utilidades

## Actualización de URLs
- Actualizado urls.py para importar desde nuevos módulos
- Mantiene todas las rutas existentes sin cambios

## Eliminación de archivos antiguos
- Eliminado serializers.py (refactorizado a serializers/)
- Eliminado api_views.py (refactorizado a api/)

## Beneficios
 Cohesión: Código organizado por dominio de negocio
 Separación de responsabilidades: API, Serializers y Services separados
 Mantenibilidad: Archivos más pequeños y enfocados
 Escalabilidad: Fácil agregar nuevos dominios
 Testabilidad: Mejor organización para pruebas por dominio
 Reutilización: Servicios Tryton pueden usarse desde cualquier vista

## Estructura final:
- models/ (ya existía organizado por dominio)
- serializers/ (nuevo, organizado por dominio)
- api/ (nuevo, organizado por dominio)
- services/tryton/ (nuevo, capa de servicios)

Tests: 46 tests pasando ✓
2026-05-29 00:16:18 -05:00
f526330f9e feat: add product activation/deactivation and filtering by active status
- Add 'active' boolean field to Product model with default=True
- Implement ProductView.get_queryset() to filter products by active status
  - Default behavior: return only active products
  - Support query params: ?active=true|false|all
  - Support variations: 1/0, yes/no for true/false
  - Detail operations (GET/PATCH/DELETE by ID) work with all products
- Update ProductSerializer to include 'active' field
- Add comprehensive test suite (11 new tests):
  - Test filtering by active/inactive/all products
  - Test parameter variations (1, yes, 0, no)
  - Test PATCH to activate/deactivate products
  - Test default list behavior after status changes
- Update API documentation in doc/requests.org with examples
- All tests passing (13 product tests + 8 API tests)
2026-05-29 00:01:29 -05:00
7fe336b0ce chore: Improve style code 2026-05-28 20:28:25 -05:00
dde6f7329f fix: catalog sale lines not being created due to wrong field name and missing read_only config
- Changed test payload from 'saleline_set' to 'catalogsaleline_set'
- Removed extraneous fields 'payment_method' and 'catalog_sale' from test data
- Made 'catalog_sale' read_only in CatalogSaleLineSerializer to allow nested creation
2026-05-28 18:56:40 -05:00
a33eef7556 feat: Test create catalog sale 2026-05-28 16:53:26 -05:00
47c18c760d feat: add CatalogSale model with abstract base classes for Sale/SaleLine
- Introduced SaleAbstractModel and SaleLineAbstractModel as abstract bases
- Added CatalogSale and CatalogSaleLine models inheriting from them
- Created migration 0045 for new models
- Added CatalogSaleView, CatalogSaleSerializer with nested line creation
- Registered new models in admin
- Added catalog_sales router endpoint to URLs
- Removed placeholder api/ package (now redundant)
2026-05-28 16:38:45 -05:00
f97b47081c refactor: split models into modules, remove template-based views, and clean up code style
- Split monolithic models.py into models/ package (customers, products, sales, payments, admin)
- Removed forms.py, all HTML templates, and associated template-based views
- Added api/ package with CatalogSaleView placeholder
- Updated all imports across project to use new model paths
- Removed obsolete tests (form, export, purchase, summary tests)
- Removed template-based URL patterns, kept only API endpoints
- Standardized string quotes (single to double) and reformatted code
2026-05-28 15:25:27 -05:00
75c030b554 fix: execution tests 2026-05-28 13:38:37 -05:00
bdf7f6f7cb chore 2026-05-10 21:55:36 -05:00
6bc76282d1 chore: Add external_id to representation 2026-05-09 15:52:56 -05:00
d45dbc4658 Merge pull request 'feat/add_external_id_serializer' (#38) from feat/add_external_id_serializer into main
Reviewed-on: #38
2026-04-11 16:49:46 -05:00
mono
5442a52ff6 feat(Payment): add CREDIT payment method 2026-03-14 23:45:52 -05:00
1e16e6e983 feat: Add exernal_id to serializer issue #34 2026-03-14 18:07:44 -05:00
mono
0d5a34d366 feat: add IsAdministrator permission and protect admin endpoints 2026-03-14 16:37:44 -05:00
7a9034943a feat(API): change to jwt authentication. 2026-02-14 15:12:32 -05:00
fb4c82a94c #29 refactor(Tests): extract to mixin class. 2025-12-13 17:35:20 -05:00
fb3124246c #29 refactor(Tests): extract to mixin class. 2025-12-13 17:34:40 -05:00
f3d3681bc4 #29 fix(Tests): add auth to tests. 2025-12-13 17:10:00 -05:00
f323873d80 #29 feat(Auth): add logout and profile. 2025-12-13 16:30:53 -05:00
b730d24855 #29 feat(Auth): add login. 2025-12-13 12:24:35 -05:00
64f07a2ce2 #27 fix: reconciliation jar. 2025-11-15 17:50:06 -05:00
e1ff427856 feat(tryton): add comment to tryton sale. 2025-11-08 15:34:45 -05:00
f02f754ae7 feat(tryton): add payment method to tryton sale description. 2025-09-05 20:24:13 -05:00
b33937d4a5 feat(Tryton): add self_pick_up in send sale to tryton. 2025-09-05 19:15:26 -05:00
253fcbae27 fix(Tryton): add try except at send sales to tryton. #16 2025-08-30 15:45:13 -05:00
604bbd3ab9 #17 feat(API): add external id to sales on api. 2025-08-30 15:28:50 -05:00
e17b8f6973 style. 2025-08-30 15:25:33 -05:00
e3f571afc5 #17 feat(API): add external id to customers on api. 2025-08-30 15:24:42 -05:00
4dae669397 #14 fix(Tryton): add address on updated customers from tryton. 2025-08-16 16:36:06 -05:00
937fe06de4 #14 feat(Tryton): add address on update customers from tryton. 2025-08-16 16:09:20 -05:00
69185f2460 fix(Tryton Shop): add shops. 2025-08-16 12:24:05 -05:00
5f40b4098c feat(Tryton): handle duplicate named products from tryton. 2025-08-16 10:27:17 -05:00
2e4c6592a3 fix test. 2025-08-16 09:55:20 -05:00
271f9b2942 fix(Tryton): fix import customers from tryton. 2025-08-09 15:27:17 -05:00
4734636b4f feat (Tryton): get customers from tryton. 2025-08-09 14:12:31 -05:00
59fbc8872a #9 feat(Tryton): get products salables from tryton only. 2025-07-27 23:34:07 -05:00
d1e137d387 #9 feat(Tryton): untouched products on sync from tryton. 2025-07-27 23:22:58 -05:00
c33c6f630a #9 feat(Tryton): update products from tryton. 2025-07-27 23:11:34 -05:00
76e525735d #9 feat(Tryton): create products from tryton. 2025-07-27 22:57:44 -05:00
3a5e13624f #9 config(Tryton): read tryton params from environment. 2025-07-20 22:01:34 -05:00
3d9feeac43 #9 feat(Tryton): add address_external_id to tryton. 2025-07-19 19:09:53 -05:00
81e4c0bc0d #9 feat(Customer): add address_external_id field. 2025-07-19 19:04:58 -05:00
cf0f6dc4b5 #9 feat(Tryton): enviar_ventas_a_tryton 2025-07-19 19:00:33 -05:00
1d3160ae92 #9 feat(Product): add unit_external_id field. 2025-07-19 18:17:18 -05:00
ba9ef039f4 #9 feat(Product): add external_id field. 2025-07-19 17:32:35 -05:00
46e7181653 #9 feat(Sale): add external_id field. 2025-07-19 17:28:47 -05:00
62d39c97c0 #9 feat(Sale): add external_id field. 2025-07-19 10:57:28 -05:00