forked from vmaster/my_work
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bdiman 28-05-11.sql
3602 lines (3516 loc) · 256 KB
/
bdiman 28-05-11.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
MySQL Data Transfer
Source Host: localhost
Source Database: bdiman
Target Host: localhost
Target Database: bdiman
Date: 28/05/2011 09:39:21 p.m.
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for acceso
-- ----------------------------
DROP TABLE IF EXISTS `acceso`;
CREATE TABLE `acceso` (
`IdAcceso` int(11) NOT NULL auto_increment,
`IdTipoUsuario` int(11) NOT NULL,
`IdOpcionMenu` int(11) NOT NULL,
PRIMARY KEY (`IdAcceso`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for armario
-- ----------------------------
DROP TABLE IF EXISTS `armario`;
CREATE TABLE `armario` (
`IdArmario` int(11) NOT NULL auto_increment,
`Codigo` varchar(5) collate utf8_spanish_ci NOT NULL,
`Nombre` varchar(25) collate utf8_spanish_ci NOT NULL,
`TotalColumnas` int(11) NOT NULL,
`TotalFilas` int(11) NOT NULL,
PRIMARY KEY (`IdArmario`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for bitacora
-- ----------------------------
DROP TABLE IF EXISTS `bitacora`;
CREATE TABLE `bitacora` (
`IdBitacora` int(11) NOT NULL auto_increment,
`IdMovimiento` int(11) NOT NULL,
`FechaHora` datetime NOT NULL,
`Comentario` varchar(100) collate utf8_spanish_ci NOT NULL,
`Idusuario` int(11) NOT NULL,
`Operacion` varchar(1) collate utf8_spanish_ci NOT NULL default 'N' COMMENT 'N->Nuevo,A->Anulacion',
PRIMARY KEY (`IdBitacora`)
) ENGINE=InnoDB AUTO_INCREMENT=136 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for categoria
-- ----------------------------
DROP TABLE IF EXISTS `categoria`;
CREATE TABLE `categoria` (
`IdCategoria` int(11) NOT NULL auto_increment,
`Descripcion` varchar(100) collate utf8_spanish_ci default NULL,
`Abreviatura` varchar(2) collate utf8_spanish_ci default NULL,
`IdCategoriaRef` int(11) default NULL,
`Nivel` int(11) default '1',
`Estado` char(1) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`IdCategoria`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for conceptopago
-- ----------------------------
DROP TABLE IF EXISTS `conceptopago`;
CREATE TABLE `conceptopago` (
`IdConceptoPago` int(11) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci NOT NULL,
`Tipo` char(1) collate utf8_spanish_ci NOT NULL COMMENT 'I->Ingreso,E->Egreso',
PRIMARY KEY (`IdConceptoPago`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci COMMENT='Solo para el caso de Caja';
-- ----------------------------
-- Table structure for cuota
-- ----------------------------
DROP TABLE IF EXISTS `cuota`;
CREATE TABLE `cuota` (
`IdCuota` int(11) NOT NULL auto_increment,
`Nombre` varchar(20) collate utf8_spanish_ci NOT NULL,
`IdMovimiento` int(11) NOT NULL,
`FechaCreacion` datetime NOT NULL,
`FechaCancelacion` datetime NOT NULL,
`FechaPago` datetime NOT NULL,
`Moneda` char(1) collate utf8_spanish_ci NOT NULL default 'S' COMMENT 'S->Soles, D->D?lares.',
`Monto` decimal(10,2) NOT NULL,
`Interes` decimal(10,2) NOT NULL,
`MontoPagado` decimal(10,2) NOT NULL,
`InteresPagado` decimal(10,2) NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL default 'N' COMMENT 'N->Normal,C->Cancelada (Pagada), A->Anulada.',
PRIMARY KEY (`IdCuota`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for departamento
-- ----------------------------
DROP TABLE IF EXISTS `departamento`;
CREATE TABLE `departamento` (
`IdDepartamento` int(11) NOT NULL auto_increment,
`Descripcion` varchar(20) collate utf8_spanish_ci default NULL,
`IdPais` int(11) NOT NULL,
`Codigo` varchar(2) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`IdDepartamento`),
KEY `XIF1DEPARTAMENTO` (`IdPais`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for detallemovalmacen
-- ----------------------------
DROP TABLE IF EXISTS `detallemovalmacen`;
CREATE TABLE `detallemovalmacen` (
`IdDetalleMovAlmacen` int(11) NOT NULL auto_increment,
`IdMovimiento` int(11) NOT NULL,
`IdProducto` int(11) NOT NULL,
`IdUnidad` int(11) NOT NULL,
`Cantidad` decimal(10,2) NOT NULL,
`PrecioCompra` decimal(10,2) NOT NULL,
`PrecioVenta` decimal(10,2) NOT NULL,
PRIMARY KEY (`IdDetalleMovAlmacen`)
) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for detallemovcaja
-- ----------------------------
DROP TABLE IF EXISTS `detallemovcaja`;
CREATE TABLE `detallemovcaja` (
`IdDetalleMovCaja` int(11) NOT NULL auto_increment,
`IdMovimiento` int(11) NOT NULL,
`IdCuota` int(11) NOT NULL,
`Monto` decimal(10,2) NOT NULL,
`Interes` decimal(10,2) NOT NULL,
`Moneda` char(1) collate utf8_spanish_ci NOT NULL default 'S' COMMENT 'S->Soles, D->D?lares.',
`TipoCambio` decimal(10,2) NOT NULL,
PRIMARY KEY (`IdDetalleMovCaja`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for distrito
-- ----------------------------
DROP TABLE IF EXISTS `distrito`;
CREATE TABLE `distrito` (
`IdDistrito` int(11) NOT NULL auto_increment,
`Descripcion` char(40) collate utf8_spanish_ci default NULL,
`Codigo` varchar(2) character set utf8 collate utf8_latvian_ci default NULL,
`IdProvincia` int(11) NOT NULL,
PRIMARY KEY (`IdDistrito`),
KEY `XIF3DISTRITO` (`IdProvincia`)
) ENGINE=InnoDB AUTO_INCREMENT=1829 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for kardex
-- ----------------------------
DROP TABLE IF EXISTS `kardex`;
CREATE TABLE `kardex` (
`IdKardex` int(11) NOT NULL auto_increment,
`IdSucursal` int(11) NOT NULL,
`IdMovimiento` int(11) NOT NULL,
`IdProducto` int(11) NOT NULL,
`IdUnidad` int(11) NOT NULL,
`Cantidad` decimal(10,2) NOT NULL,
`TipoMoneda` char(1) collate utf8_spanish_ci NOT NULL,
`PrecioUnidad` decimal(10,2) NOT NULL,
`Importe` decimal(10,2) NOT NULL,
`Fecha` datetime NOT NULL,
`SaldoAnteriorBase` decimal(10,2) NOT NULL,
`IdUnidadBase` int(11) NOT NULL,
`CantidadBase` decimal(10,2) NOT NULL,
`SaldoActual` decimal(10,2) NOT NULL,
`IdUsuario` int(11) NOT NULL,
`Ultimo` char(1) collate utf8_spanish_ci NOT NULL COMMENT 'S->Si,N->No',
`Estado` char(1) collate utf8_spanish_ci NOT NULL default 'N' COMMENT 'N->Normal,A->Anulado',
PRIMARY KEY (`IdKardex`)
) ENGINE=InnoDB AUTO_INCREMENT=62 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for listaunidad
-- ----------------------------
DROP TABLE IF EXISTS `listaunidad`;
CREATE TABLE `listaunidad` (
`IdListaUnidad` int(11) NOT NULL auto_increment,
`IdProducto` int(11) NOT NULL,
`IdUnidad` int(11) NOT NULL,
`IdUnidadBase` int(11) NOT NULL,
`Formula` decimal(10,0) NOT NULL,
`PrecioCompra` decimal(10,3) NOT NULL,
`PrecioVenta` decimal(10,3) NOT NULL,
`PrecioVentaEspecial` decimal(10,3) default NULL,
`Moneda` char(1) collate utf8_spanish_ci NOT NULL default 'S',
PRIMARY KEY (`IdListaUnidad`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for lugar
-- ----------------------------
DROP TABLE IF EXISTS `lugar`;
CREATE TABLE `lugar` (
`IdLugar` int(11) NOT NULL auto_increment,
`Direccion` varchar(50) collate utf8_spanish_ci default NULL,
`Ubigeo` int(11) default NULL,
PRIMARY KEY (`IdLugar`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for marca
-- ----------------------------
DROP TABLE IF EXISTS `marca`;
CREATE TABLE `marca` (
`IdMarca` int(11) NOT NULL auto_increment,
`Descripcion` varchar(25) collate utf8_spanish_ci NOT NULL,
`Abreviatura` varchar(2) collate utf8_spanish_ci NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdMarca`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for modulo
-- ----------------------------
DROP TABLE IF EXISTS `modulo`;
CREATE TABLE `modulo` (
`idmodulo` int(11) NOT NULL auto_increment,
`descripcion` varchar(25) collate utf8_spanish_ci NOT NULL,
`abreviatura` varchar(5) collate utf8_spanish_ci NOT NULL,
`estado` char(1) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`idmodulo`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for motivotraslado
-- ----------------------------
DROP TABLE IF EXISTS `motivotraslado`;
CREATE TABLE `motivotraslado` (
`IdMotivoTraslado` int(11) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`IdMotivoTraslado`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for movimiento
-- ----------------------------
DROP TABLE IF EXISTS `movimiento`;
CREATE TABLE `movimiento` (
`IdMovimiento` int(11) NOT NULL auto_increment,
`IdSucursal` int(11) NOT NULL,
`IdTipoMovimiento` int(11) NOT NULL,
`IdConceptoPago` int(11) NOT NULL,
`Numero` varchar(15) collate utf8_spanish_ci NOT NULL COMMENT '000000-000',
`IdTipoDocumento` int(11) NOT NULL,
`FormaPago` char(1) collate utf8_spanish_ci NOT NULL default 'A' COMMENT 'A->Contado,B->Credito',
`Fecha` datetime NOT NULL,
`Moneda` char(1) collate utf8_spanish_ci NOT NULL default 'S' COMMENT 'S->Soles, D->D?lares.',
`SubTotal` decimal(10,2) NOT NULL,
`Igv` decimal(10,2) NOT NULL,
`Total` decimal(10,2) NOT NULL,
`IdUsuario` int(11) NOT NULL,
`IdPersona` int(11) NOT NULL,
`IdResponsable` int(11) NOT NULL,
`IdMovimientoRef` int(11) NOT NULL,
`IdSucursalRef` int(11) NOT NULL,
`Comentario` varchar(100) collate utf8_spanish_ci NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL default 'N' COMMENT 'N->Normal, A->Anulado',
`FechaInicioTraslado` date NOT NULL,
`IdMotivoTraslado` int(11) NOT NULL default '0',
`IdTransportista` int(11) NOT NULL default '0',
`IdLugarPartida` int(11) NOT NULL default '0',
`IdLugarDestino` int(11) NOT NULL default '0',
PRIMARY KEY (`IdMovimiento`)
) ENGINE=InnoDB AUTO_INCREMENT=212 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for opcionmenu
-- ----------------------------
DROP TABLE IF EXISTS `opcionmenu`;
CREATE TABLE `opcionmenu` (
`IdOpcionMenu` int(11) NOT NULL auto_increment,
`LinkMenu` varchar(50) collate utf8_spanish_ci NOT NULL,
`NombreMenu` varchar(50) collate utf8_spanish_ci NOT NULL,
`idmodulo` int(11) NOT NULL,
PRIMARY KEY (`IdOpcionMenu`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for pais
-- ----------------------------
DROP TABLE IF EXISTS `pais`;
CREATE TABLE `pais` (
`IdPais` int(11) NOT NULL auto_increment,
`Descripcion` varchar(20) collate utf8_spanish_ci default NULL,
`Nacionalidad` varchar(30) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`IdPais`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for persona
-- ----------------------------
DROP TABLE IF EXISTS `persona`;
CREATE TABLE `persona` (
`IdPersona` int(11) NOT NULL auto_increment,
`TipoPersona` varchar(8) collate utf8_spanish_ci NOT NULL COMMENT 'Natural (RUC), Jur?dica (RUC) y Varios(DNI)',
`Nombres` varchar(50) collate utf8_spanish_ci NOT NULL,
`Apellidos` varchar(50) collate utf8_spanish_ci NOT NULL,
`NroDoc` varchar(10) collate utf8_spanish_ci NOT NULL,
`Sexo` char(1) collate utf8_spanish_ci NOT NULL,
`Direccion` varchar(50) collate utf8_spanish_ci NOT NULL,
`Celular` varchar(9) collate utf8_spanish_ci NOT NULL,
`Email` varchar(50) collate utf8_spanish_ci NOT NULL,
`IdSector` int(11) NOT NULL,
`IdZona` int(11) NOT NULL,
`IdDistrito` int(11) NOT NULL default '409',
`Representante` varchar(50) collate utf8_spanish_ci NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL COMMENT 'N->Normal, A->Anulado',
PRIMARY KEY (`IdPersona`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for producto
-- ----------------------------
DROP TABLE IF EXISTS `producto`;
CREATE TABLE `producto` (
`IdProducto` int(11) NOT NULL auto_increment,
`Codigo` varchar(50) collate utf8_spanish_ci NOT NULL,
`Descripcion` varchar(100) collate utf8_spanish_ci NOT NULL,
`IdCategoria` int(11) NOT NULL,
`IdMarca` int(11) NOT NULL,
`IdUnidadBase` int(11) NOT NULL,
`Peso` decimal(18,2) NOT NULL,
`IdMedidaPeso` int(11) NOT NULL COMMENT 'Se relaciona con la tabla unidad',
`StockSeguridad` decimal(10,2) NOT NULL,
`IdArmario` int(11) NOT NULL,
`Columna` int(11) NOT NULL,
`Fila` int(11) NOT NULL,
`Kardex` char(1) collate utf8_spanish_ci NOT NULL default 'S' COMMENT 'S->Si, N->No',
`Estado` char(1) collate utf8_spanish_ci NOT NULL default 'N' COMMENT 'N->Normal, A->Anulado',
PRIMARY KEY (`IdProducto`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for provincia
-- ----------------------------
DROP TABLE IF EXISTS `provincia`;
CREATE TABLE `provincia` (
`IdProvincia` int(11) NOT NULL auto_increment,
`Descripcion` varchar(30) collate utf8_spanish_ci default NULL,
`Codigo` varchar(2) collate utf8_spanish_ci default NULL,
`IdDepartamento` int(11) NOT NULL,
PRIMARY KEY (`IdProvincia`),
KEY `XIF1PROVINCIA` (`IdDepartamento`)
) ENGINE=InnoDB AUTO_INCREMENT=195 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for rol
-- ----------------------------
DROP TABLE IF EXISTS `rol`;
CREATE TABLE `rol` (
`IdRol` int(11) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdRol`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci COMMENT='Indicara si la persona es: Cliente, Proveedor, Usuario, Empl';
-- ----------------------------
-- Table structure for rolpersona
-- ----------------------------
DROP TABLE IF EXISTS `rolpersona`;
CREATE TABLE `rolpersona` (
`IdRolPersona` int(11) NOT NULL auto_increment,
`IdPersona` int(11) NOT NULL,
`IdRol` int(11) NOT NULL,
PRIMARY KEY (`IdRolPersona`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci COMMENT='Permite asignar a una persona muchos roles.';
-- ----------------------------
-- Table structure for sector
-- ----------------------------
DROP TABLE IF EXISTS `sector`;
CREATE TABLE `sector` (
`IdSector` int(11) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdSector`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for stockproducto
-- ----------------------------
DROP TABLE IF EXISTS `stockproducto`;
CREATE TABLE `stockproducto` (
`IdStockProducto` int(11) NOT NULL auto_increment,
`IdSucursal` int(11) NOT NULL,
`IdProducto` int(11) NOT NULL,
`IdUnidad` int(11) NOT NULL,
`Stock` decimal(10,2) NOT NULL,
`IdUnidadBase` int(11) NOT NULL,
`StockBase` decimal(10,2) NOT NULL,
PRIMARY KEY (`IdStockProducto`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for sucursal
-- ----------------------------
DROP TABLE IF EXISTS `sucursal`;
CREATE TABLE `sucursal` (
`IdSucursal` int(11) NOT NULL auto_increment,
`Nombre` varchar(50) collate utf8_spanish_ci NOT NULL,
`Direccion` varchar(50) collate utf8_spanish_ci NOT NULL,
`RUC` varchar(11) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdSucursal`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for tipocambio
-- ----------------------------
DROP TABLE IF EXISTS `tipocambio`;
CREATE TABLE `tipocambio` (
`IdTipocambio` int(11) NOT NULL auto_increment,
`Fecha` date NOT NULL,
`Cambio` decimal(10,2) NOT NULL,
PRIMARY KEY (`IdTipocambio`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for tipodocumento
-- ----------------------------
DROP TABLE IF EXISTS `tipodocumento`;
CREATE TABLE `tipodocumento` (
`IdTipoDocumento` int(12) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci NOT NULL,
`Abreviatura` varchar(5) collate utf8_spanish_ci NOT NULL,
`Stock` char(1) collate utf8_spanish_ci NOT NULL COMMENT 'indicara la forma como este mueve stock: R->Resta Stock, S->Suma Stock y N-> Neutro (Ejm: Cotizaciones, ?rdenes de Compra).',
PRIMARY KEY (`IdTipoDocumento`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci COMMENT='Contendr? el tipo de documento, pudiendo ser Boleta, Factura';
-- ----------------------------
-- Table structure for tipomovimiento
-- ----------------------------
DROP TABLE IF EXISTS `tipomovimiento`;
CREATE TABLE `tipomovimiento` (
`IdTipoMovimiento` int(11) NOT NULL auto_increment,
`Descripcion` varchar(25) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdTipoMovimiento`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci COMMENT='Ejm: Compra, Venta, Caja, Almacen';
-- ----------------------------
-- Table structure for tipousuario
-- ----------------------------
DROP TABLE IF EXISTS `tipousuario`;
CREATE TABLE `tipousuario` (
`IdTipoUsuario` int(11) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL default 'N',
PRIMARY KEY (`IdTipoUsuario`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for transportista
-- ----------------------------
DROP TABLE IF EXISTS `transportista`;
CREATE TABLE `transportista` (
`IdTransportista` int(11) NOT NULL auto_increment,
`IdSucursal` int(11) default NULL,
`NombreRazonSocial` varchar(100) collate utf8_spanish_ci default NULL,
`DniRuc` varchar(11) collate utf8_spanish_ci default NULL,
`Direccion` varchar(80) collate utf8_spanish_ci default NULL,
`MarcaVehiculo` varchar(30) collate utf8_spanish_ci default NULL,
`NroPlaca` varchar(20) collate utf8_spanish_ci default NULL,
`NroConstanciaCertificado` varchar(20) collate utf8_spanish_ci default NULL,
`LicenciaBrevete` varchar(20) collate utf8_spanish_ci default NULL,
`NombreChofer` varchar(100) collate utf8_spanish_ci default NULL,
`Estado` char(1) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`IdTransportista`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for unidad
-- ----------------------------
DROP TABLE IF EXISTS `unidad`;
CREATE TABLE `unidad` (
`IdUnidad` int(11) NOT NULL auto_increment,
`Descripcion` varchar(25) collate utf8_spanish_ci NOT NULL,
`Abreviatura` varchar(5) collate utf8_spanish_ci NOT NULL,
`Tipo` char(1) collate utf8_spanish_ci NOT NULL COMMENT 'M->Masa, L->Longitud, A->Area y O->Otro',
`Estado` char(1) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdUnidad`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for usuario
-- ----------------------------
DROP TABLE IF EXISTS `usuario`;
CREATE TABLE `usuario` (
`Idusuario` int(11) NOT NULL,
`US` varchar(25) collate utf8_spanish_ci NOT NULL,
`PW` varchar(32) collate utf8_spanish_ci NOT NULL,
`UltimoAcceso` datetime NOT NULL,
`IdTipoUsuario` int(11) NOT NULL,
`Estado` char(1) collate utf8_spanish_ci NOT NULL COMMENT 'N->Normal, A->Anulado',
UNIQUE KEY `Idusuario` (`Idusuario`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Table structure for zona
-- ----------------------------
DROP TABLE IF EXISTS `zona`;
CREATE TABLE `zona` (
`IdZona` int(11) NOT NULL auto_increment,
`Descripcion` varchar(50) collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`IdZona`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
-- ----------------------------
-- Procedure structure for up_AgregarStockProducto
-- ----------------------------
DROP PROCEDURE IF EXISTS `up_AgregarStockProducto`;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `up_AgregarStockProducto`(vIdSucursal int,
vIdProducto int, vIdUnidad int, vStock
numeric(10,2), vIdMovimiento int, vMoneda
char(1), vPrecioUnidad numeric(10,2),
vFecha datetime, vIdUsuario int)
BEGIN
DECLARE vIdUnidadBase INT;
DECLARE vFormula numeric(18,2);
DECLARE vStockBase numeric(18,2);
DECLARE vcount INT;
DECLARE vSaldoAnterior numeric(18,2);
DECLARE vNuevoSaldo numeric(18,2);
DECLARE vIdKardex INT;
DECLARE vImporte numeric(18,2);
DECLARE vEstado char(1);
SET vIdUnidadBase=(SELECT IdUnidadBase FROM
Producto WHERE IdProducto = vIdProducto);
SET vFormula=(SELECT Formula FROM
ListaUnidad WHERE IdProducto = vIdProducto
AND IdUnidad = vIdUnidad AND IdUnidadBase =
vIdUnidadBase);
SET vStockBase=vStock*vFormula;
SET vcount=(SELECT CASE WHEN COUNT(*) IS
NULL THEN 0 ELSE COUNT(*) END FROM
StockProducto WHERE IdProducto = vIdProducto
AND IdUnidad = vIdUnidad AND IdSucursal =
vIdSucursal);
IF vcount = 0 THEN
INSERT INTO StockProducto(
IdStockProducto, IdSucursal, IdProducto,
IdUnidad, Stock, IdUnidadBase, StockBase)
VALUES (NULL, vIdSucursal, vIdProducto,
vIdUnidad, vStock, vIdUnidadBase, vStockBase);
ELSE
UPDATE StockProducto SET Stock =
Stock + vStock, StockBase = StockBase +
vStockBase WHERE IdProducto = vIdProducto
AND IdUnidad = vIdUnidad AND IdSucursal =
vIdSucursal;
END IF;
SET vSaldoAnterior = (SELECT SaldoActual
FROM Kardex WHERE IdProducto = vIdProducto
AND IdSucursal = vIdSucursal AND Ultimo =
'S' ORDER BY IdKardex DESC LIMIT 0,1);
SET vIdKardex = (SELECT IdKardex FROM Kardex
WHERE IdProducto = vIdProducto AND
IdSucursal = vIdSucursal AND Ultimo = 'S'
ORDER BY IdKardex DESC LIMIT 0,1);
IF vSaldoAnterior IS NULL THEN
SET vSaldoAnterior = 0;
SET vIdKardex = 0;
END IF;
UPDATE Kardex SET Ultimo = 'N' WHERE
IdKardex = vIdKardex;
SET vNuevoSaldo = vSaldoAnterior +
vStockBase;
SET vImporte = vStock*vPrecioUnidad;
IF SUBSTR(vStock,1,1)= '-' THEN
SET vImporte=-vImporte;
SET vStock=-vStock;
SET vStockBase=-vStockBase;
END IF;
IF (SELECT Estado FROM Movimiento WHERE
IdMovimiento=vIdMovimiento)='A' THEN
SET vEstado='A';
ELSE
SET vEstado='N';
END IF;
INSERT INTO KARDEX(IdKardex,
IdSucursal,
IdMovimiento,
IdProducto,
IdUnidad,
Cantidad,
TipoMoneda,
PrecioUnidad,
Importe,
Fecha,
SaldoAnteriorBase,
IdUnidadBase,
CantidadBase,
SaldoActual,
IdUsuario,
Ultimo,
Estado) VALUES(NULL,
vIdSucursal,
vIdMovimiento,
vIdProducto,
vIdUnidad,
vStock,
vMoneda,
vPrecioUnidad,
vImporte,
vFecha,
vSaldoAnterior,
vIdUnidadBase,
vStockBase,
vNuevoSaldo,
vIdUsuario,
'S',
vEstado);
END;;
DELIMITER ;
-- ----------------------------
-- Procedure structure for up_BuscarCategoriaProductoArbol
-- ----------------------------
DROP PROCEDURE IF EXISTS `up_BuscarCategoriaProductoArbol`;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `up_BuscarCategoriaProductoArbol`()
BEGIN
Declare vMaxNivel int;
Declare vNivel int;
CREATE TEMPORARY TABLE Categoria_Temp
(
IdCategoria Int,
Descripcion Varchar( 50 ) ,
IdCategoriaRef Int,
Nivel Int,
Secuencia Int AUTO_INCREMENT PRIMARY KEY ,
CodigoOrden Varchar( 50 ) ,
Abreviatura Varchar( 10 ),
Estado Varchar( 1 )
);
CREATE TEMPORARY TABLE Categoria_Temp2
(
IdCategoria Int,
Descripcion Varchar( 50 ) ,
IdCategoriaRef Int,
Nivel Int,
Secuencia Int AUTO_INCREMENT PRIMARY KEY ,
CodigoOrden Varchar( 50 ) ,
Abreviatura Varchar( 10 ),
Estado Varchar( 1 )
);
Insert Into Categoria_Temp(IdCategoria, Descripcion, IdCategoriaRef, Nivel, Estado,Abreviatura) Select IdCategoria, Descripcion, IdCategoriaRef, Nivel,Estado,Abreviatura From Categoria Where Nivel=1;
Update Categoria_Temp Set CodigoOrden=Secuencia;
Insert Into Categoria_Temp2(IdCategoria, Descripcion, IdCategoriaRef, Nivel,Estado,Abreviatura) Select IdCategoria, Descripcion, IdCategoriaRef, Nivel,Estado,Abreviatura From Categoria Where Nivel=1;
Update Categoria_Temp2 Set CodigoOrden=Secuencia;
Set vMaxNivel=(Select Max(Nivel) From Categoria);
Set vNivel=2;
While vNivel<=vMaxNivel Do
Insert Into Categoria_Temp(IdCategoria, Descripcion, IdCategoriaRef, Nivel, CodigoOrden,Estado,Abreviatura)
Select TP.IdCategoria, CONCAT(SPACE(vNivel*2),TP.Descripcion), TP.IdCategoriaRef, TP.Nivel, CONCAT(Categoria_Temp2.CodigoOrden,'-',TP.Nivel),TP.Estado,TP.Abreviatura
From Categoria TP Inner Join Categoria_Temp2 ON TP.IdCategoriaRef = Categoria_Temp2.IdCategoria
Where TP.Nivel=vNivel;
Update Categoria_Temp Set CodigoOrden= CONCAT(CodigoOrden,Secuencia) Where Nivel=vNivel;
Truncate Categoria_Temp2;
Insert Into Categoria_Temp2 Select * From Categoria_Temp;
Set vNivel = vNivel + 1;
End While;
SELECT tem.IdCategoria,tem.Descripcion,tem.IdCategoriaRef,tem.Nivel,tem.Estado,tem.Abreviatura,tem.CodigoOrden,categoria.Descripcion as DescripcionRef FROM(Select * From Categoria_Temp WHERE Estado='N' Order By CodigoOrden Asc)as tem LEFT JOIN categoria ON tem.IdCategoriaRef=categoria.IdCategoria;
DROP TEMPORARY Table Categoria_Temp;
DROP TEMPORARY table Categoria_Temp2;
End;;
DELIMITER ;
-- ----------------------------
-- Function structure for obtenerStock
-- ----------------------------
DROP FUNCTION IF EXISTS `obtenerStock`;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `obtenerStock`(vIdProducto int,vIdUnidad int,vIdSucursal int) RETURNS decimal(16,2)
BEGIN
DECLARE vStockBase numeric(16,2);
DECLARE vIdUnidadBase INT;
DECLARE vFormula numeric(18,2);
DECLARE vStock numeric(18,2);
SET vStockBase= (SELECT SUM(StockBase) FROM StockProducto WHERE IdProducto = vIdProducto AND IdSucursal = vIdSucursal GROUP BY IdProducto);
SET vIdUnidadBase=(SELECT IdUnidadBase FROM Producto WHERE IdProducto = vIdProducto);
SET vFormula=(SELECT Formula FROM ListaUnidad WHERE IdProducto = vIdProducto AND IdUnidad = vIdUnidad AND IdUnidadBase = vIdUnidadBase);
SET vStock = vStockBase / vFormula;
RETURN CASE WHEN vStock IS NULL THEN 0 ELSE vStock END;
END;;
DELIMITER ;
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `acceso` VALUES ('7', '1', '1');
INSERT INTO `acceso` VALUES ('10', '1', '2');
INSERT INTO `acceso` VALUES ('11', '1', '3');
INSERT INTO `acceso` VALUES ('12', '1', '4');
INSERT INTO `acceso` VALUES ('13', '1', '5');
INSERT INTO `acceso` VALUES ('14', '1', '6');
INSERT INTO `acceso` VALUES ('15', '1', '7');
INSERT INTO `acceso` VALUES ('16', '1', '8');
INSERT INTO `acceso` VALUES ('18', '1', '10');
INSERT INTO `acceso` VALUES ('19', '1', '11');
INSERT INTO `acceso` VALUES ('20', '1', '12');
INSERT INTO `acceso` VALUES ('21', '1', '13');
INSERT INTO `acceso` VALUES ('22', '1', '14');
INSERT INTO `acceso` VALUES ('23', '1', '15');
INSERT INTO `acceso` VALUES ('24', '1', '9');
INSERT INTO `acceso` VALUES ('25', '2', '9');
INSERT INTO `acceso` VALUES ('26', '1', '16');
INSERT INTO `acceso` VALUES ('27', '1', '17');
INSERT INTO `acceso` VALUES ('28', '1', '19');
INSERT INTO `acceso` VALUES ('29', '1', '18');
INSERT INTO `acceso` VALUES ('30', '2', '18');
INSERT INTO `acceso` VALUES ('31', '1', '22');
INSERT INTO `acceso` VALUES ('32', '1', '20');
INSERT INTO `acceso` VALUES ('33', '1', '21');
INSERT INTO `acceso` VALUES ('34', '1', '23');
INSERT INTO `acceso` VALUES ('35', '1', '24');
INSERT INTO `acceso` VALUES ('36', '1', '25');
INSERT INTO `acceso` VALUES ('37', '1', '26');
INSERT INTO `acceso` VALUES ('38', '1', '27');
INSERT INTO `acceso` VALUES ('39', '1', '28');
INSERT INTO `acceso` VALUES ('40', '3', '16');
INSERT INTO `acceso` VALUES ('41', '3', '4');
INSERT INTO `acceso` VALUES ('42', '2', '4');
INSERT INTO `acceso` VALUES ('43', '2', '11');
INSERT INTO `acceso` VALUES ('44', '2', '15');
INSERT INTO `acceso` VALUES ('45', '2', '27');
INSERT INTO `acceso` VALUES ('46', '2', '2');
INSERT INTO `acceso` VALUES ('47', '2', '16');
INSERT INTO `acceso` VALUES ('48', '2', '7');
INSERT INTO `acceso` VALUES ('49', '2', '19');
INSERT INTO `acceso` VALUES ('50', '2', '26');
INSERT INTO `acceso` VALUES ('51', '2', '24');
INSERT INTO `acceso` VALUES ('52', '2', '23');
INSERT INTO `acceso` VALUES ('53', '2', '25');
INSERT INTO `acceso` VALUES ('54', '2', '21');
INSERT INTO `acceso` VALUES ('55', '3', '2');
INSERT INTO `acceso` VALUES ('56', '1', '29');
INSERT INTO `acceso` VALUES ('57', '1', '30');
INSERT INTO `acceso` VALUES ('58', '1', '31');
INSERT INTO `armario` VALUES ('1', '001', 'ARMARIO1', '5', '5');
INSERT INTO `armario` VALUES ('2', 'ARMAR', 'ARMARIO2', '4', '8');
INSERT INTO `armario` VALUES ('3', '002', 'ARMARIO 3', '4', '3');
INSERT INTO `bitacora` VALUES ('1', '1', '2011-01-20 10:18:02', 'Nuevo Doc Almacen : 001-000001-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('2', '2', '2011-01-20 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('3', '4', '2011-01-20 00:00:00', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('4', '6', '2011-01-20 00:00:00', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('5', '7', '2011-01-20 00:00:00', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('6', '9', '2011-01-20 00:00:00', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('7', '11', '2011-01-20 00:00:00', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('8', '11', '2011-01-20 00:00:00', 'Anulacion de venta', '4', 'A');
INSERT INTO `bitacora` VALUES ('9', '12', '2011-01-20 11:09:32', 'Compra: 001-099999-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('10', '13', '2011-01-24 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('11', '15', '2011-01-24 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('12', '17', '2011-01-24 12:58:26', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('13', '19', '2011-01-24 12:59:03', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('14', '21', '2011-01-24 13:00:21', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('15', '27', '2011-01-24 14:37:21', 'Registro de nueva Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('16', '28', '2011-01-25 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('17', '30', '2011-01-25 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('18', '32', '2011-01-25 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('19', '33', '2011-01-26 00:16:24', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('20', '35', '2011-01-26 00:19:15', 'Registro de nueva Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('21', '36', '2011-01-26 00:00:00', 'Cierre de Caja del 2011-01-25', '4', 'N');
INSERT INTO `bitacora` VALUES ('22', '38', '2011-01-26 00:00:00', 'Apertura de Caja del 2011-01-26', '4', 'N');
INSERT INTO `bitacora` VALUES ('23', '40', '2011-01-26 14:40:04', 'Nuevo Doc Almacen : 001-000002-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('24', '41', '2011-01-26 14:40:30', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('25', '41', '2011-01-26 14:49:19', 'Anulacion de venta', '4', 'A');
INSERT INTO `bitacora` VALUES ('26', '41', '2011-01-26 14:51:01', 'Anulacion de venta', '4', 'A');
INSERT INTO `bitacora` VALUES ('27', '43', '2011-01-26 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('28', '44', '2011-01-26 16:17:31', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('29', '46', '2011-01-26 21:22:46', 'Nuevo Doc Almacen : 001-000003-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('30', '47', '2011-01-30 00:00:00', 'Cierre de Caja del 2011-01-26', '4', 'N');
INSERT INTO `bitacora` VALUES ('31', '49', '2011-01-30 00:00:00', 'Apertura de Caja del 2011-01-30', '4', 'N');
INSERT INTO `bitacora` VALUES ('32', '51', '2011-01-30 20:41:49', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('33', '53', '2011-01-30 20:44:01', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('34', '53', '2011-01-30 20:44:42', 'Anulacion de venta', '4', 'A');
INSERT INTO `bitacora` VALUES ('35', '55', '2011-02-04 00:00:00', 'Cierre de Caja del 2011-01-30', '4', 'N');
INSERT INTO `bitacora` VALUES ('36', '57', '2011-02-04 00:00:00', 'Apertura de Caja del 2011-02-04', '4', 'N');
INSERT INTO `bitacora` VALUES ('37', '59', '2011-02-07 00:00:00', 'Cierre de Caja del 2011-02-04', '4', 'N');
INSERT INTO `bitacora` VALUES ('38', '61', '2011-02-07 00:00:00', 'Apertura de Caja del 2011-02-07', '4', 'N');
INSERT INTO `bitacora` VALUES ('39', '63', '2011-02-18 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('40', '65', '2011-02-18 00:00:00', '', '4', 'N');
INSERT INTO `bitacora` VALUES ('41', '67', '2011-02-18 00:00:00', 'ok', '4', 'N');
INSERT INTO `bitacora` VALUES ('42', '67', '2011-02-18 00:00:00', 'ANULACION DE MOV CAJA', '4', 'A');
INSERT INTO `bitacora` VALUES ('43', '68', '2011-02-18 00:00:00', 'Nuevo Mov Caja Nro: 001-000031-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('44', '69', '2011-02-18 20:17:57', 'Nuevo Mov Caja Nro: 001-000032-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('45', '70', '2011-03-05 00:00:00', 'Cierre de Caja del 2011-02-18', '4', 'N');
INSERT INTO `bitacora` VALUES ('46', '72', '2011-03-05 00:00:00', 'Apertura de Caja del 2011-03-05', '4', 'N');
INSERT INTO `bitacora` VALUES ('47', '74', '2011-03-15 19:17:18', 'Nuevo Doc Almacen : 001-000004-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('48', '75', '2011-03-15 00:00:00', 'Cierre de Caja del 2011-03-05', '4', 'N');
INSERT INTO `bitacora` VALUES ('49', '77', '2011-03-15 00:00:00', 'Apertura de Caja del 2011-03-15', '4', 'N');
INSERT INTO `bitacora` VALUES ('50', '80', '2011-03-15 18:21:40', 'Mov Caja: 001-000019-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('51', '79', '2011-03-15 18:21:40', 'Compra: 001-000100-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('52', '81', '2011-03-15 19:27:52', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('53', '83', '2011-03-20 01:08:39', 'Nuevo Doc Almacen : 001-000005-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('54', '84', '2011-04-13 17:37:27', 'Nuevo Doc Almacen : 001-000006-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('55', '85', '2011-04-13 00:00:00', 'Cierre de Caja del 2011-03-15', '4', 'N');
INSERT INTO `bitacora` VALUES ('56', '87', '2011-04-13 00:00:00', 'Apertura de Caja del 2011-04-13', '4', 'N');
INSERT INTO `bitacora` VALUES ('57', '84', '2011-04-14 15:05:11', 'Anulacion Doc Almacen : 001-000006-2011', '4', 'A');
INSERT INTO `bitacora` VALUES ('58', '89', '2011-04-14 15:13:20', 'Cierre de Caja dia: 2011-04-13', '4', 'N');
INSERT INTO `bitacora` VALUES ('59', '91', '2011-04-14 15:13:20', 'Apertura de Caja dia: 2011-04-14', '4', 'N');
INSERT INTO `bitacora` VALUES ('60', '93', '2011-04-14 15:17:22', 'Nuevo Doc Almacen : 001-000007-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('61', '94', '2011-04-14 15:22:40', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('62', '96', '2011-04-15 00:00:00', 'Cierre de Caja del 2011-04-14', '4', 'N');
INSERT INTO `bitacora` VALUES ('63', '98', '2011-04-15 00:00:00', 'Apertura de Caja del 2011-04-15', '4', 'N');
INSERT INTO `bitacora` VALUES ('64', '100', '2011-04-16 00:00:00', 'Cierre de Caja del 2011-04-15', '4', 'N');
INSERT INTO `bitacora` VALUES ('65', '102', '2011-04-16 00:00:00', 'Apertura de Caja del 2011-04-16', '4', 'N');
INSERT INTO `bitacora` VALUES ('66', '104', '2011-04-16 17:37:35', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('67', '106', '2011-04-16 17:43:36', 'Nuevo Mov Caja Nro: 001-000048-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('68', '107', '2011-04-16 17:43:56', 'Cierre de Caja dia: 2011-04-16', '4', 'N');
INSERT INTO `bitacora` VALUES ('69', '109', '2011-04-17 00:00:00', 'Cierre de Caja dia: 2011-04-17', '4', 'N');
INSERT INTO `bitacora` VALUES ('70', '111', '2011-04-16 17:50:48', 'Nuevo Doc Almacen : 001-000008-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('71', '112', '2011-04-24 00:00:00', 'Cierre de Caja del 2011-04-17', '4', 'N');
INSERT INTO `bitacora` VALUES ('72', '114', '2011-04-24 00:00:00', 'Apertura de Caja del 2011-04-24', '4', 'N');
INSERT INTO `bitacora` VALUES ('73', '116', '2011-04-24 18:28:06', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('74', '118', '2011-04-25 19:05:03', 'Nuevo Doc Almacen : 001-000009-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('75', '119', '2011-04-25 19:06:56', 'Nuevo Doc Almacen : 001-000001-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('76', '120', '2011-04-25 00:00:00', 'Cierre de Caja del 2011-04-24', '4', 'N');
INSERT INTO `bitacora` VALUES ('77', '122', '2011-04-25 00:00:00', 'Apertura de Caja del 2011-04-25', '4', 'N');
INSERT INTO `bitacora` VALUES ('78', '124', '2011-04-25 19:08:39', 'Nuevo Doc Almacen : 001-000010-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('79', '125', '2011-04-25 19:11:17', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('80', '127', '2011-04-25 19:12:36', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('81', '129', '2011-04-25 18:17:51', 'Compra: 009-0001', '4', 'N');
INSERT INTO `bitacora` VALUES ('82', '130', '2011-04-25 19:22:19', 'Nuevo Mov Caja Nro: 001-000058-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('83', '131', '2011-04-27 00:00:00', 'Cierre de Caja del 2011-04-25', '4', 'N');
INSERT INTO `bitacora` VALUES ('84', '133', '2011-04-27 00:00:00', 'Apertura de Caja del 2011-04-27', '4', 'N');
INSERT INTO `bitacora` VALUES ('85', '135', '2011-04-27 17:03:51', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('86', '137', '2011-04-27 17:08:25', 'Nuevo Mov Caja Nro: 001-000062-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('87', '138', '2011-04-27 17:09:30', 'Nuevo Mov Caja Nro: 001-000063-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('88', '139', '2011-04-28 00:00:00', 'Cierre de Caja del 2011-04-27', '4', 'N');
INSERT INTO `bitacora` VALUES ('89', '141', '2011-04-28 00:00:00', 'Apertura de Caja del 2011-04-28', '4', 'N');
INSERT INTO `bitacora` VALUES ('90', '143', '2011-04-28 00:30:02', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('91', '145', '2011-04-28 00:32:53', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('92', '147', '2011-04-28 00:34:38', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('93', '149', '2011-04-28 00:37:53', 'Registro de nueva Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('94', '150', '2011-04-28 00:42:36', 'Registro de nueva Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('95', '151', '2011-04-28 00:43:37', 'Registro de nueva Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('96', '152', '2011-04-28 00:57:01', 'Nuevo Mov Caja Nro: 001-000069-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('97', '153', '2011-04-28 01:16:37', 'Nuevo Doc Almacen : 001-000011-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('98', '154', '2011-04-28 01:23:37', 'Nuevo Doc Almacen : 001-000012-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('99', '155', '2011-04-28 01:27:00', 'Nuevo Doc Almacen : 001-000013-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('100', '157', '2011-04-28 00:37:51', 'Mov Caja: 001-000038-2011', '4', 'N');
INSERT INTO `bitacora` VALUES ('101', '156', '2011-04-28 00:37:51', 'Compra: 001-009', '4', 'N');
INSERT INTO `bitacora` VALUES ('102', '158', '2011-05-03 00:00:00', 'Cierre de Caja del 2011-04-28', '4', 'N');
INSERT INTO `bitacora` VALUES ('103', '160', '2011-05-03 00:00:00', 'Apertura de Caja del 2011-05-03', '4', 'N');
INSERT INTO `bitacora` VALUES ('104', '162', '2011-05-18 00:00:00', 'Cierre de Caja del 2011-05-03', '4', 'N');
INSERT INTO `bitacora` VALUES ('105', '164', '2011-05-18 00:00:00', 'Apertura de Caja del 2011-05-18', '4', 'N');
INSERT INTO `bitacora` VALUES ('106', '166', '2011-05-18 15:33:53', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('107', '168', '2011-05-18 15:49:55', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('108', '170', '2011-05-21 00:00:00', 'Cierre de Caja del 2011-05-18', '4', 'N');
INSERT INTO `bitacora` VALUES ('109', '172', '2011-05-21 00:00:00', 'Apertura de Caja del 2011-05-21', '4', 'N');
INSERT INTO `bitacora` VALUES ('110', '174', '2011-05-25 00:00:00', 'Cierre de Caja del 2011-05-21', '4', 'N');
INSERT INTO `bitacora` VALUES ('111', '176', '2011-05-25 00:00:00', 'Apertura de Caja del 2011-05-25', '4', 'N');
INSERT INTO `bitacora` VALUES ('112', '178', '2011-05-27 00:00:00', 'Cierre de Caja del 2011-05-25', '4', 'N');
INSERT INTO `bitacora` VALUES ('113', '180', '2011-05-27 00:00:00', 'Apertura de Caja del 2011-05-27', '4', 'N');
INSERT INTO `bitacora` VALUES ('114', '184', '2011-05-27 16:23:51', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('115', '185', '2011-05-28 00:00:00', 'Cierre de Caja del 2011-05-27', '4', 'N');
INSERT INTO `bitacora` VALUES ('116', '187', '2011-05-28 00:00:00', 'Apertura de Caja del 2011-05-28', '4', 'N');
INSERT INTO `bitacora` VALUES ('117', '189', '2011-05-28 11:29:48', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('118', '191', '2011-05-28 11:31:20', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('119', '192', '2011-05-28 12:54:17', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('120', '193', '2011-05-28 13:17:39', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('121', '195', '2011-05-28 13:51:08', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('122', '168', '2011-05-28 17:45:09', 'Registro de despacho sin Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('123', '94', '2011-05-28 17:51:53', 'Registro de despacho sin Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('124', '197', '2011-05-28 18:53:07', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('125', '198', '2011-05-28 18:54:48', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('126', '199', '2011-05-28 18:56:25', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('127', '201', '2011-05-28 19:00:38', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('128', '202', '2011-05-28 19:02:09', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('129', '202', '2011-05-28 19:24:49', 'Registro de despacho sin Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('130', '204', '2011-05-28 19:55:55', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('131', '205', '2011-05-28 19:57:44', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('132', '205', '2011-05-28 19:58:43', 'Registro de despacho sin Guia de Remision', '4', 'N');
INSERT INTO `bitacora` VALUES ('133', '207', '2011-05-28 22:13:00', 'Registro de nuevo pedido', '4', 'N');
INSERT INTO `bitacora` VALUES ('134', '208', '2011-05-28 22:13:26', 'Registro de nueva venta', '4', 'N');
INSERT INTO `bitacora` VALUES ('135', '210', '2011-05-28 22:14:24', 'Registro de nueva venta', '4', 'N');
INSERT INTO `categoria` VALUES ('1', 'XX', 'XX', '0', '1', 'A');
INSERT INTO `categoria` VALUES ('2', 'yy', 'yy', '1', '2', 'A');
INSERT INTO `categoria` VALUES ('3', 'RR', 'RR', '0', '1', 'A');
INSERT INTO `categoria` VALUES ('4', 'ttt', 'tt', '1', '2', 'A');
INSERT INTO `categoria` VALUES ('5', 'qqq', 'qq', '2', '3', 'A');
INSERT INTO `categoria` VALUES ('6', 'uuu', 'uu', '5', '4', 'A');
INSERT INTO `categoria` VALUES ('7', 'www', 'ww', '6', '6', 'A');
INSERT INTO `categoria` VALUES ('8', 'fff', 'ff', '4', '3', 'A');
INSERT INTO `categoria` VALUES ('9', 'yyyuyuyuy', 'yu', '4', '3', 'A');
INSERT INTO `categoria` VALUES ('10', 'pinturas', 'pi', '5', '4', 'A');
INSERT INTO `categoria` VALUES ('11', 'gggg', 'gg', null, '1', 'A');
INSERT INTO `categoria` VALUES ('12', 'PINTURAS', 'PI', null, '1', 'N');
INSERT INTO `categoria` VALUES ('13', 'ESMALTE SINTETICO', 'ES', '12', '2', 'N');
INSERT INTO `categoria` VALUES ('14', 'ESMALTE ACRILICO', 'EA', '12', '2', 'N');
INSERT INTO `categoria` VALUES ('15', 'LATEX', 'LA', '12', '2', 'N');
INSERT INTO `categoria` VALUES ('16', 'TINER', 'TI', null, '1', 'N');
INSERT INTO `categoria` VALUES ('17', 'TUBO ESCALONADO DE SOLDADURA FRIA', 'TE', null, '1', 'N');
INSERT INTO `categoria` VALUES ('18', 'XX', 'XX', '15', '3', 'A');
INSERT INTO `categoria` VALUES ('19', 'ALMBRE', 'AL', '18', '4', 'N');
INSERT INTO `conceptopago` VALUES ('1', 'APERTURA DE CAJA', 'I');
INSERT INTO `conceptopago` VALUES ('2', 'CIERRE DE CAJA', 'E');
INSERT INTO `conceptopago` VALUES ('3', 'PAGO DE CLIENTE', 'I');
INSERT INTO `conceptopago` VALUES ('4', 'PAGO A PROVEEDOR', 'E');
INSERT INTO `conceptopago` VALUES ('5', 'POR ANULACION DE VENTA', 'E');
INSERT INTO `conceptopago` VALUES ('6', 'POR ANULACION DE COMPRA', 'I');
INSERT INTO `conceptopago` VALUES ('7', 'PAGO A PERSONAL', 'E');
INSERT INTO `conceptopago` VALUES ('8', 'PARA COMPRA DOLARES', 'E');
INSERT INTO `conceptopago` VALUES ('9', 'POR COMPRA DOLARES', 'I');
INSERT INTO `conceptopago` VALUES ('10', 'AJUSTE TIPO CAMBIO', 'I');
INSERT INTO `conceptopago` VALUES ('11', 'AJUSTE TIPO CAMBIO', 'E');
INSERT INTO `conceptopago` VALUES ('12', 'PRESTAMO', 'I');
INSERT INTO `conceptopago` VALUES ('13', 'DEVOLUCION PRESTAMO', 'E');
INSERT INTO `conceptopago` VALUES ('14', 'PRESTAMO', 'E');
INSERT INTO `conceptopago` VALUES ('15', 'DEVOLUCION PRESTAMO', 'I');
INSERT INTO `conceptopago` VALUES ('16', 'DEPOSITO', 'E');
INSERT INTO `cuota` VALUES ('1', '1', '6', '2011-01-20 00:00:00', '2011-02-20 00:00:00', '2011-01-25 00:00:00', 'S', '100.00', '0.00', '100.00', '0.00', 'C');
INSERT INTO `cuota` VALUES ('2', '2', '6', '2011-01-20 00:00:00', '2011-03-20 00:00:00', '0000-00-00 00:00:00', 'S', '100.00', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('3', '1', '11', '2011-01-20 00:00:00', '2011-02-20 00:00:00', '0000-00-00 00:00:00', 'S', '139.70', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('4', '1', '12', '2011-01-20 00:00:00', '2011-02-20 00:00:00', '0000-00-00 00:00:00', 'S', '62.70', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('5', '1', '41', '2011-01-26 00:00:00', '2011-02-26 00:00:00', '2011-04-27 00:00:00', 'S', '70.00', '0.00', '70.00', '0.00', 'C');
INSERT INTO `cuota` VALUES ('6', '1', '53', '2011-01-30 00:00:00', '2011-02-28 00:00:00', '0000-00-00 00:00:00', 'S', '70.00', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('7', '1', '129', '2011-04-25 00:00:00', '2011-05-25 00:00:00', '0000-00-00 00:00:00', 'D', '4.50', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('8', '2', '129', '2011-04-25 00:00:00', '2011-06-25 00:00:00', '0000-00-00 00:00:00', 'D', '4.50', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('9', '3', '129', '2011-04-25 00:00:00', '2011-07-25 00:00:00', '0000-00-00 00:00:00', 'D', '4.50', '0.00', '0.00', '0.00', 'N');
INSERT INTO `cuota` VALUES ('10', '4', '129', '2011-04-25 00:00:00', '2011-08-25 00:00:00', '0000-00-00 00:00:00', 'D', '4.50', '0.00', '0.00', '0.00', 'N');
INSERT INTO `departamento` VALUES ('1', 'AMAZONAS', '1', '01');
INSERT INTO `departamento` VALUES ('2', 'ANCASH', '1', '02');
INSERT INTO `departamento` VALUES ('3', 'APURIMAC', '1', '03');
INSERT INTO `departamento` VALUES ('4', 'AREQUIPA', '1', '04');
INSERT INTO `departamento` VALUES ('5', 'AYACUCHO', '1', '05');
INSERT INTO `departamento` VALUES ('6', 'CAJAMARCA', '1', '06');
INSERT INTO `departamento` VALUES ('7', 'CALLAO', '1', '07');
INSERT INTO `departamento` VALUES ('8', 'CUSCO', '1', '08');
INSERT INTO `departamento` VALUES ('9', 'HUANCAVELICA', '1', '09');
INSERT INTO `departamento` VALUES ('10', 'HUANUCO', '1', '10');
INSERT INTO `departamento` VALUES ('11', 'ICA', '1', '11');
INSERT INTO `departamento` VALUES ('12', 'JUNIN', '1', '12');
INSERT INTO `departamento` VALUES ('13', 'LA LIBERTAD', '1', '13');
INSERT INTO `departamento` VALUES ('14', 'LAMBAYEQUE', '1', '14');
INSERT INTO `departamento` VALUES ('15', 'LIMA', '1', '15');
INSERT INTO `departamento` VALUES ('16', 'LORETO', '1', '16');
INSERT INTO `departamento` VALUES ('17', 'MADRE DE DIOS', '1', '17');
INSERT INTO `departamento` VALUES ('18', 'MOQUEGUA', '1', '18');
INSERT INTO `departamento` VALUES ('19', 'PASCO', '1', '19');
INSERT INTO `departamento` VALUES ('20', 'PIURA', '1', '20');
INSERT INTO `departamento` VALUES ('21', 'PUNO', '1', '21');
INSERT INTO `departamento` VALUES ('22', 'SAN MARTIN', '1', '22');
INSERT INTO `departamento` VALUES ('23', 'TACNA', '1', '23');
INSERT INTO `departamento` VALUES ('24', 'TUMBES', '1', '24');
INSERT INTO `departamento` VALUES ('25', 'UCAYALI', '1', '25');
INSERT INTO `detallemovalmacen` VALUES ('1', '1', '1', '1', '10.00', '62.70', '71.22');
INSERT INTO `detallemovalmacen` VALUES ('2', '4', '1', '1', '3.00', '62.70', '71.22');
INSERT INTO `detallemovalmacen` VALUES ('3', '6', '1', '1', '3.00', '62.70', '71.22');
INSERT INTO `detallemovalmacen` VALUES ('4', '7', '1', '1', '1.00', '62.70', '71.22');
INSERT INTO `detallemovalmacen` VALUES ('5', '9', '1', '1', '1.00', '62.70', '71.22');