mirror of
https://origin.cursor.com/mrdevmx/panels.git
synced 2026-10-09 19:23:19 +00:00
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Implementa el módulo **Programa de obra** por proyecto, vinculado al presupuesto ya existente. ### Flujo 1. Cargar presupuesto (requisito) 2. Definir fechas de inicio/término en el proyecto 3. Crear programa: **importar Excel Neodata/Opus**, **generar automático** o **crear vacío** 4. Editar en cuadrícula (conceptos con `Barra=` y partidas con erogaciones semanales) 5. Visualizar Gantt resumido y comparativo **programado vs ejecutado** ### Backend - Tablas: `work_programs`, `work_program_periods`, `work_program_concept_slots`, `work_program_partida_amounts`, `work_program_progress` - RPC: list/get, replace (import), generate (wizard), update celdas, recalculate partidas, vs-cost - Parser Excel para formatos **por concepto** (`Barra=`) y **por partida** (montos semanales) - Tests con fixtures reales del usuario ### Frontend - Nueva página `/programa-obra` con pestañas: Conceptos, Partidas, Gantt, Programado vs costos - Diálogos de importación y generación automática - Menú principal, enlace en ficha de proyecto, banner en presupuesto ### Permisos Reutiliza `manage_budget` en MVP. ## Test plan - [x] `deno test api/work_program_excel_test.ts` (5 tests) - [x] `deno check` API modules - [x] `npm run build` web-panel - [ ] Migrar DB (`029`, `030`) en entorno con Postgres - [ ] Importar Excel por concepto y por partida en obra con presupuesto - [ ] Generar automático con estrategia keyword - [ ] Recalcular partidas desde conceptos - [ ] Verificar tab Programado vs costos con gastos registrados <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-3985fe74-d26b-4506-bd4d-f9ad57374141?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-3985fe74-d26b-4506-bd4d-f9ad57374141&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
81 lines
4.4 KiB
SQL
81 lines
4.4 KiB
SQL
--liquibase formatted sql
|
|
-- PANELS · core · programa de obra (cronograma / erogaciones)
|
|
|
|
--changeset panel:core-029a-work-programs endDelimiter:; splitStatements:true
|
|
--preconditions onFail:MARK_RAN
|
|
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='core' AND table_name='work_programs'
|
|
CREATE TABLE core.work_programs (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
project_id INTEGER NOT NULL REFERENCES core.projects(id) ON DELETE CASCADE,
|
|
start_date DATE NOT NULL,
|
|
end_date DATE NOT NULL,
|
|
duration_days INTEGER NOT NULL,
|
|
period_unit TEXT NOT NULL DEFAULT 'week' CHECK (period_unit IN ('week')),
|
|
source TEXT NOT NULL DEFAULT 'manual' CHECK (source IN ('import', 'wizard', 'manual')),
|
|
status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'active')),
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE (project_id)
|
|
);
|
|
|
|
CREATE INDEX idx_core_work_programs_project ON core.work_programs(project_id);
|
|
|
|
--changeset panel:core-029b-work-program-periods endDelimiter:; splitStatements:true
|
|
--preconditions onFail:MARK_RAN
|
|
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='core' AND table_name='work_program_periods'
|
|
CREATE TABLE core.work_program_periods (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
program_id BIGINT NOT NULL REFERENCES core.work_programs(id) ON DELETE CASCADE,
|
|
period_index INTEGER NOT NULL,
|
|
label TEXT NOT NULL,
|
|
start_date DATE NOT NULL,
|
|
end_date DATE NOT NULL,
|
|
UNIQUE (program_id, period_index)
|
|
);
|
|
|
|
CREATE INDEX idx_core_work_program_periods_program ON core.work_program_periods(program_id);
|
|
|
|
--changeset panel:core-029c-work-program-concept-slots endDelimiter:; splitStatements:true
|
|
--preconditions onFail:MARK_RAN
|
|
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='core' AND table_name='work_program_concept_slots'
|
|
CREATE TABLE core.work_program_concept_slots (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
program_id BIGINT NOT NULL REFERENCES core.work_programs(id) ON DELETE CASCADE,
|
|
budget_item_id BIGINT NOT NULL REFERENCES core.budget_items(id) ON DELETE CASCADE,
|
|
period_id BIGINT NOT NULL REFERENCES core.work_program_periods(id) ON DELETE CASCADE,
|
|
start_pct NUMERIC(6,2) NOT NULL DEFAULT 0,
|
|
end_pct NUMERIC(6,2) NOT NULL DEFAULT 0,
|
|
UNIQUE (program_id, budget_item_id, period_id)
|
|
);
|
|
|
|
CREATE INDEX idx_core_wp_concept_slots_program ON core.work_program_concept_slots(program_id);
|
|
CREATE INDEX idx_core_wp_concept_slots_item ON core.work_program_concept_slots(budget_item_id);
|
|
|
|
--changeset panel:core-029d-work-program-partida-amounts endDelimiter:; splitStatements:true
|
|
--preconditions onFail:MARK_RAN
|
|
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='core' AND table_name='work_program_partida_amounts'
|
|
CREATE TABLE core.work_program_partida_amounts (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
program_id BIGINT NOT NULL REFERENCES core.work_programs(id) ON DELETE CASCADE,
|
|
budget_chapter_id BIGINT NOT NULL REFERENCES core.budget_chapters(id) ON DELETE CASCADE,
|
|
period_id BIGINT NOT NULL REFERENCES core.work_program_periods(id) ON DELETE CASCADE,
|
|
amount NUMERIC(14,2) NOT NULL DEFAULT 0,
|
|
UNIQUE (program_id, budget_chapter_id, period_id)
|
|
);
|
|
|
|
CREATE INDEX idx_core_wp_partida_amounts_program ON core.work_program_partida_amounts(program_id);
|
|
CREATE INDEX idx_core_wp_partida_amounts_chapter ON core.work_program_partida_amounts(budget_chapter_id);
|
|
|
|
--changeset panel:core-029e-work-program-progress endDelimiter:; splitStatements:true
|
|
--preconditions onFail:MARK_RAN
|
|
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='core' AND table_name='work_program_progress'
|
|
CREATE TABLE core.work_program_progress (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
program_id BIGINT NOT NULL REFERENCES core.work_programs(id) ON DELETE CASCADE,
|
|
budget_item_id BIGINT NOT NULL REFERENCES core.budget_items(id) ON DELETE CASCADE,
|
|
period_id BIGINT NOT NULL REFERENCES core.work_program_periods(id) ON DELETE CASCADE,
|
|
pct_complete NUMERIC(6,2) NOT NULL DEFAULT 0 CHECK (pct_complete >= 0 AND pct_complete <= 100),
|
|
UNIQUE (program_id, budget_item_id, period_id)
|
|
);
|
|
|
|
CREATE INDEX idx_core_wp_progress_program ON core.work_program_progress(program_id);
|