306 Commits

Author SHA1 Message Date
mono
539629076f fix: address PR review issues for catalogue images
- Use PNG format instead of JPEG for transparency support
- Non-strict mode only resizes if image width > target width
- Replace CATALOGUE_BACKGROUND_IMAGES_COLOR with CATALOGUE_BACKGROUND_IMAGES_RGBA (tuple default (0,0,0,0))
- Move all inline imports to top of test file
- Add test_resize_non_strict_no_upscale test case
- Add comment explaining settings.DEBUG guard for media serving
2026-06-13 14:57:25 -05:00
mono
7112197ad2 feat: add catalogue image management (#1)
- Add CatalogueImage model with FK to Product
- Add image resize service (strict/non-strict modes with configurable dimensions)
- Add CRUD API endpoints with admin-only write permissions
- Add catalogue_images field to product listing/detail endpoints
- Serve media files in development via static()
- 28 TDD tests covering model, API, permissions, resize, and product listing
2026-06-13 13:39:57 -05:00
7160d64e86 chore: Add fields to list_diplay CustomerAdmin 2026-06-09 15:49:54 -05:00
bb5ef7fed8 feat: Display fields for Customer model in webadmin. 2026-06-09 12:03:22 -05:00
77761ea8cc feat: Add customer information to CatalogSale 2026-06-05 09:11:52 -05:00
ff67720cea Add external_id to CatalogSaleSerializer
- Include external_id field in CatalogSaleSerializer response
- Allows API clients to see if catalog sale has been synced to Tryton
- Maintains consistency with SaleSerializer which already includes external_id
- Backward compatible change (field is nullable)
2026-05-30 21:20:07 -05:00
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
bf69fe88d9 feat: Add staging environment for local production testing
- Add docker-compose.staging.yml with PostgreSQL and Django
- Add .env.staging.example with staging-specific environment variables
- Configure staging settings (DEBUG=False, no SSL redirect for localhost)
- Update settings/__init__.py to support staging environment detection
- Update AGENTS.md with staging environment documentation
- Update .gitignore to exclude .env.staging
- Optimize docker-compose.prod.yml configuration

Staging environment simulates production configuration locally:
- PostgreSQL database (port 5433 to avoid conflicts)
- Gunicorn with 4 workers
- DEBUG=False but HTTP allowed for easier testing
- Separate volumes for static files, media, and logs

Usage:
  cp .env.staging.example .env.staging
  docker compose -f docker-compose.staging.yml up -d
2026-05-10 20:32:42 -05:00
8818246870 feat: Add WhiteNoise for static files serving
- Add whitenoise==6.6.0 to requirements.txt
- Configure WhiteNoise middleware in base settings
- Add WhiteNoise STORAGES configuration for all environments
- Reorder CORS middleware to correct position (before CommonMiddleware)
- Enable automatic Gzip compression and cache busting
- Configure environment-specific settings:
  * Development: autorefresh enabled, use finders
  * Staging: 10min cache, autorefresh for testing
  * Production: 1 year cache, strict mode, optimized

Fixes issue with Django REST Framework static files returning 404
in staging/production environments (DEBUG=False).

WhiteNoise now serves all static files (CSS, JS, images) with:
- Automatic Gzip compression (~84% size reduction)
- Cache busting with content hashing
- Optimized cache headers
- No nginx required for static files
2026-05-10 20:32:30 -05:00
294dbdee91 feat: Add deploy environment, Add pyprojectoml 2026-05-09 19:09:31 -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
mono
7e2c03c81b test: add tests for user role field 2026-03-14 16:27:44 -05:00
mono
83029afd5b feat: add role field to user serializer for menu control
- Endpoint /me/ now returns 'role': 'administrator' or 'role': 'user'
- Uses Django's is_staff to determine administrator role
2026-03-07 17:58:12 -05:00
7c0047b4d3 fix: rm duplicate file. 2026-02-14 15:55:59 -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
e6d2160d2e #29 feat(Auth): add logout and profile. 2025-12-13 16:31:20 -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