Commit Graph

11 Commits

Author SHA1 Message Date
Adrian Flores Cortes
32ac439c76 [TASK-2026-01-25-ERP-INTEGRACIONES] feat: Add payment terminals DDL
- Add schema payment_terminals with 5 tables
- tenant_terminal_configs: Multi-tenant credentials (MercadoPago, Clip)
- terminal_payments: Transaction records
- terminal_webhook_events: Webhook event log
- terminal_retry_queue: Retry queue with exponential backoff
- terminal_payment_links: Payment links
- RLS policies for tenant isolation
- Helper functions for retry calculation and expiration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 01:32:16 -06:00
Adrian Flores Cortes
bc15eec17d [TASK-028] security: Add RLS policies for 43 ERP tables
Creates Row Level Security policies for all ERP module tables:
- products: 2 policies
- inventory: 7 policies
- partners: 2 policies
- sales: 2 policies
- purchases: 2 policies
- billing: 2 policies
- financial: 17 policies
- projects: 6 policies

Total: 43 RLS policies for multi-tenant data isolation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 22:23:28 -06:00
Adrian Flores Cortes
30232a334f [SPRINT-3-DOCS] docs: Add DDL README with numbering documentation
- Created database/ddl/README.md
- Documents DDL file numbering conventions (01-60 ranges)
- Lists all 35 DDL files by domain
- Documents 20 PostgreSQL schemas
- Includes execution order and dependencies
- References Sprint 2 renumbering changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 11:56:54 -06:00
Adrian Flores Cortes
ac54edc855 [SPRINT-2-COHERENCIA] feat: Add missing DDL tables and fix numbering
- Add inventory.lots table (coherence with lot.entity.ts)
- Add inventory.pickings table with ENUMs (coherence with picking.entity.ts)
- Add partners.partner_tax_info table (coherence with partner-tax-info.entity.ts)
- Add partners.partner_segments table (coherence with partner-segment.entity.ts)
- Rename 21-fiscal-catalogs.sql to 26-fiscal-catalogs.sql (fix duplicate with 21-inventory.sql)
- Remove duplicate 25-fiscal-catalogs.sql

Gaps resolved:
- GAP-P1-001: lots DDL added
- GAP-P1-002: pickings DDL added
- GAP-P1-006: partner_tax_info DDL added
- GAP-P1-007: partner_segments DDL added
- GAP-P1-008: DDL numbering fixed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 08:54:32 -06:00
Adrian Flores Cortes
67cb99d4b4 [TASK-2026-01-24-GAPS] feat: Add product attributes DDL + fix numbering
Changes:
- Add 19-product-attributes.sql (attributes, values, variants)
- Rename 21-fiscal-catalogs.sql to 25-fiscal-catalogs.sql (fix duplicate 21)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 07:27:58 -06:00
57f41859de [PROJECTS] feat: Add timesheets DDL schema
Add complete projects schema with timesheets support:
- projects.projects table with status, privacy settings
- projects.tasks table with Kanban support
- projects.timesheets table for Odoo-style time tracking
- projects.milestones table for project milestones
- projects.project_stages table for Kanban columns
- projects.project_members table for team management

Includes all necessary indexes and enums for performance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 04:27:58 -06:00
4b6240311d [TASK-2026-01-20-003] feat: Add financial DDL and matching tables
Financial Schema (50-57):
- 50-financial-schema.sql: Schema + 10 ENUMs
- 51-financial-accounts.sql: account_types, accounts, account_mappings
- 52-financial-journals.sql: fiscal_years, fiscal_periods, journals
- 53-financial-entries.sql: journal_entries, journal_entry_lines
- 54-financial-invoices.sql: invoices, invoice_lines
- 55-financial-payments.sql: payments, payment_invoice_allocations
- 56-financial-taxes.sql: taxes, tax_groups
- 57-financial-bank-reconciliation.sql: bank_statements, bank_statement_lines, rules

Purchases Matching (46):
- 46-purchases-matching.sql: purchase_order_matching, purchase_matching_lines, matching_exceptions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 03:47:04 -06:00
1ac7d1e60b feat(fiscal): Add fiscal catalogs DDL schema (MGN-005)
- Add fiscal schema with tax catalog tables:
  - tax_categories (IVA, ISR, IEPS, etc.)
  - fiscal_regimes (SAT c_RegimenFiscal)
  - cfdi_uses (SAT c_UsoCFDI)
  - payment_methods (SAT c_FormaPago)
  - payment_types (SAT c_MetodoPago: PUE/PPD)
  - withholding_types (retention types)
- Include seed data for Mexican SAT catalogs
- Support for CFDI 4.0 compliance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 09:31:36 -06:00
49c64e74a8 feat(catalogs): Add core catalogs DDL and seed data (MGN-005)
DDL (20-core-catalogs.sql):
- Countries, States tables with ISO codes
- Currencies with ISO 4217
- Currency rates with historical tracking
- UoM categories and units with conversion factors
- Product categories hierarchy
- Sequences, Payment terms, Discount rules

Seed data (04-seed-catalogs.sql):
- 33 countries (Americas, Europe, Asia)
- 32 Mexican states with timezones
- 16 currencies (MXN, USD, EUR, etc.)
- Initial exchange rates
- 6 UoM categories with 30+ units

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:57:41 -06:00
5043a640e4 refactor: Restructure DDL with numbered schema files
- Replace old DDL structure with new numbered files (01-24)
- Update migrations and seeds for new schema
- Clean up deprecated files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 00:40:32 -06:00
e4cb9b6db6 Initial commit - erp-core-database 2026-01-04 06:40:22 -06:00