|
1
|
-- m?dulo de socio y admisi?n
|
|
2
|
|
|
3
|
create table pais(
|
|
4
|
id int not null,
|
|
5
|
nombre character varying(100) not null,
|
|
6
|
constraint pk_pais primary key(id),
|
|
7
|
constraint uq_pais_nombre unique(nombre)
|
|
8
|
);
|
|
9
|
|
|
10
|
create table ciudad(
|
|
11
|
id int not null,
|
|
12
|
nombre character varying(100) not null,
|
|
13
|
pais_id int not null,
|
|
14
|
constraint pk_ciudad primary key(id),
|
|
15
|
constraint fk_ciudad_pais_id foreign key(pais_id) references pais
|
|
16
|
);
|
|
17
|
|
|
18
|
create table barrio(
|
|
19
|
id int not null,
|
|
20
|
nombre character varying(100) not null,
|
|
21
|
ciudad_id int not null,
|
|
22
|
constraint pk_barrio primary key(id),
|
|
23
|
constraint fk_barrio_ciudad_id foreign key(ciudad_id) references ciudad(id)
|
|
24
|
);
|
|
25
|
|
|
26
|
-- casa propia, alquilada, otros
|
|
27
|
create table tipo_casa(
|
|
28
|
id int not null,
|
|
29
|
nombre character varying(100) not null,
|
|
30
|
constraint pk_tipo_casa primary key(id),
|
|
31
|
constraint uq_tipo_casa_nombre unique(nombre)
|
|
32
|
);
|
|
33
|
|
|
34
|
create table actividad_economica(
|
|
35
|
id int not null,
|
|
36
|
nombre character varying(100) not null,
|
|
37
|
constraint pk_actividad_economica primary key(id),
|
|
38
|
constraint uq_actividad_economica_nombre unique(nombre)
|
|
39
|
);
|
|
40
|
|
|
41
|
create table nivel_academico(
|
|
42
|
id int not null,
|
|
43
|
nombre character varying(100) not null,
|
|
44
|
constraint pk_nivel_academico primary key(id),
|
|
45
|
constraint uq_nivel_academico_nombre unique(nombre)
|
|
46
|
);
|
|
47
|
|
|
48
|
create table estado_civil(
|
|
49
|
id int not null,
|
|
50
|
nombre character varying(100) not null,
|
|
51
|
constraint pk_estado_civil primary key(id),
|
|
52
|
constraint uq_estado_civil_nombre unique(nombre)
|
|
53
|
);
|
|
54
|
|
|
55
|
create table profesion(
|
|
56
|
id int not null,
|
|
57
|
nombre character varying(100) not null,
|
|
58
|
constraint pk_profesion primary key(id),
|
|
59
|
constraint uq_profesion_nombre unique(nombre)
|
|
60
|
);
|
|
61
|
-- entidad para cargo publico
|
|
62
|
create table entidad(
|
|
63
|
id int not null,
|
|
64
|
nombre character varying(100) not null,
|
|
65
|
constraint pk_entidad primary key(id),
|
|
66
|
constraint uq_entidad_nombre unique(nombre)
|
|
67
|
);
|
|
68
|
|
|
69
|
create table cargo(
|
|
70
|
id int not null,
|
|
71
|
nombre character varying(100) not null,
|
|
72
|
constraint pk_cargo primary key(id),
|
|
73
|
constraint uq_cargo_nombre unique(nombre)
|
|
74
|
);
|
|
75
|
|
|
76
|
create table tipo_sociedad(
|
|
77
|
id int not null,
|
|
78
|
nombre character varying(100) not null,
|
|
79
|
constraint pk_tipo_sociedad primary key(id),
|
|
80
|
constraint uq_tipo_sociedad_nombre unique(nombre)
|
|
81
|
);
|
|
82
|
|
|
83
|
create table tipo_parentesco(
|
|
84
|
id int not null,
|
|
85
|
nombre character varying(100) not null,
|
|
86
|
constraint pk_tipo_parentesco primary key(id),
|
|
87
|
constraint uq_tipo_parentesco_nombre unique(nombre)
|
|
88
|
);
|
|
89
|
|
|
90
|
-- asalariado, informal, jubilado
|
|
91
|
create table tipo_ingreso(
|
|
92
|
id int not null,
|
|
93
|
nombre character varying(100) not null,
|
|
94
|
constraint pk_tipo_ingreso primary key(id),
|
|
95
|
constraint uq_tipo_ingreso_nombre unique(nombre)
|
|
96
|
);
|
|
97
|
|
|
98
|
create table estado_socio(
|
|
99
|
id int not null,
|
|
100
|
nombre character varying(100) not null,
|
|
101
|
constraint pk_estado_socio primary key(id),
|
|
102
|
constraint uq_estado_socio_nombre unique(nombre)
|
|
103
|
);
|
|
104
|
|
|
105
|
create table estado(
|
|
106
|
id int not null,
|
|
107
|
nombre character varying(100) not null,
|
|
108
|
constraint pk_estado primary key(id),
|
|
109
|
constraint uq_estado unique(nombre)
|
|
110
|
);
|
|
111
|
|
|
112
|
-- ci, ruc, pasaporte
|
|
113
|
create table tipo_documento(
|
|
114
|
id int not null,
|
|
115
|
nombre character varying(100) not null,
|
|
116
|
constraint pk_tipo_documento primary key(id),
|
|
117
|
constraint uq_tipo_documento_nombre unique(nombre)
|
|
118
|
);
|
|
119
|
|
|
120
|
create table persona(
|
|
121
|
id int not null,
|
|
122
|
nombres_razon_social character varying(100) not null,
|
|
123
|
apellidos character varying(100) not null,
|
|
124
|
tipo_persona char(1) not null,
|
|
125
|
documento_ruc character varying(50) not null,
|
|
126
|
tipo_documento_id int not null,
|
|
127
|
fecha_nacimiento_constitucion date not null,
|
|
128
|
constraint pk_persona primary key(id),
|
|
129
|
constraint ck_persona check ((tipo_persona = ANY (ARRAY['F'::bpchar, 'J'::bpchar]))),
|
|
130
|
constraint fk_persona_tipo_documento_id foreign key(tipo_documento_id) references tipo_documento(id)
|
|
131
|
);
|
|
132
|
|
|
133
|
create table socio(
|
|
134
|
id int not null,
|
|
135
|
persona_id int not null,
|
|
136
|
tipo_persona char(1) not null,
|
|
137
|
socio_nro character varying(100) not null,
|
|
138
|
fecha_nacimiento_constitucion date not null,
|
|
139
|
direccion character varying(200) not null,
|
|
140
|
barrio_id int not null,
|
|
141
|
telefonos character varying(50),
|
|
142
|
celular character varying(50),
|
|
143
|
correo_electronico character varying(50),
|
|
144
|
pais_id int not null,
|
|
145
|
tipo_ingreso_id int not null,
|
|
146
|
estado_socio_id int not null,
|
|
147
|
constraint pk_socio primary key(id),
|
|
148
|
constraint fk_socio_persona_id foreign key(persona_id) references persona(id),
|
|
149
|
constraint ck_socio check ((tipo_persona = ANY (ARRAY['F'::bpchar, 'J'::bpchar]))),
|
|
150
|
constraint fk_socio_estado_socio_id foreign key(estado_socio_id) references estado_socio(id),
|
|
151
|
constraint fk_socio_barrio_id foreign key(barrio_id) references barrio(id),
|
|
152
|
constraint fk_socio_tipo_ingreso_id foreign key(tipo_ingreso_id) references tipo_ingreso(id),
|
|
153
|
constraint fk_socio_pais_id foreign key(pais_id) references pais(id)
|
|
154
|
);
|
|
155
|
|
|
156
|
create table socio_fisico(
|
|
157
|
id int not null,
|
|
158
|
socio_id int not null,
|
|
159
|
es_funcionario boolean not null,
|
|
160
|
es_directivo boolean not null,
|
|
161
|
extranjero boolean not null,
|
|
162
|
cant_personas_cargo int,
|
|
163
|
separacion_bienes boolean not null,
|
|
164
|
grupo_sanguineo character varying(20),
|
|
165
|
ciudad_nacimiento_id int not null,
|
|
166
|
nivel_academico_id int not null,
|
|
167
|
profesion_id int not null,
|
|
168
|
nro_carnet_admision character varying(20),
|
|
169
|
estado_civil_id int not null,
|
|
170
|
constraint pk_socio_fisico primary key(id),
|
|
171
|
constraint fk_socio_fisico_socio_id foreign key(socio_id) references socio(id),
|
|
172
|
constraint fk_socio_fisico_nivel_academico_id foreign key(nivel_academico_id) references nivel_academico(id),
|
|
173
|
constraint fk_socio_fisico_profesion_id foreign key(profesion_id) references profesion(id),
|
|
174
|
constraint fk_socio_fisico_ciudad_nacimiento_id foreign key(ciudad_nacimiento_id) references ciudad(id),
|
|
175
|
constraint fk_socio_fisico_estado_civil_id foreign key(estado_civil_id) references estado_civil(id)
|
|
176
|
);
|
|
177
|
|
|
178
|
create table socio_fisico_domicilio(
|
|
179
|
id int not null,
|
|
180
|
socio_fisico_id int not null,
|
|
181
|
direccion character varying(200) not null,
|
|
182
|
tipo_casa_id int not null,
|
|
183
|
barrio_id int not null,
|
|
184
|
valor_casa numeric,
|
|
185
|
nro_domicilio character varying(20),
|
|
186
|
constraint pk_socio_fisico_domicilio primary key(id),
|
|
187
|
constraint fk_socio_fisico_domicilio_socio_fisico__id foreign key(socio_fisico_id) references socio_fisico(id),
|
|
188
|
constraint fk_socio_fisico_domicilio_tipo_casa_id foreign key(tipo_casa_id) references tipo_casa(id),
|
|
189
|
constraint fk_socio_fisico_domicilio_barrio_id foreign key(barrio_id) references barrio(id)
|
|
190
|
);
|
|
191
|
|
|
192
|
create table socio_fisico_laboral(
|
|
193
|
id int not null,
|
|
194
|
socio_fisico_id int not null,
|
|
195
|
direccion_laboral character varying(200),
|
|
196
|
barrio_id int not null,
|
|
197
|
entidad_id int not null,
|
|
198
|
telefono character varying(50),
|
|
199
|
antiguedad character varying(50),
|
|
200
|
correo character varying(50),
|
|
201
|
activdad_economica_id int not null,
|
|
202
|
actividad_laboral character varying(100),
|
|
203
|
constraint pk_socio_fisico_laboral primary key(id),
|
|
204
|
constraint fk_socio_fisico_laboral_socio_fisico__id foreign key(socio_fisico_id) references socio_fisico(id),
|
|
205
|
constraint fk_socio_fisico_laboral_entidad_id foreign key(entidad_id) references entidad(id),
|
|
206
|
constraint fk_socio_fisico_laboral_barrio_id foreign key(barrio_id) references barrio(id),
|
|
207
|
constraint fk_socio_fisico_laboral_economica_id foreign key(activdad_economica_id) references actividad_economica(id)
|
|
208
|
);
|
|
209
|
|
|
210
|
create table persona_expuesta(
|
|
211
|
id int not null,
|
|
212
|
socio_fisico_id int not null,
|
|
213
|
cargo_laboral_id int not null,
|
|
214
|
cargo_publico boolean not null,
|
|
215
|
entidad_cargo_publico_id int,
|
|
216
|
periodo_inicio int,
|
|
217
|
periodo_fin int,
|
|
218
|
es_conyuge_pariente boolean not null,
|
|
219
|
es_accionista_asociado boolean not null,
|
|
220
|
miembro_gerencia_organizacion boolean not null,
|
|
221
|
es_proveedor_estado boolean not null,
|
|
222
|
registro_informacion_proveedores boolean not null,
|
|
223
|
obs character varying(200),
|
|
224
|
constraint pk_persona_expuesta primary key(id),
|
|
225
|
constraint fk_persona_expuesta_socio_fisico_id foreign key(socio_fisico_id) references socio_fisico(id),
|
|
226
|
constraint fk_persona_expuesta_cargo_laboral_id foreign key(cargo_laboral_id) references cargo(id),
|
|
227
|
constraint fk_persona_expuesta_entidad_cargo_publico_id foreign key(entidad_cargo_publico_id) references entidad(id)
|
|
228
|
);
|
|
229
|
|
|
230
|
create table relacion_persona_expuesta(
|
|
231
|
id int not null,
|
|
232
|
persona_expuesta_id int not null,
|
|
233
|
persona_id int not null,
|
|
234
|
tipo_parentesco_id int,
|
|
235
|
id_licitacion character varying(30),
|
|
236
|
fecha_inicio_contrato date,
|
|
237
|
fecha_fin_contrato date,
|
|
238
|
nro_pregunta character varying(10) not null,
|
|
239
|
constraint pk_relacion_persona_expuesta primary key(id),
|
|
240
|
constraint fk_relacion_persona_expuesta_persona_expuesta_id foreign key(persona_expuesta_id) references persona_expuesta(id),
|
|
241
|
constraint fk_relacion_persona_expuesta_persona_id foreign key(persona_id) references persona(id),
|
|
242
|
constraint fk_relacion_persona_expuesta_tipo_parentesco_id foreign key(tipo_parentesco_id) references tipo_parentesco(id)
|
|
243
|
);
|
|
244
|
|
|
245
|
create table socio_juridico(
|
|
246
|
id int not null,
|
|
247
|
socio_id int not null,
|
|
248
|
pais_residencia_id int not null,
|
|
249
|
actividad_economica_id int not null,
|
|
250
|
proposito_relacion character varying(100) not null,
|
|
251
|
tipo_sociedad_id int not null,
|
|
252
|
tipo_sociedad_otro character varying(100),
|
|
253
|
cant_sucursales int,
|
|
254
|
cant_empleados int,
|
|
255
|
url_web character varying(100),
|
|
256
|
constraint pk_socio_juridico primary key(id),
|
|
257
|
constraint fk_socio_juridico_socio_id foreign key(socio_id) references socio(id),
|
|
258
|
constraint fk_socio_juridico_pais_residencia_id foreign key(pais_residencia_id) references pais(id),
|
|
259
|
constraint fk_socio_juridico_actividad_economica_id foreign key(actividad_economica_id) references actividad_economica(id),
|
|
260
|
constraint fk_socio_juridico_tipo_sociedad_id foreign key(tipo_sociedad_id) references tipo_sociedad(id)
|
|
261
|
);
|
|
262
|
|
|
263
|
create table accionista(
|
|
264
|
id int not null,
|
|
265
|
socio_juridico_id int not null,
|
|
266
|
persona_id int not null,
|
|
267
|
cargo_id int not null,
|
|
268
|
duracion_mandato character varying(30) not null,
|
|
269
|
porcentaje_participacion int, -- para pep
|
|
270
|
direccion_particular character varying(200) not null,
|
|
271
|
telefono character varying(50) not null,
|
|
272
|
constraint pk_accionista primary key(id),
|
|
273
|
constraint fk_accionista_socio_juridico_id foreign key(socio_juridico_id) references socio_juridico(id),
|
|
274
|
constraint fk_accionista_persona_id foreign key(persona_id) references persona(id),
|
|
275
|
constraint fk_accionista_cargo_id foreign key(cargo_id) references cargo(id)
|
|
276
|
);
|
|
277
|
|
|
278
|
create table parentesco(
|
|
279
|
id int not null,
|
|
280
|
socio_fisico_id int not null,
|
|
281
|
persona_id int not null,
|
|
282
|
tipo_parentesco_id int not null,
|
|
283
|
ciudad_nacimiento_id int not null,
|
|
284
|
direccion character varying(200),
|
|
285
|
telefono character varying(50),
|
|
286
|
correo character varying(60),
|
|
287
|
nivel_academico_id int,
|
|
288
|
profesion_id int,
|
|
289
|
entidad_laboral_id int,
|
|
290
|
direccion_laboral character varying(200),
|
|
291
|
barrio_laboral_id int,
|
|
292
|
telefono_laboral character varying(50),
|
|
293
|
cargo_laboral_id int,
|
|
294
|
constraint pk_parentesco primary key(id),
|
|
295
|
constraint fk_parentesco_persona_id foreign key(persona_id) references persona(id),
|
|
296
|
constraint fk_parentesco_socio_fisico_id foreign key(socio_fisico_id) references socio_fisico(id),
|
|
297
|
constraint fk_parentesco_tipo_parentesco_id foreign key(tipo_parentesco_id) references tipo_parentesco(id),
|
|
298
|
constraint fk_parentesco_ciudad_nacimiento_id foreign key(ciudad_nacimiento_id) references ciudad(id),
|
|
299
|
constraint fk_parentesco_nivel_academico_id foreign key(nivel_academico_id) references nivel_academico(id),
|
|
300
|
constraint fk_parentesco_profesion_id foreign key(profesion_id) references profesion(id),
|
|
301
|
constraint fk_parentesco_entidad_laboral_id foreign key(entidad_laboral_id) references entidad(id),
|
|
302
|
constraint fk_parentesco_barrio_laboral_id foreign key(barrio_laboral_id) references barrio(id),
|
|
303
|
constraint fk_parentesco_cargo_laboral_id foreign key(cargo_laboral_id) references cargo(id)
|
|
304
|
);
|
|
305
|
|
|
306
|
create table inmueble(
|
|
307
|
id int not null,
|
|
308
|
socio_id int not null,
|
|
309
|
ciudad_id int not null,
|
|
310
|
finca_nro character varying(50) not null,
|
|
311
|
hipotecado boolean not null,
|
|
312
|
edificado boolean not null,
|
|
313
|
valor_actual numeric not null,
|
|
314
|
cta_cte_catastral character varying(50) not null,
|
|
315
|
superficie_terreno numeric,
|
|
316
|
superficie_edificio numeric,
|
|
317
|
a_nombre_de character varying(100) not null,
|
|
318
|
url_google_maps character varying(200) not null,
|
|
319
|
latitud character varying(50),
|
|
320
|
longitud character varying(50),
|
|
321
|
constraint pk_inmueble primary key(id),
|
|
322
|
constraint fk_inmueble_socio_id foreign key(socio_id) references socio(id),
|
|
323
|
constraint fk_inmueble_ciudad_id foreign key(ciudad_id) references ciudad(id)
|
|
324
|
);
|
|
325
|
|
|
326
|
create table tipo_vehiculo(
|
|
327
|
id int not null,
|
|
328
|
nombre character varying(100) not null,
|
|
329
|
constraint pk_tipo_vehiculo primary key(id),
|
|
330
|
constraint uq_tipo_vehiculo unique(nombre));
|
|
331
|
|
|
332
|
create table marca(
|
|
333
|
id int not null,
|
|
334
|
nombre character varying(100) not null,
|
|
335
|
constraint pk_marca primary key(id),
|
|
336
|
constraint uq_marca unique(nombre));
|
|
337
|
|
|
338
|
create table rodado(
|
|
339
|
id int not null,
|
|
340
|
socio_id int not null,
|
|
341
|
tipo_vehiculo_id int not null,
|
|
342
|
marca_id int not null,
|
|
343
|
modelo character varying(50) not null,
|
|
344
|
a?o_fabricacion int not null,
|
|
345
|
prendado boolean not null,
|
|
346
|
asegurado boolean not null,
|
|
347
|
valor_actual numeric not null,
|
|
348
|
constraint pk_rodado primary key(id),
|
|
349
|
constraint fk_rodado_socio_id foreign key(socio_id) references socio(id),
|
|
350
|
constraint fk_rodado_tipo_vehiculo_id foreign key(tipo_vehiculo_id) references tipo_vehiculo(id),
|
|
351
|
constraint fk_rodado_marca_id foreign key(marca_id) references marca(id)
|
|
352
|
);
|
|
353
|
|
|
354
|
create table cuentas_externas(
|
|
355
|
id int not null,
|
|
356
|
socio_id int not null,
|
|
357
|
entidad_financiera_id int not null,
|
|
358
|
porcentaje_participacion int,
|
|
359
|
nro_cuenta character varying(50) not null,
|
|
360
|
valor numeric not null,
|
|
361
|
modalidad character varying(50) not null,
|
|
362
|
vencimiento date,
|
|
363
|
constraint pk_cuentas_externas primary key(id),
|
|
364
|
constraint fk_cuentas_externas_socio_id foreign key(socio_id) references socio(id),
|
|
365
|
constraint fk_cuentas_externas_entidad_financiera_id foreign key(entidad_financiera_id) references entidad(id));
|
|
366
|
|
|
367
|
create table otros_bienes(
|
|
368
|
id int not null,
|
|
369
|
socio_id int not null,
|
|
370
|
descripcion character varying(100) not null,
|
|
371
|
valor numeric not null,
|
|
372
|
constraint pk_otros_bienes primary key(id),
|
|
373
|
constraint fk_otros_bienes_socio_id foreign key(socio_id) references socio(id)
|
|
374
|
);
|
|
375
|
|
|
376
|
create table deudas_externas(
|
|
377
|
id int not null,
|
|
378
|
socio_id int not null,
|
|
379
|
entidad_financiera_id int not null,
|
|
380
|
vencimiento date,
|
|
381
|
nro_cuota int,
|
|
382
|
garant?a numeric,
|
|
383
|
deuda_inicial numeric,
|
|
384
|
saldo numeric,
|
|
385
|
constraint pk_deudas_externas primary key(id),
|
|
386
|
constraint fk_deudas_externas_socio_id foreign key(socio_id) references socio(id),
|
|
387
|
constraint fk_deudas_externas_entidad_financiera_id foreign key(entidad_financiera_id) references entidad(id)
|
|
388
|
);
|
|
389
|
|
|
390
|
create table referencias(
|
|
391
|
id int not null,
|
|
392
|
socio_id int not null,
|
|
393
|
nombre_completo character varying(100) not null,
|
|
394
|
telefono character varying(50) not null,
|
|
395
|
entidad_id int not null,
|
|
396
|
constraint pk_referencias primary key(id),
|
|
397
|
constraint fk_referencias_socio_id foreign key(socio_id) references socio(id),
|
|
398
|
constraint fk_referencias_entidad_id foreign key(entidad_id) references entidad(id)
|
|
399
|
);
|
|
400
|
|
|
401
|
create table deudas_hipotecarias(
|
|
402
|
id int not null,
|
|
403
|
socio_id int not null,
|
|
404
|
nombre_apellido_acreedor character varying(500) not null,
|
|
405
|
objeto_prendario character varying(50) not null,
|
|
406
|
vencimiento date,
|
|
407
|
importe_deuda numeric,
|
|
408
|
constraint pk_deudas_hipotecarias primary key(id),
|
|
409
|
constraint fk_deudas_hipotecarias_socio_id foreign key(socio_id) references socio(id)
|
|
410
|
);
|
|
411
|
|
|
412
|
create table concepto_renta(
|
|
413
|
id int not null,
|
|
414
|
nombre character varying(100) not null,
|
|
415
|
egreso boolean not null,
|
|
416
|
constraint pk_concepto_renta primary key(id),
|
|
417
|
constraint uq_concepto_renta_nombre unique(nombre)
|
|
418
|
);
|
|
419
|
|
|
420
|
create table renta_mensual(
|
|
421
|
id int not null,
|
|
422
|
socio_id int not null,
|
|
423
|
concepto_renta_id int not null,
|
|
424
|
importe numeric not null,
|
|
425
|
constraint pk_renta_mensual primary key(id),
|
|
426
|
constraint fk_renta_mensual_socio_id foreign key(socio_id) references socio(id),
|
|
427
|
constraint fk_renta_mensual_concepto_renta_id foreign key(concepto_renta_id) references concepto_renta(id)
|
|
428
|
);
|
|
429
|
|
|
430
|
create table socio_historico(
|
|
431
|
id int not null,
|
|
432
|
socio_id int not null,
|
|
433
|
fecha_evento date not null,
|
|
434
|
nro_socio character varying(50),
|
|
435
|
estado_socio_id int not null,
|
|
436
|
obs character varying(50),
|
|
437
|
constraint pk_socio_historico primary key(id),
|
|
438
|
constraint fk_socio_historico_socio_id foreign key(socio_id) references socio(id),
|
|
439
|
constraint fk_socio_historico_estado_socio_id foreign key(estado_socio_id) references estado_socio(id)
|
|
440
|
);
|
|
441
|
|
|
442
|
create table solicitud(
|
|
443
|
id int not null,
|
|
444
|
fecha_solicitud date not null,
|
|
445
|
nro_solicitud character varying(20) not null,
|
|
446
|
fecha_sesion date,
|
|
447
|
acta_nro character varying(50),
|
|
448
|
sesion character varying(50),
|
|
449
|
observacion character varying(200),
|
|
450
|
persona_id int not null,
|
|
451
|
nombre_pariente_proximo character varying(100),
|
|
452
|
telefono_pariente_proximo character varying(50),
|
|
453
|
telefono_vecino_proximo character varying(50),
|
|
454
|
nombre_vecino_proximo character varying(100),
|
|
455
|
constraint pk_solicitud primary key(id),
|
|
456
|
constraint fk_solicitud_persona_id foreign key(persona_id) references persona(id)
|
|
457
|
);
|
|
458
|
|
|
459
|
create table tipo_archivo(
|
|
460
|
id int not null,
|
|
461
|
nombre character varying(100) not null,
|
|
462
|
constraint pk_tipo_archivo primary key(id),
|
|
463
|
constraint uq_tipo_archivo_nombre unique(nombre)
|
|
464
|
);
|
|
465
|
|
|
466
|
create table archivo(
|
|
467
|
id int not null,
|
|
468
|
fecha_subida date not null,
|
|
469
|
tipo_archivo_id int not null,
|
|
470
|
ruta character varying(200) not null,
|
|
471
|
nombre_archivo character varying(100) not null,
|
|
472
|
tipo_extension character varying(30) not null,
|
|
473
|
solicitud_id int,
|
|
474
|
constraint pk_archivo primary key(id),
|
|
475
|
constraint fk_archivo_tipo_archivo_id foreign key(tipo_archivo_id) references tipo_archivo(id),
|
|
476
|
constraint fk_archivo_solicitud_id foreign key(solicitud_id) references solicitud(id)
|
|
477
|
);
|
|
478
|
|
|
479
|
create table tipo_cuenta(
|
|
480
|
id int not null,
|
|
481
|
nombre character varying(100) not null,
|
|
482
|
constraint pk_tipo_cuenta primary key(id),
|
|
483
|
constraint uq_tipo_cuenta_nombre unique(nombre)
|
|
484
|
);
|
|
485
|
|
|
486
|
create table estado_cuenta(
|
|
487
|
id int not null,
|
|
488
|
nombre character varying(100) not null,
|
|
489
|
constraint pk_estado_cuenta primary key(id),
|
|
490
|
constraint uq_estado_cuenta_nombre unique(nombre)
|
|
491
|
);
|
|
492
|
|
|
493
|
create table titular_cuenta(
|
|
494
|
id int not null,
|
|
495
|
cuenta_id int not null,
|
|
496
|
socio_titular_id int not null,
|
|
497
|
co_titular_id int not null,
|
|
498
|
constraint pk_titular_cuenta primary key(id),
|
|
499
|
constraint fk_titular_cuenta_socio_titular_id foreign key(socio_titular_id) references socio(id),
|
|
500
|
constraint fk_titular_cuenta_co_titular_id foreign key(co_titular_id) references persona(id),
|
|
501
|
constraint fk_titular_cuenta_cuenta_id foreign key(cuenta_id) references cuenta(id)
|
|
502
|
);
|
|
503
|
|
|
504
|
-- se preve sucursal?
|
|
505
|
create table cuenta(
|
|
506
|
id int not null,
|
|
507
|
socio_id int not null, --titular de cuenta
|
|
508
|
fecha_apertura date not null,
|
|
509
|
fecha_expiracion date,
|
|
510
|
solicitud_id int,
|
|
511
|
saldo numeric,
|
|
512
|
saldo_promedio numeric,
|
|
513
|
saldo_contable numeric,
|
|
514
|
saldo_bloqueado numeric,
|
|
515
|
saldo_retenido numeric,
|
|
516
|
dias_atraso int,
|
|
517
|
maximo_atraso int,
|
|
518
|
monto_atraso numeric,
|
|
519
|
motivo_cancelacion character varying(100) not null,
|
|
520
|
fecha_cancelacion date,
|
|
521
|
fecha_ultimo_movimiento date,
|
|
522
|
estado_cuenta_id int not null,
|
|
523
|
tipo_cuenta_id int not null,
|
|
524
|
constraint pk_cuenta primary key(id),
|
|
525
|
constraint fk_cuenta_socio_id foreign key(socio_id) references socio(id),
|
|
526
|
constraint fk_cuenta_solicitud_id foreign key(solicitud_id) references solicitud(id),
|
|
527
|
constraint fk_cuenta_estado_cuenta_id foreign key(estado_cuenta_id) references estado_cuenta(id),
|
|
528
|
constraint fk_cuenta_tipo_cuenta_id foreign key(tipo_cuenta_id) references tipo_cuenta(id)
|
|
529
|
);
|
|
530
|
|
|
531
|
create table cuenta_socio(
|
|
532
|
id int not null,
|
|
533
|
persona_id int not null,
|
|
534
|
cuenta_id int not null,
|
|
535
|
es_titular boolean not null,
|
|
536
|
constraint pk_cuenta_socio primary key(id),
|
|
537
|
constraint fk_cuenta_estado_persona_id foreign key(persona_id) references persona(id),
|
|
538
|
constraint fk_cuenta_estado_cuenta_id foreign key(cuenta_id) references cuenta(id)
|
|
539
|
);
|
|
540
|
|
|
541
|
create table aporte(
|
|
542
|
id int not null,
|
|
543
|
cuenta_id int not null,
|
|
544
|
nro_cuota int not null,
|
|
545
|
monto_pagar numeric not null,
|
|
546
|
vencimiento date not null,
|
|
547
|
pagado numeric,
|
|
548
|
descuento numeric,
|
|
549
|
saldo numeric,
|
|
550
|
constraint pk_aporte primary key(id),
|
|
551
|
constraint fk_aporte_cuenta_id foreign key(cuenta_id) references cuenta(id)
|
|
552
|
);
|
|
553
|
|
|
554
|
create table solidaridad(
|
|
555
|
id int not null,
|
|
556
|
cuenta_id int not null,
|
|
557
|
nro_cuota int not null,
|
|
558
|
monto_pagar numeric not null,
|
|
559
|
vencimiento date not null,
|
|
560
|
pagado numeric,
|
|
561
|
descuento numeric,
|
|
562
|
saldo numeric,
|
|
563
|
constraint pk_solidaridad primary key(id),
|
|
564
|
constraint fk_solidaridad_cuenta_id foreign key(cuenta_id) references cuenta(id)
|
|
565
|
);
|
|
566
|
|
|
567
|
-- persona, indistina,
|
|
568
|
create table tipo_ahorro(
|
|
569
|
id int not null,
|
|
570
|
nombre character varying(100) not null,
|
|
571
|
constraint pk_tipo_ahorro primary key(id),
|
|
572
|
constraint uq_tipo_ahorro_nombre unique(nombre)
|
|
573
|
);
|
|
574
|
|
|
575
|
-- a la vista, plazo fijo, etc
|
|
576
|
create table modalidad(
|
|
577
|
id int not null,
|
|
578
|
nombre character varying(100) not null,
|
|
579
|
constraint pk_modalidad primary key(id),
|
|
580
|
constraint uq_modalidad_nombre unique(nombre)
|
|
581
|
);
|
|
582
|
|
|
583
|
create table solicitud_ahorro(
|
|
584
|
id int not null,
|
|
585
|
tipo_ahorro_id int not null,
|
|
586
|
fecha date not null,
|
|
587
|
modalidad_id int not null,
|
|
588
|
socio_id int not null,
|
|
589
|
monto_solicitado numeric,
|
|
590
|
estado_id int not null,
|
|
591
|
constraint pk_solicitud_ahorro primary key(id),
|
|
592
|
constraint fk_solicitud_ahorro_tipo_ahorro_id foreign key(tipo_ahorro_id) references tipo_ahorro(id),
|
|
593
|
constraint fk_solicitud_ahorro_modalidad_id foreign key(modalidad_id) references modalidad(id),
|
|
594
|
constraint fk_solicitud_ahorro_socio_id foreign key(socio_id) references socio(id),
|
|
595
|
constraint fk_solicitud_estado_id foreign key(estado_id) references estado(id)
|
|
596
|
);
|
|
597
|
|
|
598
|
create table ahorro(
|
|
599
|
id int not null,
|
|
600
|
cuenta_id int not null,
|
|
601
|
tipo_cuenta_id int not null,
|
|
602
|
modalidad_id int not null,
|
|
603
|
total_inversion numeric not null,
|
|
604
|
total_interes numeric not null,
|
|
605
|
saldo numeric,
|
|
606
|
plazo int not null,
|
|
607
|
tasa int not null,
|
|
608
|
forma_pago character varying(20),
|
|
609
|
hecho_por character varying(20),
|
|
610
|
verificado_por character varying(20),
|
|
611
|
visto_bueno_por character varying(20),
|
|
612
|
contrato_nro character varying(20),
|
|
613
|
proforma_nro character varying(20),
|
|
614
|
constraint pk_ahorro primary key(id),
|
|
615
|
constraint fk_ahorro_cuenta_id foreign key(cuenta_id) references cuenta(id),
|
|
616
|
constraint fk_ahorro_tipo_cuenta_id foreign key(tipo_cuenta_id) references tipo_cuenta(id),
|
|
617
|
constraint fk_ahorro_modalidad_id foreign key(modalidad_id) references modalidad(id)
|
|
618
|
);
|
|
619
|
|
|
620
|
create table liquidacion_ahorro(
|
|
621
|
id int not null,
|
|
622
|
ahorro_id int not null,
|
|
623
|
nro_cuota int,
|
|
624
|
fecha_vencimiento date not null,
|
|
625
|
monto_capital numeric not null,
|
|
626
|
monto_interes numeric not null,
|
|
627
|
constraint pk_liquidacion_ahorro primary key(id),
|
|
628
|
constraint fk_liquidacion_ahorro_ahorro_id foreign key(ahorro_id) references ahorro(id)
|
|
629
|
);
|
|
630
|
|
|
631
|
-- efectivo, otros banco, cheque
|
|
632
|
create table tipo_deposito(
|
|
633
|
id int not null,
|
|
634
|
nombre character varying(100) not null,
|
|
635
|
constraint pk_tipo_deposito primary key(id),
|
|
636
|
constraint uq_tipo_deposito_nombre unique(nombre)
|
|
637
|
);
|
|
638
|
|
|
639
|
-- bancos para cheques
|
|
640
|
create table institucion_financiera(
|
|
641
|
id int not null,
|
|
642
|
nombre character varying(100) not null,
|
|
643
|
constraint pk_institucion_financiera primary key(id),
|
|
644
|
constraint uq_institucion_financiera_nombre unique(nombre)
|
|
645
|
);
|
|
646
|
|
|
647
|
-- extracci?n/deposito/interes
|
|
648
|
create table movimiento_ahorro(
|
|
649
|
id int not null,
|
|
650
|
ahorro_id int not null,
|
|
651
|
tipo char(3) not null, -- EXT/DEP/INT
|
|
652
|
fecha date not null,
|
|
653
|
depositado_por character varying(100) not null,
|
|
654
|
extraido_por character varying(100) not null,
|
|
655
|
monto numeric not null,
|
|
656
|
saldo numeric,
|
|
657
|
nro_boleta character varying(50),
|
|
658
|
constraint pk_comprobante primary key(id),
|
|
659
|
constraint fk_comprobante_ahorro_id foreign key(ahorro_id) references ahorro(id)
|
|
660
|
);
|
|
661
|
|
|
662
|
create table movimiento_ahorro_tipo_deposito(
|
|
663
|
id int not null,
|
|
664
|
movimiento_ahorro_id int not null,
|
|
665
|
monto_depositado numeric not null,
|
|
666
|
tipo_deposito_id int not null,
|
|
667
|
institucion_financiera_id int,
|
|
668
|
cheque_nro character varying(50) not null,
|
|
669
|
constraint pk_movimiento_ahorro_tipo_deposito primary key(id),
|
|
670
|
constraint fk_movimiento_ahorro_tipo_deposito_tipo_deposito_id foreign key(tipo_deposito_id) references tipo_deposito(id),
|
|
671
|
constraint fk_movimiento_ahorro_tipo_deposito_movimiento_ahorro_id foreign key(movimiento_ahorro_id) references movimiento_ahorro(id),
|
|
672
|
constraint fk_comprobante_tipo_deposito_institucion_financiera_id foreign key(institucion_financiera_id) references institucion_financiera(id)
|
|
673
|
);
|
|
674
|
|
|
675
|
create table tarjeta_debito(
|
|
676
|
id int not null,
|
|
677
|
nro_tarjeta character varying(100) not null,
|
|
678
|
marca_id int, --visa/ mastercard
|
|
679
|
cuenta_id int not null,
|
|
680
|
vencimiento date not null,
|
|
681
|
estado_tarjeta int,
|
|
682
|
constraint pk_tarjeta primary key(id),
|
|
683
|
constraint fk_tarjeta_cuenta_id foreign key(cuenta_id) references ahorro(id)
|
|
684
|
);
|
|
685
|
|
|
686
|
-- m?dulo pr?stamos
|
|
687
|
|
|
688
|
create table destino(
|
|
689
|
id int not null,
|
|
690
|
nombre character varying(100) not null,
|
|
691
|
constraint pk_destino primary key(id),
|
|
692
|
constraint uq_destino_nombre unique(nombre)
|
|
693
|
);
|
|
694
|
|
|
695
|
create table tipo_garantia(
|
|
696
|
id int not null,
|
|
697
|
nombre character varying(100) not null,
|
|
698
|
constraint pk_tipo_garantia primary key(id),
|
|
699
|
constraint uq_tipo_garantia_nombre unique(nombre)
|
|
700
|
);
|
|
701
|
|
|
702
|
create table tipo_plazo(
|
|
703
|
id int not null,
|
|
704
|
nombre character varying(100) not null,
|
|
705
|
constraint pk_tipo_plazo primary key(id),
|
|
706
|
constraint uq_tipo_plazo_nombre unique(nombre)
|
|
707
|
);
|
|
708
|
|
|
709
|
create table archivo_solicitud(
|
|
710
|
id int not null,
|
|
711
|
archivo_id int not null,
|
|
712
|
solicitud_id int not null,
|
|
713
|
constraint pk_archivo_solicitud primary key(id),
|
|
714
|
constraint fk_archivo_solicitud_archivo_id foreign key(archivo_id) references archivo(id),
|
|
715
|
constraint fk_archivo_solicitud_solicitud_id foreign key(solicitud_id) references solicitud(id)
|
|
716
|
);
|
|
717
|
|
|
718
|
create table perfil_economico(
|
|
719
|
id int not null,
|
|
720
|
fecha date not null,
|
|
721
|
persona_id int not null,
|
|
722
|
inmueble_id int not null,
|
|
723
|
rodado_id int not null,
|
|
724
|
cuentas_externas_id int not null,
|
|
725
|
otros_bienes_id int not null,
|
|
726
|
deudas_externas_id int not null,
|
|
727
|
deudas_hipotecarias_id int not null,
|
|
728
|
renta_mensual_id int not null,
|
|
729
|
constraint pk_perfil_economico primary key(id),
|
|
730
|
constraint fk_perfil_economico_persona_id foreign key(persona_id) references persona(id),
|
|
731
|
constraint fk_perfil_economico_inmueble_id foreign key(inmueble_id) references inmueble(id),
|
|
732
|
constraint fk_perfil_economico_rodado_id foreign key(rodado_id) references rodado(id),
|
|
733
|
constraint fk_perfil_economico_cuentas_externas_id foreign key(cuentas_externas_id) references cuentas_externas(id),
|
|
734
|
constraint fk_perfil_economico_otros_bienes_id foreign key(otros_bienes_id) references otros_bienes(id),
|
|
735
|
constraint fk_perfil_economico_deudas_externas_id foreign key(deudas_externas_id) references deudas_externas(id),
|
|
736
|
constraint fk_perfil_economico_deudas_hipotecarias_id foreign key(deudas_hipotecarias_id) references deudas_hipotecarias(id),
|
|
737
|
constraint fk_perfil_economico_renta_mensual_id foreign key(renta_mensual_id) references renta_mensual(id)
|
|
738
|
);
|
|
739
|
|
|
740
|
-- individual, intercooperativo, empleados
|
|
741
|
create table tipo_sujeto_credito(
|
|
742
|
id int not null,
|
|
743
|
nombre character varying(100) not null,
|
|
744
|
constraint pk_tipo_sujeto_credito primary key(id),
|
|
745
|
constraint uq_tipo_sujeto_credito_nombre unique(nombre)
|
|
746
|
);
|
|
747
|
|
|
748
|
-- normal, tarjeta cr?dito, vivienda
|
|
749
|
create table tipo_credito(
|
|
750
|
id int not null,
|
|
751
|
nombre character varying(100) not null,
|
|
752
|
constraint pk_tipo_credito primary key(id),
|
|
753
|
constraint uq_tipo_credito_nombre unique(nombre)
|
|
754
|
);
|
|
755
|
|
|
756
|
create table calificacion_socio(
|
|
757
|
id int not null,
|
|
758
|
socio_id int not null,
|
|
759
|
fecha date not null,
|
|
760
|
calificacion character varying(10) not null,
|
|
761
|
constraint pk_calificacion_socio primary key(id),
|
|
762
|
constraint fk_calificacion_socio_socio_id foreign key(socio_id) references socio(id)
|
|
763
|
);
|
|
764
|
|
|
765
|
create table solicitud_prorroga(
|
|
766
|
id int not null,
|
|
767
|
cuota_id int not null,
|
|
768
|
fecha_solicitud date not null,
|
|
769
|
motivo character varying(100) not null,
|
|
770
|
estado_id int not null,
|
|
771
|
constraint pk_solicitud_prorroga primary key(id),
|
|
772
|
constraint fk_solicitud_prorroga_cuota_id foreign key(cuota_id) references cuota(id),
|
|
773
|
constraint fk_solicitud_prorroga_estado_id foreign key(estado_id) references estado(id)
|
|
774
|
);
|
|
775
|
|
|
776
|
create table solicitud_amplicacion(
|
|
777
|
id int not null,
|
|
778
|
prestamo_id int not null,
|
|
779
|
fecha_solicitud date not null,
|
|
780
|
motivo character varying(100) not null,
|
|
781
|
estado_id int not null,
|
|
782
|
constraint pk_solicitud_amplicacion primary key(id),
|
|
783
|
constraint fk_solicitud_amplicacion_prestamo_id foreign key(prestamo_id) references prestamo(id),
|
|
784
|
constraint fk_solicitud_amplicacion_estado_id foreign key(estado_id) references estado(id)
|
|
785
|
);
|
|
786
|
|
|
787
|
create table solicitud_refinanciacion(
|
|
788
|
id int not null,
|
|
789
|
prestamo_id int not null,
|
|
790
|
fecha_solicitud date not null,
|
|
791
|
motivo character varying(100) not null,
|
|
792
|
estado_id int not null,
|
|
793
|
constraint pk_solicitud_refinanciacion primary key(id),
|
|
794
|
constraint fk_solicitud_refinanciacion_prestamo_id foreign key(prestamo_id) references prestamo(id),
|
|
795
|
constraint fk_solicitud_refinanciacion_estado_id foreign key(estado_id) references estado(id)
|
|
796
|
);
|
|
797
|
|
|
798
|
create table solicitud_consolidacion(
|
|
799
|
id int not null,
|
|
800
|
fecha_solicitud date not null,
|
|
801
|
motivo character varying(100) not null,
|
|
802
|
estado_id int not null,
|
|
803
|
constraint pk_solicitud_consolidacion primary key(id),
|
|
804
|
constraint fk_solicitud_consolidacion_estado_id foreign key(estado_id) references estado(id)
|
|
805
|
);
|
|
806
|
|
|
807
|
create table prestamo_consolidacion(
|
|
808
|
id int not null,
|
|
809
|
prestamo_id int not null,
|
|
810
|
solicitud_id int not null,
|
|
811
|
constraint pk_prestamo_consolidacion primary key(id),
|
|
812
|
constraint fk_prestamo_consolidacion_prestamo_id foreign key(prestamo_id) references prestamo(id),
|
|
813
|
constraint fk_prestamo_consolidacion_solicitud_id foreign key(solicitud_id) references solicitud_consolidacion(id)
|
|
814
|
);
|
|
815
|
|
|
816
|
create table producto_credito(
|
|
817
|
id int not null,
|
|
818
|
nombre character varying(100) not null,
|
|
819
|
tipo_credito_id int not null, -- consumo
|
|
820
|
sub_tipo_id int not null, -- compra anteojos
|
|
821
|
monto_hasta numeric not null, -- 5.000.000
|
|
822
|
relacion_aporte character varying(20) not null, -- 1/15
|
|
823
|
plazo_minimo int not null, -- 6
|
|
824
|
plazo_maximo int not null, -- 36
|
|
825
|
constraint pk_producto_credito primary key(id),
|
|
826
|
constraint fk_producto_credito_tipo_credito_id foreign key(tipo_credito_id) references tipo_credito(id)
|
|
827
|
--constraint fk_producto_credito_sub_tipo_id foreign key(sub_tipo_id) references sub_tipo_credito(id)
|
|
828
|
);
|
|
829
|
|
|
830
|
create table producto_detalle(
|
|
831
|
id int not null,
|
|
832
|
producto_credito_id int not null,
|
|
833
|
cuota_desde int not null, -- 13
|
|
834
|
cuota_hasta int not null, -- 16
|
|
835
|
tasa numeric not null, -- 18
|
|
836
|
constraint pk_producto_detalle primary key(id),
|
|
837
|
constraint fk_producto_detalle_producto_credito_id foreign key(producto_credito_id) references producto_credito(id)
|
|
838
|
);
|
|
839
|
|
|
840
|
create table solicitud_prestamo(
|
|
841
|
id int not null,
|
|
842
|
socio_id int not null,
|
|
843
|
fecha_solicitud date not null,
|
|
844
|
nro_solicitud character varying(20) not null,
|
|
845
|
monto_solicitado numeric not null,
|
|
846
|
cant_cuotas int not null,
|
|
847
|
observacion character varying(200),
|
|
848
|
perfil_economico_id int not null,
|
|
849
|
destino_id int not null,
|
|
850
|
tipo_credito_id int not null,
|
|
851
|
tipo_garantia_id int not null,
|
|
852
|
tipo_plazo_id int not null,
|
|
853
|
producto_credito_id int not null,
|
|
854
|
constraint pk_solicitud_prestamo primary key(id),
|
|
855
|
constraint fk_solicitud_prestamo_socio_id foreign key(socio_id) references socio(id),
|
|
856
|
constraint fk_solicitud_prestamo_perfil_economico_id foreign key(perfil_economico_id) references perfil_economico(id),
|
|
857
|
constraint fk_solicitud_prestamo_destino_id foreign key(destino_id) references destino(id),
|
|
858
|
constraint fk_solicitud_prestamo_tipo_credito_id foreign key(tipo_credito_id) references tipo_credito(id),
|
|
859
|
constraint fk_solicitud_prestamo_tipo_garantia_id foreign key(tipo_garantia_id) references tipo_garantia(id),
|
|
860
|
constraint fk_solicitud_prestamo_tipo_plazo_id foreign key(tipo_plazo_id) references tipo_plazo(id),
|
|
861
|
constraint fk_solicitud_prestamo_producto_credito_id foreign key(producto_credito_id) references producto_credito(id)
|
|
862
|
);
|
|
863
|
|
|
864
|
create table analisis_credito(
|
|
865
|
id int not null,
|
|
866
|
solicitud_prestamo_id int not null,
|
|
867
|
analizado_por int not null,
|
|
868
|
fecha_analisis date,
|
|
869
|
recomendacion_analista character varying(100),
|
|
870
|
jefe_por int not null,
|
|
871
|
fecha_analisis_jefe date,
|
|
872
|
recomendacion_jefe character varying(100),
|
|
873
|
gerente_por int not null,
|
|
874
|
fecha_analisis_gerente date,
|
|
875
|
recomendacion_gerente character varying(100),
|
|
876
|
comite_por int not null,
|
|
877
|
fecha_analisis_comite date,
|
|
878
|
recomendacion_comite character varying(100),
|
|
879
|
consejo_por int not null,
|
|
880
|
fecha_analisis_consejo date,
|
|
881
|
recomendacion_consejo character varying(100),
|
|
882
|
estado_id int not null,
|
|
883
|
fecha_estado date not null,
|
|
884
|
constraint pk_analisis_credito primary key(id),
|
|
885
|
constraint fk_analisis_credito_solicitud_prestamo_id foreign key(solicitud_prestamo_id) references solicitud_prestamo(id),
|
|
886
|
constraint fk_analisis_credito_estado_id foreign key(estado_id) references estado(id)
|
|
887
|
);
|
|
888
|
|
|
889
|
create table prestamo(
|
|
890
|
id int not null,
|
|
891
|
cuenta_id int not null,
|
|
892
|
fecha_aprobacion date not null,
|
|
893
|
saldo numeric,
|
|
894
|
saldo_capital numeric,
|
|
895
|
saldo_interes numeric,
|
|
896
|
capital_pagado numeric,
|
|
897
|
interes_pagado numeric,
|
|
898
|
prevision numeric,
|
|
899
|
prevision_heredada numeric,
|
|
900
|
cantidad_cuotas int,
|
|
901
|
monto_aprobado numeric,
|
|
902
|
cantidad_cuotas_pagadas int,
|
|
903
|
producto_credito_id int not null,
|
|
904
|
constraint pk_prestamo primary key(id),
|
|
905
|
constraint fk_prestamo_cuenta_id foreign key(cuenta_id) references cuenta(id),
|
|
906
|
constraint fk_prestamo_producto_credito_id foreign key(producto_credito_id) references producto_credito(id)
|
|
907
|
);
|
|
908
|
|
|
909
|
create table codeudor(
|
|
910
|
id int not null,
|
|
911
|
persona_id int not null,
|
|
912
|
prestamo_id int not null,
|
|
913
|
es_socio boolean not null,
|
|
914
|
es_conyuge boolean not null,
|
|
915
|
constraint pk_deudor primary key(id),
|
|
916
|
constraint fk_deudor_persona_id foreign key(persona_id) references persona(id),
|
|
917
|
constraint fk_deudor_prestamo_id foreign key(prestamo_id) references prestamo(id)
|
|
918
|
);
|
|
919
|
|
|
920
|
create table tipo_accion(
|
|
921
|
id int not null,
|
|
922
|
nombre character varying(100) not null,
|
|
923
|
constraint pk_tipo_accion primary key(id),
|
|
924
|
constraint uq_tipo_accion_nombre unique(nombre)
|
|
925
|
);
|
|
926
|
|
|
927
|
create table recuperacion(
|
|
928
|
id int not null,
|
|
929
|
prestamo_id int not null,
|
|
930
|
etapa int not null,
|
|
931
|
tipo_accion_id int not null,
|
|
932
|
tratamiento character varying(200) not null,
|
|
933
|
constraint pk_recuperacion primary key(id),
|
|
934
|
constraint fk_recuperacion_prestamo_id foreign key(prestamo_id) references prestamo(id),
|
|
935
|
constraint fk_recuperacion_tipo_accion_id foreign key(tipo_accion_id) references tipo_accion(id)
|
|
936
|
);
|
|
937
|
|
|
938
|
-- cheque, deposito ahorro
|
|
939
|
create table tipo_desembolso(
|
|
940
|
id int not null,
|
|
941
|
nombre character varying(100) not null,
|
|
942
|
constraint pk_tipo_desembolso primary key(id),
|
|
943
|
constraint uq_tipo_desembolso_nombre unique(nombre)
|
|
944
|
);
|
|
945
|
|
|
946
|
create table descuento_desembolso(
|
|
947
|
id int not null,
|
|
948
|
nombre character varying(100) not null,
|
|
949
|
constraint pk_descuento_desembolso primary key(id),
|
|
950
|
constraint uq_descuento_desembolso_nombre unique(nombre)
|
|
951
|
);
|
|
952
|
|
|
953
|
create table desembolso(
|
|
954
|
id int not null,
|
|
955
|
prestamo_id int not null,
|
|
956
|
fecha date not null,
|
|
957
|
constraint pk_desembolso primary key(id),
|
|
958
|
constraint fk_desembolso_prestamo_id foreign key(prestamo_id) references prestamo(id)
|
|
959
|
);
|
|
960
|
|
|
961
|
create table detalle_desembolso(
|
|
962
|
id int not null,
|
|
963
|
desembolso_id int not null,
|
|
964
|
tipo_desembolso_id int not null,
|
|
965
|
monto numeric not null,
|
|
966
|
ahorro_id int,
|
|
967
|
cheque_id int,
|
|
968
|
constraint pk_detalle_desembolso primary key(id),
|
|
969
|
constraint fk_detalle_desembolso_tipo_desembolso_id foreign key(tipo_desembolso_id) references tipo_desembolso(id)
|
|
970
|
);
|
|
971
|
|
|
972
|
create table detalle_descuento(
|
|
973
|
id int not null,
|
|
974
|
desembolso_id int not null,
|
|
975
|
descuento_id int not null,
|
|
976
|
monto numeric not null,
|
|
977
|
constraint pk_detalle_descuento primary key(id),
|
|
978
|
constraint fk_detalle_descuento_desembolso_id foreign key(desembolso_id) references desembolso(id)
|
|
979
|
--constraint fk_detalle_descuento_descuento_id foreign key(descuento_id) references descuento(id)
|
|
980
|
);
|
|
981
|
|
|
982
|
-- plan de pago (ideal)
|
|
983
|
create table plan_pago(
|
|
984
|
id int not null,
|
|
985
|
cuenta_id int not null, -- 12548
|
|
986
|
monto_capital numeric not null, -- 100
|
|
987
|
interes numeric not null, -- 10
|
|
988
|
saldo numeric,
|
|
989
|
nro_cuota int,
|
|
990
|
fecha_vencimiento date not null,
|
|
991
|
constraint pk_cuota primary key(id),
|
|
992
|
constraint fk_cuota_cuenta_id foreign key(cuenta_id) references cuenta(id)
|
|
993
|
);
|
|
994
|
|
|
995
|
create table cuota(
|
|
996
|
id int not null,
|
|
997
|
cuenta_id int not null, -- 12548
|
|
998
|
monto_capital numeric not null, -- 100
|
|
999
|
interes numeric not null, -- 10
|
|
1000
|
interes_moratorio numeric,
|
|
1001
|
interes_punitorio numeric,
|
|
1002
|
saldo numeric,
|
|
1003
|
nro_cuota int,
|
|
1004
|
fecha_vencimiento date not null,
|
|
1005
|
constraint pk_cuota1 primary key(id),
|
|
1006
|
constraint fk_cuota_cuenta_id foreign key(cuenta_id) references cuenta(id)
|
|
1007
|
);
|
|
1008
|
|