mirror of
https://origin.cursor.com/mrdevmx/panels.git
synced 2026-10-09 18:03:18 +00:00
Implementa el módulo completo de programa de obra vinculado al presupuesto: - Schema PostgreSQL: work_programs, periods, concept_slots, partida_amounts, progress - RPC: CRUD, import replace, generate wizard, recalculate partidas, vs-cost - API: parser Excel Neodata (concepto Barra= + partida erogaciones), endpoints REST - UI: página /programa-obra con cuadrículas, Gantt, comparativo programado/ejecutado - Integración: menú, ficha proyecto, banner en presupuesto, permiso manage_budget Co-authored-by: alberto.martinez <alberto.martinez@mrdev.mx>
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);
|