Update 2022-03-07
This commit is contained in:
2
.adminer.env
Normal file
2
.adminer.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ADMINER_DESIGN=dracula
|
||||||
|
ADMINER_PLUGINS=dump-json
|
4
.db.env
Normal file
4
.db.env
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
MYSQL_DATABASE=incoviba
|
||||||
|
MYSQL_PASSWORD=5GQYFvRjVw2A4KcD
|
||||||
|
MYSQL_ROOT_PASSWORD=password
|
||||||
|
MYSQL_USER=incoviba
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ package-lock.json
|
|||||||
Pipfile.lock
|
Pipfile.lock
|
||||||
/logs/
|
/logs/
|
||||||
/cache/
|
/cache/
|
||||||
|
/modules/
|
||||||
|
@ -410,6 +410,8 @@ class Informes
|
|||||||
public static function ventas()
|
public static function ventas()
|
||||||
{
|
{
|
||||||
if (get('proyecto')) {
|
if (get('proyecto')) {
|
||||||
|
ini_set('memory_limit', "1G");
|
||||||
|
ini_set('max_execution_time', '3600');
|
||||||
$id = get('proyecto');
|
$id = get('proyecto');
|
||||||
$proyecto = model(Proyecto::class)->findOne($id);
|
$proyecto = model(Proyecto::class)->findOne($id);
|
||||||
$ventas = $proyecto->ventas();
|
$ventas = $proyecto->ventas();
|
||||||
@ -434,7 +436,7 @@ class Informes
|
|||||||
|
|
||||||
$columnas = [
|
$columnas = [
|
||||||
'Propietario',
|
'Propietario',
|
||||||
['name' => 'Departamento', 'style' => 'number'],
|
'Departamento',
|
||||||
['name' => 'Estacionamientos', 'style' => 'number'],
|
['name' => 'Estacionamientos', 'style' => 'number'],
|
||||||
['name' => 'Bodegas', 'style' => 'number'],
|
['name' => 'Bodegas', 'style' => 'number'],
|
||||||
'Fecha Venta',
|
'Fecha Venta',
|
||||||
@ -457,7 +459,8 @@ class Informes
|
|||||||
['name' => 'Valor Neto', 'style' => 'amount'],
|
['name' => 'Valor Neto', 'style' => 'amount'],
|
||||||
['name' => 'UF/m²*', 'style' => 'amount'],
|
['name' => 'UF/m²*', 'style' => 'amount'],
|
||||||
['name' => 'Comision', 'style' => 'amount'],
|
['name' => 'Comision', 'style' => 'amount'],
|
||||||
['name' => 'Venta s/Comision', 'style' => 'amount']
|
['name' => 'Venta s/Comision', 'style' => 'amount'].
|
||||||
|
['name' => 'Precio', 'style' => 'Amount']
|
||||||
];
|
];
|
||||||
//$informe->addColumns($columnas);
|
//$informe->addColumns($columnas);
|
||||||
|
|
||||||
@ -465,28 +468,14 @@ class Informes
|
|||||||
foreach ($ventas as $venta) {
|
foreach ($ventas as $venta) {
|
||||||
$info = [];
|
$info = [];
|
||||||
$info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto());
|
$info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto());
|
||||||
$info['Departamento'] = trim(array_reduce($venta->propiedad()->departamentos(), function($carry, $item) {
|
$info['Departamento'] = implode(' - ', array_map(function($item) {
|
||||||
return implode(' - ', [$carry, $item->descripcion]);
|
return $item->descripcion;
|
||||||
}), ' -');
|
}, $venta->propiedad()->departamentos()));
|
||||||
//$ests = [];
|
|
||||||
$es = $venta->propiedad()->estacionamientos();
|
$es = $venta->propiedad()->estacionamientos();
|
||||||
/*if (count($es) > 0) {
|
|
||||||
foreach ($es as $e) {
|
|
||||||
$ests []= $e->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Estacionamientos'] = implode(', ', $ests);*/
|
|
||||||
$info['Estacionamientos'] = implode(', ', array_map(function($item) {
|
$info['Estacionamientos'] = implode(', ', array_map(function($item) {
|
||||||
return $item->descripcion;
|
return $item->descripcion;
|
||||||
}, $es));
|
}, $es));
|
||||||
//$bods = [];
|
|
||||||
$bs = $venta->propiedad()->bodegas();
|
$bs = $venta->propiedad()->bodegas();
|
||||||
/*if (count($bs) > 0) {
|
|
||||||
foreach ($bs as $b) {
|
|
||||||
$bods []= $b->descripcion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Bodegas'] = implode(', ', $bods);*/
|
|
||||||
$info['Bodegas'] = implode(', ', array_map(function($item) {
|
$info['Bodegas'] = implode(', ', array_map(function($item) {
|
||||||
return $item->descripcion;
|
return $item->descripcion;
|
||||||
}, $bs));
|
}, $bs));
|
||||||
@ -495,7 +484,7 @@ class Informes
|
|||||||
$info['Tipo'] = $venta->unidad()->abreviacion;
|
$info['Tipo'] = $venta->unidad()->abreviacion;
|
||||||
$info['m² Ponderados'] = $venta->unidad()->m2('vendible');
|
$info['m² Ponderados'] = $venta->unidad()->m2('vendible');
|
||||||
$info['Valor Promesa'] = $venta->valor_uf;
|
$info['Valor Promesa'] = $venta->valor_uf;
|
||||||
$info['Pie'] = $venta->pie()->valor;
|
$info['Pie'] = $venta->pie()->valor;
|
||||||
$info['Pie Pagado'] = 0;
|
$info['Pie Pagado'] = 0;
|
||||||
$info['% Pie Pagado'] = 0;
|
$info['% Pie Pagado'] = 0;
|
||||||
if ($venta->pie()) {
|
if ($venta->pie()) {
|
||||||
@ -508,12 +497,6 @@ class Informes
|
|||||||
$info['Valor Operador'] = $venta->valorComision();
|
$info['Valor Operador'] = $venta->valorComision();
|
||||||
//$promos = 0;
|
//$promos = 0;
|
||||||
$ps = $venta->promociones();
|
$ps = $venta->promociones();
|
||||||
/*if (count($ps) > 0) {
|
|
||||||
foreach ($ps as $promo) {
|
|
||||||
$promos += $promo->valor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$info['Premios'] = $promos;*/
|
|
||||||
$info['Premios'] = array_reduce($ps, function($sum, $item) {
|
$info['Premios'] = array_reduce($ps, function($sum, $item) {
|
||||||
return $sum + $item->valor;
|
return $sum + $item->valor;
|
||||||
});
|
});
|
||||||
@ -536,31 +519,17 @@ class Informes
|
|||||||
$info['UF/m²*'] = $venta->uf_m2();
|
$info['UF/m²*'] = $venta->uf_m2();
|
||||||
$info['Comision'] = $venta->valorFinal() * $comision;
|
$info['Comision'] = $venta->valorFinal() * $comision;
|
||||||
$info['Venta s/Comision'] = $venta->valorFinal() - $info['Comision'];
|
$info['Venta s/Comision'] = $venta->valorFinal() - $info['Comision'];
|
||||||
|
$fecha = $venta->fecha();
|
||||||
|
$info['Precio'] = 0;
|
||||||
|
try {
|
||||||
|
$info['Precio'] = array_reduce($venta->propiedad()->departamentos(), function($sum, $item) use ($fecha) {
|
||||||
|
return $sum + $item->precio($fecha)->valor;
|
||||||
|
});
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$data []= $info;
|
$data []= $info;
|
||||||
}
|
}
|
||||||
/*$informe->addData($data);
|
|
||||||
|
|
||||||
$totals = [
|
|
||||||
'Propietario' => 'TOTAL',
|
|
||||||
'Departamento' => 'count',
|
|
||||||
'Estacionamientos' => 'count',
|
|
||||||
'Bodegas' => 'count',
|
|
||||||
'm² Ponderados' => 'sum',
|
|
||||||
'Valor Promesa' => 'sum',
|
|
||||||
'Bono Pie' => 'sum',
|
|
||||||
'Subsidio' => 'sum',
|
|
||||||
'Ahorro' => 'sum',
|
|
||||||
'Credito' => 'sum',
|
|
||||||
'Valor Operador' => 'sum',
|
|
||||||
'Premios' => 'sum',
|
|
||||||
'Valor Ests & Bods' => 'sum',
|
|
||||||
'Valor Neto' => 'sum',
|
|
||||||
'Comision' => 'sum'
|
|
||||||
];
|
|
||||||
$informe->addTotals($totals);
|
|
||||||
|
|
||||||
return $informe->informe();*/
|
|
||||||
|
|
||||||
$body = [
|
$body = [
|
||||||
"Proyecto" => $proyecto->descripcion,
|
"Proyecto" => $proyecto->descripcion,
|
||||||
|
@ -163,53 +163,25 @@ class Ventas
|
|||||||
$unis = json_decode(post('unidades'));
|
$unis = json_decode(post('unidades'));
|
||||||
$id_principal = array_shift($unis);
|
$id_principal = array_shift($unis);
|
||||||
$principal = model(Unidad::class)->findOne(post('unidad' . $id_principal));
|
$principal = model(Unidad::class)->findOne(post('unidad' . $id_principal));
|
||||||
$propiedad = model(Propiedad::class)
|
|
||||||
->select('propiedad.*')
|
|
||||||
->join('unidad', ['unidad.id', '=', 'propiedad.unidad_principal'])
|
|
||||||
->where('propiedad.unidad_principal', $principal->id)
|
|
||||||
->where('unidad.proyecto', post('proyecto'))
|
|
||||||
->orderByDesc('propiedad.id')
|
|
||||||
->findOne();
|
|
||||||
// Revisar si existe la propiedad y si está vigente.
|
// Revisar si existe la propiedad y si está vigente.
|
||||||
if (!$propiedad or ($propiedad->venta() and $propiedad->venta()->estado() and $propiedad->venta()->estado()->tipo()->descripcion != 'vigente')) {
|
$propiedad = model(Propiedad::class)->create();
|
||||||
if (!$propiedad) {
|
$propiedad->unidad_principal = $principal->id;
|
||||||
$propiedad = model(Propiedad::class)->create();
|
$propiedad->save();
|
||||||
}
|
$data = [
|
||||||
$propiedad->unidad_principal = $principal->id;
|
'propiedad' => $propiedad->id,
|
||||||
$propiedad->save();
|
'unidad' => $principal->id,
|
||||||
|
'principal' => 1
|
||||||
|
];
|
||||||
|
$pu = model(PropiedadUnidad::class)->create($data);
|
||||||
|
$pu->save();
|
||||||
|
foreach ($unis as $id_unidad) {
|
||||||
$data = [
|
$data = [
|
||||||
'propiedad' => $propiedad->id,
|
'propiedad' => $propiedad->id,
|
||||||
'unidad' => $principal->id,
|
'unidad' => post('unidad' . $id_unidad),
|
||||||
'principal' => 1
|
'principal' => 0
|
||||||
];
|
];
|
||||||
$pu = model(PropiedadUnidad::class)->create($data);
|
$pu = model(PropiedadUnidad::class)->create($data);
|
||||||
$pu->save();
|
$pu->save();
|
||||||
foreach ($unis as $id_unidad) {
|
|
||||||
$data = [
|
|
||||||
'propiedad' => $propiedad->id,
|
|
||||||
'unidad' => post('unidad' . $id_unidad),
|
|
||||||
'principal' => 0
|
|
||||||
];
|
|
||||||
$pu = model(PropiedadUnidad::class)->create($data);
|
|
||||||
$pu->save();
|
|
||||||
}
|
|
||||||
/*$ests = [];
|
|
||||||
$bods = [];
|
|
||||||
foreach ($unis as $id_unidad) {
|
|
||||||
$unidad = model(Unidad::class)->findOne(post('unidad' . $id_unidad));
|
|
||||||
if ($unidad->tipo == 2) {
|
|
||||||
$ests []= $unidad->id;
|
|
||||||
}
|
|
||||||
if ($unidad->tipo == 3) {
|
|
||||||
$bods []= $unidad->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$propiedad->estacionamientos = implode(';', $ests);
|
|
||||||
$propiedad->bodegas = implode(';', $bods);
|
|
||||||
$propiedad->save();*/
|
|
||||||
} elseif ($propiedad->venta() and $propiedad->venta()->estado()->tipo()->descripcion == 'vigente') {
|
|
||||||
// Existe la propiedad en este proyecto y está vigente. Error, no se debiese vender si está vigente.
|
|
||||||
throw new \Exception('Existe la propiedad en este proyecto y está vigente. Error, no se debiese vender si está vigente.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$venta = model(Venta::class)->create();
|
$venta = model(Venta::class)->create();
|
||||||
|
@ -1,141 +1,141 @@
|
|||||||
from flask import Blueprint, request, Response
|
from flask import Blueprint, request, Response
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
ventas_blueprint = Blueprint('ventas', __name__,)
|
ventas_blueprint = Blueprint('ventas', __name__,)
|
||||||
|
|
||||||
|
|
||||||
def format_data(data):
|
def format_data(data):
|
||||||
df = pd.DataFrame(data)
|
df = pd.DataFrame(data)
|
||||||
int_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
int_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
||||||
for col in int_columns:
|
for col in int_columns:
|
||||||
df[col] = pd.to_numeric(df[col], errors='ignore')
|
df[col] = pd.to_numeric(df[col], errors='ignore')
|
||||||
float_columns = ['Valor Promesa', 'Pie', 'Pie Pagado', '% Pie Pagado', 'Bono Pie', 'Valor Operador',
|
float_columns = ['Valor Promesa', 'Pie', 'Pie Pagado', '% Pie Pagado', 'Bono Pie', 'Valor Operador',
|
||||||
'Premios', 'Subsidio', 'Ahorro', 'Credito', 'Valor Ests & Bods', 'Valor Neto',
|
'Premios', 'Subsidio', 'Ahorro', 'Credito', 'Valor Ests & Bods', 'Valor Neto',
|
||||||
'UF/m²*', 'Comision', 'Venta s/Comision']
|
'UF/m²*', 'Comision', 'Venta s/Comision', 'Precio']
|
||||||
for col in float_columns:
|
for col in float_columns:
|
||||||
if col in df.columns:
|
if col in df.columns:
|
||||||
df[col] = pd.to_numeric(df[col], errors='coerce')
|
df[col] = pd.to_numeric(df[col], errors='coerce')
|
||||||
df = df.replace(np.nan, 0, regex=True)
|
df = df.replace(np.nan, 0, regex=True)
|
||||||
|
|
||||||
df['Fecha Venta'] = pd.to_datetime(df['Fecha Venta'], format='%Y-%m-%d')
|
df['Fecha Venta'] = pd.to_datetime(df['Fecha Venta'], format='%Y-%m-%d')
|
||||||
df = df.sort_values(by=['Fecha Venta', 'Departamento'])
|
df = df.sort_values(by=['Fecha Venta', 'Departamento'])
|
||||||
df['Fecha Venta'] = df['Fecha Venta'].dt.strftime('%d.%m.%Y')
|
df['Fecha Venta'] = df['Fecha Venta'].dt.strftime('%d.%m.%Y')
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
def format_columns(workbook, columns):
|
def format_columns(workbook, columns):
|
||||||
column_settings = [{'header': column} for column in columns]
|
column_settings = [{'header': column} for column in columns]
|
||||||
|
|
||||||
center_format = workbook.add_format({'align': 'center'})
|
center_format = workbook.add_format({'align': 'center'})
|
||||||
amount_format = workbook.add_format({'num_format': '#,##0.00'})
|
amount_format = workbook.add_format({'num_format': '#,##0.00'})
|
||||||
percent_format = workbook.add_format({'num_format': '0.00%'})
|
percent_format = workbook.add_format({'num_format': '0.00%'})
|
||||||
|
|
||||||
amount_columns = ['m² Ponderados', 'Valor Promesa', 'Pie', 'Pie Pagado', 'Bono Pie', 'Valor Operador', 'Premios',
|
amount_columns = ['m² Ponderados', 'Valor Promesa', 'Pie', 'Pie Pagado', 'Bono Pie', 'Valor Operador', 'Premios',
|
||||||
'Subsidio', 'Ahorro', 'Credito', 'Valor Ests & Bods', 'Valor Neto', 'UF/m²*', 'Comision',
|
'Subsidio', 'Ahorro', 'Credito', 'Valor Ests & Bods', 'Valor Neto', 'UF/m²*', 'Comision',
|
||||||
'Venta s/Comision']
|
'Venta s/Comision', 'Precio']
|
||||||
center_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
center_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
||||||
sum_columns = ['m² Ponderados', 'Valor Promesa', 'Pie', 'Pie Pagado', 'Bono Pie', 'Subsidio', 'Ahorro', 'Credito',
|
sum_columns = ['m² Ponderados', 'Valor Promesa', 'Pie', 'Pie Pagado', 'Bono Pie', 'Subsidio', 'Ahorro', 'Credito',
|
||||||
'Valor Operador', 'Premios', 'Valor Ests & Bods', 'Valor Neto', 'Comision']
|
'Valor Operador', 'Premios', 'Valor Ests & Bods', 'Valor Neto', 'Comision']
|
||||||
count_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
count_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
||||||
|
|
||||||
for (k, col) in enumerate(column_settings):
|
for (k, col) in enumerate(column_settings):
|
||||||
if col['header'] in amount_columns:
|
if col['header'] in amount_columns:
|
||||||
column_settings[k]['format'] = amount_format
|
column_settings[k]['format'] = amount_format
|
||||||
if col['header'] in center_columns:
|
if col['header'] in center_columns:
|
||||||
column_settings[k]['format'] = center_format
|
column_settings[k]['format'] = center_format
|
||||||
if col['header'] in sum_columns:
|
if col['header'] in sum_columns:
|
||||||
column_settings[k]['total_function'] = 'sum'
|
column_settings[k]['total_function'] = 'sum'
|
||||||
if col['header'] in count_columns:
|
if col['header'] in count_columns:
|
||||||
column_settings[k]['total_function'] = 'count'
|
column_settings[k]['total_function'] = 'count'
|
||||||
if col['header'] == '% Pie Pagado':
|
if col['header'] == '% Pie Pagado':
|
||||||
column_settings[k]['format'] = percent_format
|
column_settings[k]['format'] = percent_format
|
||||||
if col['header'] == 'Propietario':
|
if col['header'] == 'Propietario':
|
||||||
column_settings[k]['total_string'] = 'TOTAL'
|
column_settings[k]['total_string'] = 'TOTAL'
|
||||||
|
|
||||||
return column_settings
|
return column_settings
|
||||||
|
|
||||||
|
|
||||||
def format_excel(workbook, worksheet, data):
|
def format_excel(workbook, worksheet, data):
|
||||||
center_format = workbook.add_format({'align': 'center'})
|
center_format = workbook.add_format({'align': 'center'})
|
||||||
amount_format = workbook.add_format({'num_format': '#,##0.00'})
|
amount_format = workbook.add_format({'num_format': '#,##0.00'})
|
||||||
percent_format = workbook.add_format({'num_format': '0.00%'})
|
percent_format = workbook.add_format({'num_format': '0.00%'})
|
||||||
|
|
||||||
amount_columns = ['m² Ponderados', 'Valor Promesa', 'Pie', 'Pie Pagado', 'Bono Pie', 'Valor Operador', 'Premios',
|
amount_columns = ['m² Ponderados', 'Valor Promesa', 'Pie', 'Pie Pagado', 'Bono Pie', 'Valor Operador', 'Premios',
|
||||||
'Subsidio', 'Ahorro', 'Credito', 'Valor Ests & Bods', 'Valor Neto', 'UF/m²*', 'Comision',
|
'Subsidio', 'Ahorro', 'Credito', 'Valor Ests & Bods', 'Valor Neto', 'UF/m²*', 'Comision',
|
||||||
'Venta s/Comision']
|
'Venta s/Comision', 'Precio']
|
||||||
center_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
center_columns = ['Departamento', 'Estacionamientos', 'Bodegas']
|
||||||
|
|
||||||
for col in amount_columns:
|
for col in amount_columns:
|
||||||
if col not in data.columns:
|
if col not in data.columns:
|
||||||
continue
|
continue
|
||||||
k = data.columns.get_loc(col) + 1
|
k = data.columns.get_loc(col) + 1
|
||||||
worksheet.set_column(k, k, cell_format=amount_format)
|
worksheet.set_column(k, k, cell_format=amount_format)
|
||||||
for col in center_columns:
|
for col in center_columns:
|
||||||
if col not in data.columns:
|
if col not in data.columns:
|
||||||
continue
|
continue
|
||||||
k = data.columns.get_loc(col) + 1
|
k = data.columns.get_loc(col) + 1
|
||||||
worksheet.set_column(k, k, cell_format=center_format)
|
worksheet.set_column(k, k, cell_format=center_format)
|
||||||
col = '% Pie Pagado'
|
col = '% Pie Pagado'
|
||||||
k = data.columns.get_loc(col) + 1
|
k = data.columns.get_loc(col) + 1
|
||||||
worksheet.set_column(k, k, cell_format=percent_format)
|
worksheet.set_column(k, k, cell_format=percent_format)
|
||||||
|
|
||||||
return worksheet
|
return worksheet
|
||||||
|
|
||||||
|
|
||||||
@ventas_blueprint.route('', methods=['POST'])
|
@ventas_blueprint.route('', methods=['POST'])
|
||||||
def ventas():
|
def ventas():
|
||||||
data = json.loads(request.data)
|
data = json.loads(request.data)
|
||||||
output = io.BytesIO()
|
output = io.BytesIO()
|
||||||
writer = pd.ExcelWriter('tmp.xlsx', engine='xlsxwriter')
|
writer = pd.ExcelWriter('tmp.xlsx', engine='xlsxwriter')
|
||||||
df = format_data(data['data'])
|
df = format_data(data['data'])
|
||||||
|
|
||||||
start_row = 4
|
start_row = 4
|
||||||
if 'Compañía' in data:
|
if 'Compañía' in data:
|
||||||
start_row += 1
|
start_row += 1
|
||||||
df.to_excel(writer, startrow=start_row+1, startcol=1, header=False, index=False, sheet_name='Ventas')
|
df.to_excel(writer, startrow=start_row+1, startcol=1, header=False, index=False, sheet_name='Ventas')
|
||||||
wb = writer.book
|
wb = writer.book
|
||||||
wb.filename = output
|
wb.filename = output
|
||||||
|
|
||||||
title_format = wb.add_format({'font_size': 16, 'bold': True})
|
title_format = wb.add_format({'font_size': 16, 'bold': True})
|
||||||
ws = writer.sheets['Ventas']
|
ws = writer.sheets['Ventas']
|
||||||
(max_row, max_col) = df.shape
|
(max_row, max_col) = df.shape
|
||||||
|
|
||||||
if 'Compañía' in data:
|
if 'Compañía' in data:
|
||||||
ws.merge_range(1, 1, 1, max_col, data['Compañía'])
|
ws.merge_range(1, 1, 1, max_col, data['Compañía'])
|
||||||
ws.merge_range(start_row-3, 1, start_row-3, max_col, data['Proyecto'], cell_format=title_format)
|
ws.merge_range(start_row-3, 1, start_row-3, max_col, data['Proyecto'], cell_format=title_format)
|
||||||
ws.write_string(start_row-2, 1, 'Ventas')
|
ws.write_string(start_row-2, 1, 'Ventas')
|
||||||
column_settings = format_columns(wb, df.columns)
|
column_settings = format_columns(wb, df.columns)
|
||||||
ws.add_table(start_row, 1, max_row+start_row+1, max_col, {'name': 'Ventas', 'total_row': 1,
|
ws.add_table(start_row, 1, max_row+start_row+1, max_col, {'name': 'Ventas', 'total_row': 1,
|
||||||
'columns': column_settings,
|
'columns': column_settings,
|
||||||
'style': 'Table Style Medium 1'})
|
'style': 'Table Style Medium 1'})
|
||||||
ws = format_excel(wb, ws, df)
|
ws = format_excel(wb, ws, df)
|
||||||
|
|
||||||
column_widths = {
|
column_widths = {
|
||||||
'B': 46,
|
'B': 46,
|
||||||
'C': 16,
|
'C': 16,
|
||||||
'D': 18,
|
'D': 18,
|
||||||
'E': 10,
|
'E': 10,
|
||||||
'F': 13,
|
'F': 13,
|
||||||
'G': 7,
|
'G': 7,
|
||||||
'H': 8,
|
'H': 8,
|
||||||
'I': 16,
|
'I': 16,
|
||||||
'J': 16,
|
'J': 16,
|
||||||
'K': 13,
|
'K': 13,
|
||||||
'L': 14
|
'L': 14
|
||||||
}
|
}
|
||||||
for (col, wd) in column_widths.items():
|
for (col, wd) in column_widths.items():
|
||||||
ws.set_column('{0}:{0}'.format(col), wd)
|
ws.set_column('{0}:{0}'.format(col), wd)
|
||||||
|
|
||||||
writer.save()
|
writer.save()
|
||||||
output.seek(0)
|
output.seek(0)
|
||||||
date = datetime.date.today()
|
date = datetime.date.today()
|
||||||
filename = "Informe de Ventas - {0} - {1}.xlsx".format(data['Proyecto'], date.strftime('%Y-%m-%d'))
|
filename = "Informe de Ventas - {0} - {1}.xlsx".format(data['Proyecto'], date.strftime('%Y-%m-%d'))
|
||||||
return Response(output, mimetype="application/ms-excel",
|
return Response(output, mimetype="application/ms-excel",
|
||||||
headers={"Content-Disposition": "attachment;filename={0}".format(filename),
|
headers={"Content-Disposition": "attachment;filename={0}".format(filename),
|
||||||
"Content-Type": 'application/octet-stream; charset=utf-8'})
|
"Content-Type": 'application/octet-stream; charset=utf-8'})
|
||||||
|
@ -7,4 +7,4 @@ return [
|
|||||||
'benchmark' => false,
|
'benchmark' => false,
|
||||||
'login_hours' => 5*24
|
'login_hours' => 5*24
|
||||||
];
|
];
|
||||||
?>
|
?>
|
||||||
|
@ -23,12 +23,8 @@ services:
|
|||||||
image: mariadb:latest
|
image: mariadb:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 3307:3306
|
- 3308:3306
|
||||||
environment:
|
env_file: .db.env
|
||||||
MYSQL_ROOT_PASSWORD: 'password'
|
|
||||||
MYSQL_DATABASE: 'incoviba'
|
|
||||||
MYSQL_USER: 'incoviba'
|
|
||||||
MYSQL_PASSWORD: '5GQYFvRjVw2A4KcD'
|
|
||||||
volumes:
|
volumes:
|
||||||
- dbdata:/var/lib/mysql
|
- dbdata:/var/lib/mysql
|
||||||
|
|
||||||
@ -37,10 +33,8 @@ services:
|
|||||||
image: adminer:latest
|
image: adminer:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 8082:8080
|
- 8083:8080
|
||||||
environment:
|
env_file: .adminer.env
|
||||||
ADMINER_DESIGN: 'dracula'
|
|
||||||
ADMINER_PLUGINS: 'dump-json'
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
dbdata:
|
dbdata:
|
||||||
|
@ -131,7 +131,7 @@ class Proyecto extends Model
|
|||||||
$unidades['disponibles'] = (array) $this->unidades->disponibles;
|
$unidades['disponibles'] = (array) $this->unidades->disponibles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$q_s = "SELECT u.*
|
/*$q_s = "SELECT u.*
|
||||||
FROM
|
FROM
|
||||||
(SELECT * FROM unidad WHERE proyecto = ? ORDER BY tipo) AS u
|
(SELECT * FROM unidad WHERE proyecto = ? ORDER BY tipo) AS u
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
@ -158,7 +158,18 @@ class Proyecto extends Model
|
|||||||
OR propiedad.bodegas LIKE CONCAT('%;', unidad.id)
|
OR propiedad.bodegas LIKE CONCAT('%;', unidad.id)
|
||||||
OR propiedad.bodegas LIKE CONCAT('%;', unidad.id, ';%')
|
OR propiedad.bodegas LIKE CONCAT('%;', unidad.id, ';%')
|
||||||
WHERE venta.estado = 1) AS b ON b.id = u.id
|
WHERE venta.estado = 1) AS b ON b.id = u.id
|
||||||
WHERE v.id IS NULL AND e.id IS NULL AND b.id IS NULL";
|
WHERE v.id IS NULL AND e.id IS NULL AND b.id IS NULL";*/
|
||||||
|
$q_s = "SELECT u.*
|
||||||
|
FROM
|
||||||
|
(SELECT * FROM unidad WHERE proyecto = ? ORDER BY tipo) AS u
|
||||||
|
LEFT JOIN (SELECT unidad.*
|
||||||
|
FROM unidad
|
||||||
|
JOIN propiedad_unidad pu ON pu.unidad = unidad.id
|
||||||
|
JOIN venta ON venta.propiedad = pu.propiedad
|
||||||
|
JOIN (SELECT e1.* FROM estado_venta e1
|
||||||
|
JOIN (SELECT venta, MAX(id) AS id FROM estado_venta GROUP BY venta) e0 ON e0.id = e1.id) ev ON ev.venta = venta.id
|
||||||
|
WHERE ev.estado = 1) AS v ON v.id = u.id
|
||||||
|
WHERE v.id IS NULL";
|
||||||
$q_p = " ORDER BY u.tipo, LPAD(u.descripcion, 4, '0')";
|
$q_p = " ORDER BY u.tipo, LPAD(u.descripcion, 4, '0')";
|
||||||
switch (strtolower($id_tipo)) {
|
switch (strtolower($id_tipo)) {
|
||||||
case null:
|
case null:
|
||||||
|
1
modules/operadores
Submodule
1
modules/operadores
Submodule
Submodule modules/operadores added at 71e10c52bd
@ -33,6 +33,13 @@
|
|||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<li rol="presentation" class="dropdown">
|
||||||
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
|
||||||
|
Operadores <span class="caret"></span>
|
||||||
|
</a>
|
||||||
|
@include('layout.menu.operadores')
|
||||||
|
</li>
|
||||||
|
|
||||||
@if (\App\Contract\Auth::checkAccess('viewHerramientas'))
|
@if (\App\Contract\Auth::checkAccess('viewHerramientas'))
|
||||||
<li role="presentation" class="dropdown">
|
<li role="presentation" class="dropdown">
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
|
||||||
|
12
resources/views/layout/menu/operadores.blade.php
Normal file
12
resources/views/layout/menu/operadores.blade.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li>
|
||||||
|
<a href="http://provm.cl:8000/operadores">Listado</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="http://provm.cl:8000/ventas">Ventas</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="http://provm.cl:8000/facturas">Informe</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
@ -257,14 +257,33 @@ function changeProyecto() {
|
|||||||
});
|
});
|
||||||
$('#unidades').show();
|
$('#unidades').show();
|
||||||
});
|
});
|
||||||
$.post('{!!url('', ['p' => 'ajax', 'a' => 'operadores', 'ajax' => true])!!}', {"proyecto": proyecto}, function(data) {
|
$.ajax({
|
||||||
var operadores = $("select[name='operador']");
|
url: 'https://provm.cl:8001/proyecto/' + proyecto + '/operadores',
|
||||||
operadores.html('').append($('<option></option>').attr('value', 0).html('---'));
|
method: 'get',
|
||||||
var info = $.parseJSON(data);
|
dataType: 'json'
|
||||||
$.each(info, function(i, e) {
|
}).then(function(data) {
|
||||||
operadores.append($('<option></option>').attr('value', e.id).html(e.abreviacion));
|
var operadoress = $("select[name='operador']");
|
||||||
});
|
operadores.html('').append($('<option></option>').attr('value', 0).html('---'));
|
||||||
|
$.each(data.operadores, function(i, e) {
|
||||||
|
operadores.append($('<option></option>').attr('value', e.id).html(e.operador.abreviacion));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
/*$.getJSON('http://provm.cl:8001/proyecto/' + proyecto + '/operadores', function(data) {
|
||||||
|
var operadores = $("select[name='operador']");
|
||||||
|
operadores.html('').append($('<option></option>').attr('value', 0).html('---'));
|
||||||
|
$.each(data.operadores, function(i, e) {
|
||||||
|
operadores.append($('<option></option>').attr('value', e.id).html(e.operador.abreviacion));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$.post('{!!url('', ['p' => 'ajax', 'a' => 'operadores', 'ajax' => true])!!}', {"proyecto": proyecto}, function(data) {
|
||||||
|
var operadores = $("select[name='operador']");
|
||||||
|
operadores.html('').append($('<option></option>').attr('value', 0).html('---'));
|
||||||
|
var info = $.parseJSON(data);
|
||||||
|
$.each(info, function(i, e) {
|
||||||
|
operadores.append($('<option></option>').attr('value', e.id).html(e.abreviacion));
|
||||||
|
});
|
||||||
|
});*/
|
||||||
}
|
}
|
||||||
function agregarUnidad(tipo, name) {
|
function agregarUnidad(tipo, name) {
|
||||||
var proyecto = $("select[name='proyecto']").val();
|
var proyecto = $("select[name='proyecto']").val();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<select name="asociado" class="form-control">
|
<select name="asociado" class="form-control">
|
||||||
@foreach ($pie->venta()->propietario()->ventas() as $v)
|
@foreach ($pie->venta()->propietario()->ventas() as $v)
|
||||||
@if ($v->unidad()->id == $pie->venta()->unidad()->id)
|
@if ($v->unidad()->id == $pie->venta()->unidad()->id or $v->pie == 0)
|
||||||
@continue
|
@continue
|
||||||
@endif
|
@endif
|
||||||
<option value="{{$v->pie()->id}}">
|
<option value="{{$v->pie()->id}}">
|
||||||
|
Reference in New Issue
Block a user