Mejorado el asunto en docker

This commit is contained in:
2021-07-09 01:11:04 -04:00
parent 450a171827
commit 81a1fa5115
3 changed files with 20 additions and 24 deletions

150
database/inserts-prueba.sql Normal file
View File

@@ -0,0 +1,150 @@
start transaction;
-----------------------------------
--- Creando restaurant de prueba
-----------------------------------
insert into restaurantes (nombre)
values ('Todo Rico Restaurant');
insert into categorias (nombre, restaurante_id)
values ('Platos de fondo', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Bebidas', (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into sectores (nombre, restaurante_id)
values ('Salon Principal', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Salon Secundario', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Virtual', (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into canales_venta (nombre, sector_id, tipo_canal_id, restaurante_id)
values ('1', (select id from sectores where nombre = 'Salon Principal'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('2', (select id from sectores where nombre = 'Salon Principal'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('3', (select id from sectores where nombre = 'Salon Principal'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('4', (select id from sectores where nombre = 'Salon Principal'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('5', (select id from sectores where nombre = 'Salon Principal'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('6', (select id from sectores where nombre = 'Salon Secundario'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('7', (select id from sectores where nombre = 'Salon Secundario'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('8', (select id from sectores where nombre = 'Salon Secundario'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('9', (select id from sectores where nombre = 'Salon Secundario'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('10', (select id from sectores where nombre = 'Salon Secundario'), (select id from tipos_canal where nombre = 'Mesa'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Pedidos Ya', (select id from sectores where nombre = 'Virtual'), (select id from tipos_canal where nombre = 'Delivery'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Uber Eats', (select id from sectores where nombre = 'Virtual'), (select id from tipos_canal where nombre = 'Delivery'), (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into zonas_produccion (nombre, restaurante_id)
values ('Cocina', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Barra', (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into usuarios_restaurantes (usuario_id, restaurante_id)
values ((select id from usuarios where nombre = 'Test'), (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into productores (usuario_id, zona_produccion_id)
values ((select id from usuarios where nombre = 'Test'), (select id from zonas_produccion where nombre = 'Cocina'));
insert into recaudadores (usuario_id)
values ((select id from usuarios where nombre = 'Test'));
insert into meseros (usuario_id)
values ((select id from usuarios where nombre = 'Test'));
insert into administradores (usuario_id)
values ((select id from usuarios where nombre = 'Test'));
-----------------------------------
--- Inventando ingredientes y productos de venta
-----------------------------------
insert into ingredientes (nombre, medida, restaurante_id)
values ('Papas', 'Kg', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Papas Pre-Fritas', 'Kg', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Sal', 'Kg', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Mantequilla', 'Kg', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Leche', 'L', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Chuletas', 'Kg', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Aceite', 'L', (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Coca-Cola', 'Unidad', (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into productos (nombre, precio_venta, categoria_id, zona_produccion_id, restaurante_id)
values ('Chuleta con Pure', 4390, (select id from categorias where nombre = 'Platos de fondo'),
(select id from zonas_produccion where nombre = 'Cocina'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Chuleta con Papas Fritas', 4690, (select id from categorias where nombre = 'Platos de fondo'),
(select id from zonas_produccion where nombre = 'Cocina'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('Coca-Cola', 1200, (select id from categorias where nombre = 'Bebidas'),
(select id from zonas_produccion where nombre = 'Barra'), (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into recetas (producto_id, ingrediente_id, unidades)
values ((select id from productos where nombre = 'Chuleta con Pure'), (select id from ingredientes where nombre = 'Papas'), 0.25),
((select id from productos where nombre = 'Chuleta con Pure'), (select id from ingredientes where nombre = 'Sal'), 0.002),
((select id from productos where nombre = 'Chuleta con Pure'), (select id from ingredientes where nombre = 'Mantequilla'), 0.03),
((select id from productos where nombre = 'Chuleta con Pure'), (select id from ingredientes where nombre = 'Leche'), 0.2),
((select id from productos where nombre = 'Chuleta con Pure'), (select id from ingredientes where nombre = 'Chuletas'), 0.25);
insert into recetas (producto_id, ingrediente_id, unidades)
values ((select id from productos where nombre = 'Chuleta con Papas Fritas'), (select id from ingredientes where nombre = 'Papas Pre-Fritas'), 0.25),
((select id from productos where nombre = 'Chuleta con Papas Fritas'), (select id from ingredientes where nombre = 'Aceite'), 0.01),
((select id from productos where nombre = 'Chuleta con Papas Fritas'), (select id from ingredientes where nombre = 'Sal'), 0.002),
((select id from productos where nombre = 'Chuleta con Papas Fritas'), (select id from ingredientes where nombre = 'Chuletas'), 0.25);
insert into recetas (producto_id, ingrediente_id, unidades)
values ((select id from productos where nombre = 'Coca-Cola'), (select id from ingredientes where nombre = 'Coca-Cola'), 1);
-----------------------------------
--- Creando compras para crear un inventario
-----------------------------------
insert into proveedores (rut, nombre, descripcion, direccion, telefono, restaurante_id)
values ('123-1', 'Coca-Cola', 'Vende Coca Cola', null, null, (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('123-1', 'Mr. Carnes', 'Vende Carnes', null, null, (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('123-1', 'Santa Isabel', 'Vende Productos Generales', null, null, (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into compras (fecha_compra, proveedor_id, restaurante_id)
values ('2021-01-01'::date, (select id from proveedores where nombre = 'Coca-Cola'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('2021-02-01'::date, (select id from proveedores where nombre = 'Mr. Carnes'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('2021-02-01'::date, (select id from proveedores where nombre = 'Santa Isabel'), (select id from restaurantes where nombre = 'Todo Rico Restaurant')),
('2021-01-01'::date, (select id from proveedores where nombre = 'Coca-Cola'), (select id from restaurantes where nombre = 'Todo Rico Restaurant'));
insert into compra_ingredientes (unidades, monto_unitario_bruto, monto_unitario_neto, compra_id, ingrediente_id)
values (20, 500, 500 * 1.19, (select id from compras limit 1 offset 0), (select id from ingredientes where nombre = 'Coca-Cola')),
(50, 1000, 1000 * 1.19, (select id from compras limit 1 offset 1), (select id from ingredientes where nombre = 'Chuletas')),
(25, 1000, 1000 * 1.19, (select id from compras limit 1 offset 2), (select id from ingredientes where nombre = 'Papas')),
(10, 500, 500 * 1.19, (select id from compras limit 1 offset 2), (select id from ingredientes where nombre = 'Papas Pre-Fritas')),
(5, 300, 300 * 1.19, (select id from compras limit 1 offset 2), (select id from ingredientes where nombre = 'Sal')),
(10, 2000, 2000 * 1.19, (select id from compras limit 1 offset 2), (select id from ingredientes where nombre = 'Mantequilla')),
(10, 700, 700 * 1.19, (select id from compras limit 1 offset 2), (select id from ingredientes where nombre = 'Leche')),
(50, 1000, 1000 * 1.19, (select id from compras limit 1 offset 2), (select id from ingredientes where nombre = 'Aceite')),
(20, 500, 500 * 1.19, (select id from compras limit 1 offset 3), (select id from ingredientes where nombre = 'Coca-Cola'));
insert into facturas (numero, monto_bruto, monto_neto, fecha_emision, fecha_vencimiento, compra_id)
values ('1', 500 * 20, 500 * 20 * 1.19, '2021-01-01'::date, '2021-01-30'::date, (select id from compras limit 1 offset 0)),
('1', 1000 * 50, 1000 * 50 * 1.19, '2021-02-01'::date, '2021-02-28'::date, (select id from compras limit 1 offset 1)),
('1', 108500, 129115, '2021-02-10'::date, '2021-02-28'::date, (select id from compras limit 1 offset 2)),
('1', 500 * 20, 500 * 20 * 1.19, '2021-01-01'::date, '2021-01-30'::date, (select id from compras limit 1 offset 0));
-----------------------------------
--- Creando ventas para descontar del inventario
-----------------------------------
insert into cajas (fondo, apertura, cierre) values (200000, '2021-02-01'::timestamptz, null);
insert into ventas (tiempo_venta, mesero_id, canal_id, restaurante_id, medio_pago_id, caja_id)
values (current_timestamp,
(select id from meseros limit 1),
(select id from canales_venta where nombre = '1'),
(select id from restaurantes where nombre = 'Todo Rico Restaurant'),
(select id from medios_pago where nombre = 'Efectivo'),
(select id from cajas limit 1));
insert into venta_productos (tiempo_entrada, tiempo_salida, venta_id, producto_id, estado_id)
values (current_timestamp, null, (select id from ventas limit 1), (select id from productos where nombre = 'Coca-Cola'),
(select id from estados_produccion where nombre = 'Enviada')),
(current_timestamp, null, (select id from ventas limit 1), (select id from productos where nombre = 'Coca-Cola'),
(select id from estados_produccion where nombre = 'Enviada')),
(current_timestamp, null, (select id from ventas limit 1), (select id from productos where nombre = 'Coca-Cola'),
(select id from estados_produccion where nombre = 'Enviada')),
(current_timestamp, null, (select id from ventas limit 1), (select id from productos where nombre = 'Chuleta con Papas Fritas'),
(select id from estados_produccion where nombre = 'Enviada')),
(current_timestamp, null, (select id from ventas limit 1), (select id from productos where nombre = 'Chuleta con Papas Fritas'),
(select id from estados_produccion where nombre = 'Enviada')),
(current_timestamp, null, (select id from ventas limit 1), (select id from productos where nombre = 'Chuleta con Pure'),
(select id from estados_produccion where nombre = 'Enviada'));
commit;