correciones al formulario osp

This commit is contained in:
2026-01-28 22:42:19 -04:00
parent d2908f1e4c
commit 8efe595f73
23 changed files with 9036 additions and 1685 deletions

View File

@@ -46,12 +46,14 @@ export const answersSurveys = t.pgTable(
export const trainingSurveys = t.pgTable(
'training_surveys',
{
// Datos basicos
// === 1. IDENTIFICADORES Y DATOS DE VISITA ===
id: t.serial('id').primaryKey(),
firstname: t.text('firstname').notNull(),
lastname: t.text('lastname').notNull(),
visitDate: t.timestamp('visit_date').notNull(),
// ubicacion
coorPhone: t.text('coor_phone'),
// === 2. UBICACIÓN (Claves Foráneas - Nullables) ===
state: t
.integer('state')
.references(() => states.id, { onDelete: 'set null' }),
@@ -61,93 +63,89 @@ export const trainingSurveys = t.pgTable(
parish: t
.integer('parish')
.references(() => parishes.id, { onDelete: 'set null' }),
siturCodeCommune: t.text('situr_code_commune').notNull(),
// === 3. DATOS DE LA OSP (Organización Socioproductiva) ===
ospType: t.text('osp_type').notNull(), // UPF, EPS, etc.
ecoSector: t.text('eco_sector').notNull().default(''),
productiveSector: t.text('productive_sector').notNull().default(''),
centralProductiveActivity: t
.text('central_productive_activity')
.notNull()
.default(''),
mainProductiveActivity: t
.text('main_productive_activity')
.notNull()
.default(''),
productiveActivity: t.text('productive_activity').notNull(),
ospRif: t.text('osp_rif').notNull(),
ospName: t.text('osp_name').notNull(),
companyConstitutionYear: t.integer('company_constitution_year').notNull(),
currentStatus: t.text('current_status').notNull().default('ACTIVA'),
infrastructureMt2: t.text('infrastructure_mt2').notNull().default(''),
hasTransport: t.boolean('has_transport').notNull().default(false),
structureType: t.text('structure_type').notNull().default(''),
isOpenSpace: t.boolean('is_open_space').notNull().default(false),
paralysisReason: t.text('paralysis_reason'),
equipmentList: t.jsonb('equipment_list').notNull().default([]),
productionList: t.jsonb('production_list').notNull().default([]),
productList: t.jsonb('product_list').notNull().default([]),
ospAddress: t.text('osp_address').notNull(),
ospGoogleMapsLink: t.text('osp_google_maps_link').notNull().default(''),
communeName: t.text('commune_name').notNull().default(''),
siturCodeCommune: t.text('situr_code_commune').notNull(),
communeRif: t.text('commune_rif').notNull().default(''),
communeSpokespersonName: t.text('commune_spokesperson_name').notNull().default(''),
communeSpokespersonCedula: t.text('commune_spokesperson_cedula').notNull().default(''),
communeSpokespersonRif: t.text('commune_spokesperson_rif').notNull().default(''),
communeSpokespersonPhone: t.text('commune_spokesperson_phone').notNull().default(''),
communeSpokespersonName: t
.text('commune_spokesperson_name')
.notNull()
.default(''),
communeSpokespersonCedula: t
.text('commune_spokesperson_cedula')
.notNull()
.default(''),
communeSpokespersonRif: t
.text('commune_spokesperson_rif')
.notNull()
.default(''),
communeSpokespersonPhone: t
.text('commune_spokesperson_phone')
.notNull()
.default(''),
communeEmail: t.text('commune_email').notNull().default(''),
communalCouncil: t.text('communal_council').notNull(),
siturCodeCommunalCouncil: t.text('situr_code_communal_council').notNull(),
communalCouncilRif: t.text('communal_council_rif').notNull().default(''),
communalCouncilSpokespersonName: t.text('communal_council_spokesperson_name').notNull().default(''),
communalCouncilSpokespersonCedula: t.text('communal_council_spokesperson_cedula').notNull().default(''),
communalCouncilSpokespersonRif: t.text('communal_council_spokesperson_rif').notNull().default(''),
communalCouncilSpokespersonPhone: t.text('communal_council_spokesperson_phone').notNull().default(''),
communalCouncilEmail: t.text('communal_council_email').notNull().default(''),
ospGoogleMapsLink: t.text('osp_google_maps_link').notNull().default(''),
// datos del OSP (ORGANIZACIÓN SOCIOPRODUCTIVA)
ospName: t.text('osp_name').notNull(),
ospAddress: t.text('osp_address').notNull(),
ospRif: t.text('osp_rif').notNull(),
ospType: t.text('osp_type').notNull(),
productiveActivity: t.text('productive_activity').notNull(),
financialRequirementDescription: t
.text('financial_requirement_description')
communalCouncilSpokespersonName: t
.text('communal_council_spokesperson_name')
.notNull()
.default(''),
communalCouncilSpokespersonCedula: t
.text('communal_council_spokesperson_cedula')
.notNull()
.default(''),
communalCouncilSpokespersonRif: t
.text('communal_council_spokesperson_rif')
.notNull()
.default(''),
communalCouncilSpokespersonPhone: t
.text('communal_council_spokesperson_phone')
.notNull()
.default(''),
communalCouncilEmail: t
.text('communal_council_email')
.notNull()
.default(''),
currentStatus: t.text('current_status').notNull().default('ACTIVA'),
companyConstitutionYear: t.integer('company_constitution_year').notNull(),
producerCount: t.integer('producer_count').notNull(),
productCount: t.integer('product_count').notNull().default(0),
productDescription: t.text('product_description').notNull(),
installedCapacity: t.text('installed_capacity').notNull(),
operationalCapacity: t.text('operational_capacity').notNull(),
// datos del responsable
ospResponsibleFullname: t.text('osp_responsible_fullname').notNull(),
ospResponsibleCedula: t.text('osp_responsible_cedula').notNull(),
ospResponsibleRif: t.text('osp_responsible_rif').notNull(),
civilState: t.text('civil_state').notNull(),
ospResponsiblePhone: t.text('osp_responsible_phone').notNull(),
ospResponsibleEmail: t.text('osp_responsible_email').notNull(),
civilState: t.text('civil_state').notNull(),
familyBurden: t.integer('family_burden').notNull(),
numberOfChildren: t.integer('number_of_children').notNull(),
// datos adicionales
generalObservations: t.text('general_observations').notNull(),
paralysisReason: t.text('paralysis_reason').notNull(),
// fotos
photo1: t.text('photo1').notNull(),
generalObservations: t.text('general_observations'),
photo1: t.text('photo1'),
photo2: t.text('photo2'),
photo3: t.text('photo3'),
// nuevos campos coordinacion
coorState: t
.integer('coor_state')
.references(() => states.id, { onDelete: 'set null' }),
coorMunicipality: t
.integer('coor_municipality')
.references(() => municipalities.id, { onDelete: 'set null' }),
coorParish: t
.integer('coor_parish')
.references(() => parishes.id, { onDelete: 'set null' }),
coorPhone: t.text('coor_phone'),
// sectores
ecoSector: t.text('eco_sector').notNull().default(''),
productiveSector: t.text('productive_sector').notNull().default(''),
centralProductiveActivity: t.text('central_productive_activity').notNull().default(''),
mainProductiveActivity: t.text('main_productive_activity').notNull().default(''),
// equipamiento
typesOfEquipment: t.text('types_of_equipment').notNull().default(''),
equipmentCount: t.integer('equipment_count').notNull().default(0),
equipmentDescription: t.text('equipment_description').notNull().default(''),
// materia prima
rawMaterial: t.text('raw_material').notNull().default(''),
materialType: t.text('material_type').notNull().default(''),
rawMaterialCount: t.integer('raw_material_count').notNull().default(0),
// conteo de productos
productCountDaily: t.integer('product_count_daily').notNull().default(0),
productCountWeekly: t.integer('product_count_weekly').notNull().default(0),
productCountMonthly: t.integer('product_count_monthly').notNull().default(0),
// nuevos campos adicionales
prodDescriptionInternal: t.text('prod_description_internal').notNull().default(''),
internalCount: t.integer('internal_count').notNull().default(0),
externalCount: t.integer('external_count').notNull().default(0),
prodDescriptionExternal: t.text('prod_description_external').notNull().default(''),
country: t.text('country').notNull().default(''),
city: t.text('city').notNull().default(''),
menCount: t.integer('men_count').notNull().default(0),
womenCount: t.integer('women_count').notNull().default(0),
...timestamps,
},
(trainingSurveys) => ({