Skip to content

Commit

Permalink
Made some progress in the resume view.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbdavide committed Oct 14, 2017
1 parent a4f5005 commit 5a9b6c5
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
73 changes: 73 additions & 0 deletions sales/static/js/listado.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
'use strict'

$(document).ready(function() {

var elements = {
'row' : $('#row_base'),
'table' : $('#table'),
'table_expense' : $('#table_expense')
}

var buttons = {
'print' : $('#print')
}

$.get('/registros', function(data) {
var registros = data.data

var ingresos = {}
var gastos = {}

for(var i in registros) {
var name = registros[i]['owner_name']

if(registros[i].register_type === 'ingreso') {

if(!ingresos[name])
ingresos[name] = 0

ingresos[name] += registros[i].value

} else {

if(!gastos[name])
gastos[name] = 0

gastos[name] += registros[i].value

}
}

var idx = 1
for(var i in ingresos){
addRow(elements['row'], elements['table'], idx++, {
key: i,
val: ingresos[i]
})
}

idx = 1
for(var i in gastos) {
addRow(elements['row'], elements['table_expense'], idx++, {
key: i,
val: gastos[i]
})
}

})
})

function addRow(base, table, idx, register) {

var new_row = base.clone()
var children = new_row.children()

new_row.attr('hidden', false)

children[0].textContent = idx
children[1].textContent = register.key
children[2].textContent = register.val

table.append(new_row)

}
55 changes: 55 additions & 0 deletions sales/templates/sales/lista.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Balance</title>
<link rel="stylesheet" type="text/css" href="/static/css/styles.css">
<link rel="stylesheet" type="text/css" href="/static/css/icons.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-grid.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-reboot.min.css">
</head>
<body>
<div class="container">
<table class="table table-hover table-bordered">
<thead class="thead-inverse">
<tr>
<th class="text-center"></th>
<th class="text-center">Nombre</th>
<th class="text-center">Saldo</th>
</tr>
</thead>
<tbody id="table">
<tr id="row_base" hidden="">
<th class="text-right"scope="row"></th>
<td class=""></td>
<td class="text-right"></td>
</tr>
</tbody>
</table>
<h3>Gastos</h3>
<table class="table table-hover table-bordered">
<thead class="thead-inverse">
<tr>
<th class="text-center"></th>
<th class="text-center">Nombre</th>
<th class="text-center">Saldo</th>
</tr>
</thead>
<tbody id="table_expense">
<tr id="row_base" hidden="">
<th class="text-right"scope="row"></th>
<td class=""></td>
<td class="text-right"></td>
</tr>
</tbody>
</table>
</div>
<script src="/static/js/jquery-3.2.1.min.js"></script>
<script src="/static/js/popper.min.js"></script>
<script src="/static/js/boostrap.min.js"></script>
<script src="/static/js/index.js"></script>
<script src="/static/js/listado.js"></script>
</body>
</html>

0 comments on commit 5a9b6c5

Please sign in to comment.