Fixes
This commit is contained in:
@ -69,6 +69,9 @@ class TiposCambios {
|
|||||||
return $cambio->valor;
|
return $cambio->valor;
|
||||||
}
|
}
|
||||||
$valor = $this->getValor($fecha, $moneda->codigo);
|
$valor = $this->getValor($fecha, $moneda->codigo);
|
||||||
|
if ($valor === null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'fecha' => $fecha->format('Y-m-d H:i:s'),
|
'fecha' => $fecha->format('Y-m-d H:i:s'),
|
||||||
'desde_id' => $moneda->id,
|
'desde_id' => $moneda->id,
|
||||||
|
@ -12,11 +12,12 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
|
|
||||||
if ($request_method = 'OPTIONS') {
|
if ($request_method = 'OPTIONS') {
|
||||||
add_header 'Access-Control-Max-Age' 1728000;
|
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
|
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
|
||||||
|
add_header 'Access-Control-Max-Age' 1728000;
|
||||||
add_header 'Content-Type' 'application/json';
|
add_header 'Content-Type' 'application/json';
|
||||||
add_header 'Content-Length' 0;
|
add_header 'Content-Length' 0;
|
||||||
return 204;
|
return 204;
|
||||||
|
@ -56,6 +56,7 @@ class Cuenta extends Model {
|
|||||||
public function transacciones($limit = null, $start = 0) {
|
public function transacciones($limit = null, $start = 0) {
|
||||||
if ($this->transacciones === null) {
|
if ($this->transacciones === null) {
|
||||||
$transacciones = Model::factory(Transaccion::class)
|
$transacciones = Model::factory(Transaccion::class)
|
||||||
|
->select('transacciones.*')
|
||||||
->join('cuentas', 'cuentas.id = transacciones.debito_id OR cuentas.id = transacciones.credito_id')
|
->join('cuentas', 'cuentas.id = transacciones.debito_id OR cuentas.id = transacciones.credito_id')
|
||||||
->whereEqual('cuentas.id', $this->id)
|
->whereEqual('cuentas.id', $this->id)
|
||||||
->orderByAsc('transacciones.fecha');
|
->orderByAsc('transacciones.fecha');
|
||||||
|
@ -231,8 +231,10 @@ const transacciones = {
|
|||||||
edit: function() {
|
edit: function() {
|
||||||
const id = $("[name='id']").val()
|
const id = $("[name='id']").val()
|
||||||
const fecha = $("[name='fecha']").val()
|
const fecha = $("[name='fecha']").val()
|
||||||
const valor = $("[name='valor']").val()
|
|
||||||
const cuenta = $("[name='cuenta']").val()
|
const cuenta = $("[name='cuenta']").val()
|
||||||
|
const glosa = $("[name='glosa']").val()
|
||||||
|
const detalle = $("[name='detalle']").val()
|
||||||
|
const valor = $("[name='valor']").val()
|
||||||
const data = JSON.stringify({
|
const data = JSON.stringify({
|
||||||
debito_id: (valor < 0) ? this.cuenta_id : cuenta,
|
debito_id: (valor < 0) ? this.cuenta_id : cuenta,
|
||||||
credito_id: (valor < 0) ? cuenta : this.cuenta_id,
|
credito_id: (valor < 0) ? cuenta : this.cuenta_id,
|
||||||
|
@ -245,6 +245,29 @@ const cuentas = {
|
|||||||
table.append(parent)
|
table.append(parent)
|
||||||
segment.append(table)
|
segment.append(table)
|
||||||
return parent
|
return parent
|
||||||
|
},
|
||||||
|
resultado: (segment) => {
|
||||||
|
segment.append(
|
||||||
|
$('<table></table>').attr('class', 'ui collapsing table').append(
|
||||||
|
$('<tr></tr>').append(
|
||||||
|
$('<td></td>').html('Ganancias')
|
||||||
|
).append(
|
||||||
|
$('<td></td>').attr('data-tipo', 'ganancias')
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<tr></tr>').append(
|
||||||
|
$('<td></td>').html('Perdidas')
|
||||||
|
).append(
|
||||||
|
$('<td></td>').attr('data-tipo', 'perdidas')
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<tr></tr>').append(
|
||||||
|
$('<td></td>').html('Resultado')
|
||||||
|
).append(
|
||||||
|
$('<td></td>').attr('data-tipo', 'resultado')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -285,6 +308,8 @@ const cuentas = {
|
|||||||
this.balance = data
|
this.balance = data
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.draw().balance()
|
this.draw().balance()
|
||||||
|
}).then(() => {
|
||||||
|
this.draw().resultado()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,6 +345,17 @@ const cuentas = {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
foot.append(tr)
|
foot.append(tr)
|
||||||
|
},
|
||||||
|
resultado: () => {
|
||||||
|
const div = $('#resultado')
|
||||||
|
if (div.find("[data-tipo='resultado']").length === 0) {
|
||||||
|
div.html('')
|
||||||
|
this.build().resultado(div)
|
||||||
|
}
|
||||||
|
const format = Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
|
||||||
|
div.find("[data-tipo='ganancias']").html(format.format(this.balance['ganancias']))
|
||||||
|
div.find("[data-tipo='perdidas']").html(format.format(this.balance['perdidas']))
|
||||||
|
div.find("[data-tipo='resultado']").html(format.format(this.balance['ganancias'] - this.balance['perdidas']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
Contabilidad
|
Contabilidad
|
||||||
</h1>
|
</h1>
|
||||||
<div id="cuentas" class="ui basic fitted segment"></div>
|
<div id="cuentas" class="ui basic fitted segment"></div>
|
||||||
|
<div id="resultado" class="ui basic fitted segment"></div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
|
Reference in New Issue
Block a user