Adrian Flores Cortes
9060cf7715
docs: Update DDL README with comprehensive schema documentation
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:19:23 -06:00
Adrian Flores Cortes
d736622985
[TASK-2026-02-05-EJECUCION-REMEDIATION-ERP-CORE] fix: Complete recreate-database.sh with missing DDL files and schemas
...
- Add 03b-core-companies.sql and 21b-inventory-extended.sql to DDL array
- Add 8 missing schemas to create_base_schemas(): operations, fiscal, payment_terminals, core_settings, reports, financial, hr, projects
- Update validate_database() schema lists to include all 24 schemas
- Verified: 208 tables across 24 schemas created successfully
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 22:07:39 -06:00
Adrian Flores Cortes
02ab2caf26
[TASK-2026-02-05-EJECUCION-REMEDIATION-ERP-CORE] feat: DDL fixes and new schemas
...
- 00-auth-base.sql: Extracted auth.tenants+users from recreate-database.sh
- 03b-core-companies.sql: DDL for auth.companies entity
- 21b-inventory-extended.sql: 7 new tables for inventory entities without DDL
- 24-invoices.sql: billing→operations schema to resolve duplication
- 27/28/29-cfdi: Track existing CFDI DDL files
- recreate-database.sh: Updated ddl_files array (17→43 entries)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 21:52:22 -06:00
Adrian Flores Cortes
c9ddeb8b5a
[TASK-2026-02-03] feat: Add RLS policies to 19-product-attributes.sql
...
- Added Row Level Security for product_attributes, product_variants
- Added tenant isolation policies for related tables
- Prepared for execution in WSL
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:49:41 -06:00
Adrian Flores Cortes
b682fdaaf3
[RBAC-001] feat: Add permissions seed for complete RBAC system
...
- Add 07a-permissions-seed.sql with ~150 permissions covering all ERP modules
- Permissions for: auth, billing, inventory, sales, purchases, partners,
products, financial, hr, crm, projects, reports, system
- Add new roles: accountant, sales, warehouse
- Map ERP profiles to roles
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 00:12:13 -06:00
Adrian Flores Cortes
e964ff4812
feat(ddl): Add DDL for Settings, Reports and HR modules
...
- 30-settings.sql: system_settings, plan_settings, tenant_settings, user_preferences (4 tables)
- 31-reports.sql: report_definitions, executions, schedules, dashboards, widgets (12 tables, 7 enums)
- 45-hr.sql: employees, departments, job_positions, contracts, leave_types, leaves (7 tables, 6 enums)
Includes RLS policies, triggers, and utility functions for each module.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 16:11:51 -06:00
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