Ventas
This commit is contained in:
14
app/resources/views/construccion.blade.php
Normal file
14
app/resources/views/construccion.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Construcción
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<div class="ui warning message">
|
||||
<i class="hammer icon"></i>
|
||||
Esta parte del sitio está en construcción.
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -4,9 +4,9 @@
|
||||
@include('layout.body.header.menu.ventas')
|
||||
@include('layout.body.header.menu.proyectos')
|
||||
@include('layout.body.header.menu.inmobiliarias')
|
||||
@include('layout.body.header.menu.contabilidad')
|
||||
@include('layout.body.header.menu.operadores')
|
||||
@include('layout.body.header.menu.herramientas')
|
||||
{{--@include('layout.body.header.menu.contabilidad')--}}
|
||||
{{--@include('layout.body.header.menu.operadores')--}}
|
||||
{{--@include('layout.body.header.menu.herramientas')--}}
|
||||
<div class="right aligned menu">
|
||||
@include('layout.body.header.menu.user')
|
||||
@include('layout.body.header.menu.search')
|
||||
|
@ -2,7 +2,7 @@
|
||||
Proyectos
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}">Listado</a>
|
||||
<a class="item" href="{{$urls->base}}/unidades">Unidades</a>
|
||||
<a class="item" href="{{$urls->base}}/proyectos">Listado</a>
|
||||
<a class="item" href="{{$urls->base}}/proyectos/unidades">Unidades</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -17,11 +17,11 @@
|
||||
<a class="item" href="{{$urls->base}}/ventas/cuotas/abonar">Abonar</a>
|
||||
</div>
|
||||
</div>
|
||||
<a class="item" href="{{$urls->base}}/ventas/pagos/pendientes">Pagos Pendientes</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/consolidado">Consolidado Ventas</a>
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/pagos/pendientes">Pagos Pendientes</a>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/consolidado">Consolidado Ventas</a>--}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
{{--<div class="item">
|
||||
Informes
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
@ -30,9 +30,9 @@
|
||||
<a class="item" href="{{$urls->base}}/informes/entregas/gantt">Gantt de Entregas</a>
|
||||
<a class="item" href="{{$urls->base}}/informes/resciliaciones">Resciliaciones</a>
|
||||
</div>
|
||||
</div>
|
||||
<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>
|
||||
<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>
|
||||
</div>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
|
||||
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
|
||||
<a class="item" href="{{$urls->base}}/ventas/add">
|
||||
Nueva Venta
|
||||
<i class="plus icon"></i>
|
||||
|
@ -0,0 +1,3 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
@endpush
|
799
app/resources/views/ventas/add.blade.php
Normal file
799
app/resources/views/ventas/add.blade.php
Normal file
@ -0,0 +1,799 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Nueva Venta</h2>
|
||||
<form class="ui form" action="{{$urls->base}}/ventas/add" method="post">
|
||||
<label for="fecha_venta">Fecha de Venta</label>
|
||||
<div class="inline field">
|
||||
<div class="ui calendar" id="fecha_venta_calendar">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_venta" id="fecha_venta" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="ui dividing header">PROPIETARIO</h4>
|
||||
<div class="inline fields">
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" id="persona_propietario" name="natural_uno" checked="checked" />
|
||||
<label>Personal Natural</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" id="cantidad_propietario" name="natural_multiple" />
|
||||
<label>Multiples Propietarios</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span id="propietario"></span>
|
||||
<h4 class="ui dividing header">PROPIEDAD</h4>
|
||||
<label for="proyecto">Proyecto</label>
|
||||
<div class="four wide field">
|
||||
<div class="ui fluid search selection dropdown" id="proyecto">
|
||||
<input type="hidden" name="proyecto" />
|
||||
<div class="default text">Proyecto</div>
|
||||
<div class="menu">
|
||||
@foreach($proyectos as $proyecto)
|
||||
<div class="item" data-value="{{$proyecto->id}}">{{$proyecto->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button" type="button" id="agregar_departamento">
|
||||
<i class="plus icon"></i>
|
||||
<i class="building icon"></i>
|
||||
{{--Departamento--}}
|
||||
</button>
|
||||
<button class="ui button" type="button" id="agregar_estacionamiento">
|
||||
<i class="plus icon"></i>
|
||||
<i class="car icon"></i>
|
||||
{{--Estacionamiento--}}
|
||||
</button>
|
||||
<button class="ui button" type="button" id="agregar_bodega">
|
||||
<i class="plus icon"></i>
|
||||
<i class="warehouse icon"></i>
|
||||
{{--Bodega--}}
|
||||
</button>
|
||||
<table id="unidades" class="ui very basic compact collapsing table"></table>
|
||||
<h4 class="ui dividing header">FORMA DE PAGO</h4>
|
||||
<label for="valor">Valor</label>
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="valor" id="valor" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<label for="has_pie">Pie</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_pie" id="has_pie" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="pie">
|
||||
<div class="inline fields">
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="pie" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="four wide inline field">
|
||||
<label for="cuotas">Cuotas</label>
|
||||
<input type="text" name="cuotas" id="cuotas" />
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<label for="has_subsidio">Subsidio</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_subsidio" id="has_subsidio" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="subsidio">
|
||||
<div class="inline fields">
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="subsidio" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label for="ahorro">Ahorro</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="ahorro" id="ahorro" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<label for="has_credito">Crédito</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_credito" id="has_credito" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="credito">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="credito" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<h4 class="ui dividing header">OTRAS CONDICIONES</h4>
|
||||
<label for="has_bono_pie">Bono Pie</label>
|
||||
<div class="inline fields">
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="has_bono_pie" id="has_bono_pie" />
|
||||
<label></label>
|
||||
</div>
|
||||
<span id="bono_pie">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="bono_pie" />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button class="ui button" type="submit">Agregar</button>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
const regiones = [
|
||||
@foreach ($regiones as $region)
|
||||
'<div class="item" data-value="{{$region->id}}">{{$region->descripcion}}</div>',
|
||||
@endforeach
|
||||
]
|
||||
|
||||
class Rut {
|
||||
ids
|
||||
patterns
|
||||
valid
|
||||
|
||||
constructor({id, alert_id, valid}) {
|
||||
this.ids = {
|
||||
input: id,
|
||||
alert: alert_id
|
||||
}
|
||||
this.patterns = {
|
||||
like: /^(\d{0,2})\.?(\d{3})\.?(\d{3})-?(\d|k)$/gi,
|
||||
suspicious: /^(\d)\1?\.?(\1{3})\.?(\1{3})-?(\d|k)?$/gi
|
||||
}
|
||||
this.valid = valid
|
||||
|
||||
$(this.ids.alert).hide()
|
||||
$(this.ids.input).change(event => {
|
||||
this.verify(event)
|
||||
})
|
||||
}
|
||||
is() {
|
||||
return {
|
||||
like: rut => this.patterns.like.test(rut),
|
||||
suspicious: rut => this.patterns.suspicious.test(rut)
|
||||
}
|
||||
}
|
||||
clean() {
|
||||
return {
|
||||
rut: rut => rut.includes('-') ? rut.split('-').join('') : rut
|
||||
}
|
||||
}
|
||||
get() {
|
||||
return {
|
||||
digits: rut => this.clean().rut(rut).slice(0, -1),
|
||||
verifier: rut => this.clean().rut(rut).slice(-1)
|
||||
}
|
||||
}
|
||||
calculate() {
|
||||
return {
|
||||
verifier: digits => {
|
||||
let sum = 0
|
||||
let mul = 2
|
||||
|
||||
let i = digits.length
|
||||
while (i--) {
|
||||
sum = sum + parseInt(digits.charAt(i)) * mul
|
||||
if (mul % 7 === 0) {
|
||||
mul = 2
|
||||
} else {
|
||||
mul++
|
||||
}
|
||||
}
|
||||
|
||||
const res = sum % 11
|
||||
|
||||
if (res === 0) {
|
||||
return '0'
|
||||
} else if (res === 1) {
|
||||
return 'k'
|
||||
}
|
||||
|
||||
return `${11 - res}`
|
||||
}
|
||||
}
|
||||
}
|
||||
validate(rut, not_suspicious = true) {
|
||||
if (!this.is().like(rut) || (not_suspicious && this.is().suspicious(rut))) {
|
||||
return false
|
||||
}
|
||||
return this.get().verifier(rut).toLowerCase() === this.calculate().verifier(this.get().digits(rut))
|
||||
}
|
||||
verify(event) {
|
||||
const input = $(event.currentTarget)
|
||||
const val = input.val()
|
||||
let new_val = this.clean().rut(val)
|
||||
if (new_val.length < 3) {
|
||||
return
|
||||
}
|
||||
new_val = [this.get().digits(new_val), this.get().verifier(new_val)].join('-')
|
||||
input.val(new_val)
|
||||
if (!this.validate(new_val)) {
|
||||
this.alert().invalid()
|
||||
return
|
||||
}
|
||||
this.alert().valid()
|
||||
this.valid(new_val)
|
||||
}
|
||||
alert() {
|
||||
return {
|
||||
valid: () => {
|
||||
$(this.ids.alert).hide()
|
||||
},
|
||||
invalid: () => {
|
||||
$(this.ids.alert).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Comuna {
|
||||
id
|
||||
data
|
||||
|
||||
constructor(id) {
|
||||
this.id = id
|
||||
this.data = {
|
||||
region: 0,
|
||||
provincias: []
|
||||
}
|
||||
|
||||
$(this.id).dropdown()
|
||||
}
|
||||
|
||||
get() {
|
||||
return {
|
||||
provincias: () => {
|
||||
const uri = '{{$urls->api}}/region/' + this.data.region + '/provincias'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data.provincias = data.provincias
|
||||
const promises = []
|
||||
this.data.provincias.forEach(provincia => {
|
||||
promises.push(this.get().comunas(provincia.id))
|
||||
})
|
||||
Promise.all(promises).then(() => {
|
||||
this.draw().comunas()
|
||||
})
|
||||
})
|
||||
},
|
||||
comunas: provincia_id => {
|
||||
const uri = '{{$urls->api}}/provincia/' + provincia_id + '/comunas'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
const i = this.data.provincias.findIndex(provincia => provincia.id === data.provincia_id)
|
||||
this.data.provincias[i].comunas = data.comunas
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
draw() {
|
||||
return {
|
||||
comunas: () => {
|
||||
const dropdown = $(this.id)
|
||||
const menu = dropdown.find('.menu')
|
||||
menu.html('')
|
||||
this.data.provincias.forEach(provincia => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('header').html(provincia.descripcion)
|
||||
)
|
||||
menu.append(
|
||||
$('<div></div>').addClass('divider')
|
||||
)
|
||||
provincia.comunas.forEach(comuna => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', comuna.id).html(comuna.descripcion)
|
||||
)
|
||||
})
|
||||
})
|
||||
dropdown.dropdown('refresh')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Region {
|
||||
id
|
||||
comuna
|
||||
|
||||
constructor({id, comuna}) {
|
||||
this.id = id
|
||||
this.comuna = comuna
|
||||
|
||||
const dd = $(this.id)
|
||||
dd.dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: value => {
|
||||
this.comuna.data.region = value
|
||||
this.comuna.get().provincias()
|
||||
}
|
||||
})
|
||||
dd.dropdown('set selected', 13)
|
||||
}
|
||||
}
|
||||
class PersonaNatural {
|
||||
valid
|
||||
constructor({valid}) {
|
||||
this.valid = valid
|
||||
}
|
||||
draw() {
|
||||
const lines = [
|
||||
'<label for="rut">RUT</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut" name="rut" />',
|
||||
'<span class="ui error message" id="alert_rut">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
'</span>',
|
||||
'</div>',
|
||||
'<label for="nombres">Nombre</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres" id="nombres" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle">Dirección</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle" id="calle" size="16" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero" size="5" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="two wide field"></div>',
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna">',
|
||||
'<input type="hidden" name="comuna" />',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region">',
|
||||
'<input type="hidden" name="region" />',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
]
|
||||
return lines.join("\n")
|
||||
}
|
||||
activate() {
|
||||
new Rut({id: '#rut', alert_id: '#alert_rut', valid: this.valid})
|
||||
const comuna = new Comuna('#comuna')
|
||||
new Region({id: '#region', comuna})
|
||||
}
|
||||
}
|
||||
class PersonaTributaria {
|
||||
persona
|
||||
constructor({valid}) {
|
||||
this.persona = new PersonaNatural({valid})
|
||||
}
|
||||
draw() {
|
||||
const lines = [
|
||||
'<label for="rut">RUT Sociedad</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut_sociedad" name="rut_sociedad" />',
|
||||
'<span class="ui error message" id="alert_rut_sociedad">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
'</span>',
|
||||
'</div>',
|
||||
'<label for="razon_social">Razón Social</label>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="razon_social" id="razon_social" />',
|
||||
'</div>',
|
||||
'<label for="calle_comercial">Dirección Comercial</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle_comercial" id="calle_comercial" size="16" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero_comercial" size="5" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra_comercial" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="two wide field"></div>',
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna_sociedad">',
|
||||
'<input type="hidden" name="comuna_sociedad" />',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region_sociedad">',
|
||||
'<input type="hidden" name="region_sociedad" />',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div>Representante Legal</div>',
|
||||
]
|
||||
return [lines.join("\n"), this.persona.draw()].join("\n")
|
||||
}
|
||||
activate() {
|
||||
new Rut({id: '#rut_sociedad', alert_id: '#alert_rut_sociedad'})
|
||||
const comuna = new Comuna('#comuna_sociedad')
|
||||
new Region({id: '#region_sociedad', comuna})
|
||||
this.persona.activate()
|
||||
}
|
||||
}
|
||||
class MultiplesPersonas {
|
||||
persona
|
||||
constructor({valid}) {
|
||||
this.persona = new PersonaNatural({valid})
|
||||
}
|
||||
|
||||
draw() {
|
||||
let lines = [
|
||||
this.persona.draw(),
|
||||
'<label for="rut">RUT Otro</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut_otro" name="rut_otro" />',
|
||||
'<span class="ui error message" id="alert_rut_otro">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
'</span>',
|
||||
'</div>',
|
||||
'<label for="nombres_otro">Nombre Otro</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres_otro" id="nombres_otro" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno_otro" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno_otro" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle_otro">Dirección Otro</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle_otro" id="calle_otro" size="16" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero_otro" size="5" />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra_otro" />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="two wide field"></div>',
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna_otro">',
|
||||
'<input type="hidden" name="comuna_otro" />',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region_otro">',
|
||||
'<input type="hidden" name="region_otro" />',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
]
|
||||
return lines.join("\n")
|
||||
}
|
||||
activate() {
|
||||
this.persona.activate()
|
||||
new Rut({id: '#rut_otro', alert_id: '#alert_rut_otro'})
|
||||
const comuna = new Comuna('#comuna_otro')
|
||||
new Region({id: '#region_otro', comuna})
|
||||
}
|
||||
}
|
||||
class Propietario {
|
||||
ids
|
||||
|
||||
constructor({id, id_tipo, id_cantidad}) {
|
||||
this.ids = {
|
||||
span: id,
|
||||
tipo: id_tipo,
|
||||
cantidad: id_cantidad
|
||||
}
|
||||
|
||||
document.getElementById(this.ids.tipo).onchange = event => {
|
||||
const cantidad = document.getElementById(this.ids.cantidad)
|
||||
cantidad.disabled = !event.currentTarget.checked;
|
||||
this.draw()
|
||||
}
|
||||
document.getElementById(this.ids.cantidad).onchange = event => {
|
||||
this.draw()
|
||||
}
|
||||
document.getElementById(this.ids.cantidad).disabled = !document.getElementById(this.ids.tipo).checked
|
||||
|
||||
this.draw()
|
||||
|
||||
$(this.ids.span).find('#rut')
|
||||
}
|
||||
get tipo() {
|
||||
return document.getElementById(this.ids.tipo).checked ? (document.getElementById(this.ids.cantidad).checked ? 2 : 0) : 1
|
||||
}
|
||||
get() {
|
||||
return {
|
||||
propietario: tipo => {
|
||||
const map = {
|
||||
0: new PersonaNatural({valid: rut => this.fetch().propietario(rut)}),
|
||||
1: new PersonaTributaria({valid: () => {}}),
|
||||
2: new MultiplesPersonas({valid: () => {}})
|
||||
}
|
||||
return map[tipo]
|
||||
}
|
||||
}
|
||||
}
|
||||
fetch() {
|
||||
return {
|
||||
propietario: rut => {
|
||||
const uri = '{{$urls->api}}/ventas/propietario/' + rut.split('-')[0]
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.propietario !== null) {
|
||||
const parent = $(this.ids.span)
|
||||
parent.find("[name='nombres']").val(data.propietario.nombres)
|
||||
parent.find("[name='apellido_paterno']").val(data.propietario.apellidos.paterno)
|
||||
parent.find("[name='apellido_materno']").val(data.propietario.apellidos.materno)
|
||||
parent.find("[name='calle']").val(data.propietario.direccion.calle)
|
||||
parent.find("[name='numero']").val(data.propietario.direccion.numero)
|
||||
parent.find("[name='extra']").val(data.propietario.direccion.extra)
|
||||
parent.find('#region').dropdown('set selected', data.propietario.direccion.comuna.provincia.region.id)
|
||||
parent.find('#comuna').dropdown('set selected', data.propietario.direccion.comuna.id)
|
||||
|
||||
if (data.propietario.representante !== '') {
|
||||
document.getElementById(this.ids.tipo).trigger('check')
|
||||
} else {
|
||||
if (data.propietario.otro) {
|
||||
document.getElementById(this.ids.cantidad).trigger('check')
|
||||
}
|
||||
}
|
||||
}
|
||||
console.debug(data)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
draw() {
|
||||
const propietario = this.get().propietario(this.tipo)
|
||||
$(this.ids.span).html(propietario.draw())
|
||||
propietario.activate()
|
||||
}
|
||||
}
|
||||
|
||||
class Proyecto {
|
||||
ids
|
||||
data
|
||||
unidades
|
||||
added
|
||||
|
||||
constructor({unidades_id, proyecto_id}) {
|
||||
this.ids = {
|
||||
proyecto: proyecto_id,
|
||||
unidades: unidades_id,
|
||||
buttons: []
|
||||
}
|
||||
this.data = {id: 0}
|
||||
this.unidades = []
|
||||
this.added = []
|
||||
|
||||
$(this.ids.proyecto).dropdown({
|
||||
fireOnInit: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.id = value
|
||||
this.ids.buttons.forEach(button => {
|
||||
$(button).prop('disabled', true)
|
||||
})
|
||||
this.reset()
|
||||
this.fetch().unidades().then(() => {
|
||||
this.ids.buttons.forEach(button => {
|
||||
$(button).prop('disabled', false)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
const buttons = [
|
||||
'departamento',
|
||||
'estacionamiento',
|
||||
'bodega'
|
||||
]
|
||||
buttons.forEach(name => {
|
||||
const id = '#agregar_' + name
|
||||
this.ids.buttons.push(id)
|
||||
$(id).click(event => {
|
||||
this.add(name)
|
||||
})
|
||||
})
|
||||
}
|
||||
fetch() {
|
||||
return {
|
||||
unidades: () => {
|
||||
const uri = '{{$urls->api}}/proyecto/' + this.data.id + '/unidades'
|
||||
return fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.total === 0) {
|
||||
return
|
||||
}
|
||||
this.unidades = data.unidades
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
add(tipo) {
|
||||
const number = Math.floor(Math.random() * 1000)
|
||||
const unidad = new Unidad({number})
|
||||
this.added.push(unidad)
|
||||
$(this.ids.unidades).append(
|
||||
$('<tr></tr>').attr('data-number', number).append(
|
||||
$('<td></td>').append(
|
||||
unidad.draw(this.unidades[tipo])
|
||||
)
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<button></button>').addClass('ui icon button').attr('type', 'button').attr('data-number', number).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const number = $(event.currentTarget).attr('data-number')
|
||||
this.remove(number)
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
remove(number) {
|
||||
number = parseInt(number)
|
||||
const index = this.added.findIndex(unidad => unidad.number === number)
|
||||
if (index === -1) {
|
||||
return
|
||||
}
|
||||
$(this.ids.unidades).find("tr[data-number='" + number + "']").remove()
|
||||
this.added.splice(index, 1)
|
||||
}
|
||||
reset() {
|
||||
this.added = []
|
||||
$(this.ids.unidades).html('')
|
||||
}
|
||||
}
|
||||
class Unidad{
|
||||
number
|
||||
constructor({number}) {
|
||||
this.number = number
|
||||
}
|
||||
|
||||
draw(unidades) {
|
||||
const dropdown = $('<div></div>').addClass('ui search selection dropdown')
|
||||
const tipo = unidades[0].proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||
dropdown.append(
|
||||
$('<input />').attr('type', 'hidden').attr('name', 'unidad' + this.number)
|
||||
).append(
|
||||
$('<div></div>').addClass('default text').html(tipo.charAt(0).toUpperCase() + tipo.slice(1))
|
||||
).append(
|
||||
$('<i></i>').addClass('dropdown icon')
|
||||
)
|
||||
const menu = $('<div></div>').addClass('menu')
|
||||
unidades.forEach(unidad => {
|
||||
menu.append(
|
||||
$('<div></div>').addClass('item').attr('data-value', unidad.id).html(unidad.descripcion)
|
||||
)
|
||||
})
|
||||
dropdown.append(menu)
|
||||
dropdown.dropdown()
|
||||
return $('<div></div>').addClass('inline fields').attr('data-number', this.number).append(dropdown)
|
||||
}
|
||||
}
|
||||
|
||||
const unidades = {
|
||||
data: []
|
||||
}
|
||||
|
||||
class Payment {
|
||||
ids
|
||||
|
||||
constructor({id, checkbox_id}) {
|
||||
this.ids = {
|
||||
base: id,
|
||||
checkbox: checkbox_id
|
||||
}
|
||||
|
||||
$(this.ids.base).hide()
|
||||
document.getElementById(this.ids.checkbox).onchange = event => {
|
||||
this.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
get status() {
|
||||
return document.getElementById(this.ids.checkbox).checked
|
||||
}
|
||||
toggle() {
|
||||
if (this.status) {
|
||||
$(this.ids.base).show()
|
||||
return
|
||||
}
|
||||
$(this.ids.base).hide()
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
$('#fecha_venta_calendar').calendar({
|
||||
type: 'date',
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
}
|
||||
})
|
||||
new Propietario({id: '#propietario', id_tipo: 'persona_propietario', id_cantidad: 'cantidad_propietario'})
|
||||
new Proyecto({unidades_id: '#unidades', proyecto_id: '#proyecto'})
|
||||
|
||||
const payments = [
|
||||
'pie',
|
||||
'subsidio',
|
||||
'credito',
|
||||
'bono_pie'
|
||||
]
|
||||
payments.forEach(payment => {
|
||||
new Payment({
|
||||
id: '#' + payment,
|
||||
checkbox_id: 'has_' + payment
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
144
app/resources/views/ventas/cuotas/abonar.blade.php
Normal file
144
app/resources/views/ventas/cuotas/abonar.blade.php
Normal file
@ -0,0 +1,144 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h3 class="ui header">Abonar Cuotas</h3>
|
||||
<div class="ui grid">
|
||||
<div class="two wide column">Total</div>
|
||||
<div class="column">{{count($cuotas_depositadas)}}</div>
|
||||
<div class="two wide column">{{$format->pesos(array_reduce($cuotas_depositadas, function($sum, $cuota) {return $sum + $cuota['Valor'];}, 0))}}</div>
|
||||
</div>
|
||||
<table class="ui striped table" id="cuotas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="two wide column">Proyecto</th>
|
||||
<th class="column">Departamento</th>
|
||||
<th>Departamento Sort</th>
|
||||
<th class="two wide column">Propietario</th>
|
||||
<th class="column">Valor Cuota</th>
|
||||
<th class="column">Fecha Cuota</th>
|
||||
<th>Fecha ISO</th>
|
||||
<th class="column">Fecha Depositada</th>
|
||||
<th class="two wide column">Fecha Abono / Devolución</th>
|
||||
<th class="column">Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($cuotas_depositadas as $cuota)
|
||||
<tr>
|
||||
<td>{{$cuota['Proyecto']}}</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/venta/{{$cuota['venta_id']}}">{{$cuota['Departamento']}}</a>
|
||||
</td>
|
||||
<td>{{str_pad($cuota['Departamento'], 4, 0, STR_PAD_LEFT)}}</td>
|
||||
<td>{{$cuota['Propietario']}}</td>
|
||||
<td>{{$format->pesos($cuota['Valor'])}}</td>
|
||||
<td>{{$cuota['Fecha Cheque']}}</td>
|
||||
<td>{{$cuota['Fecha ISO']}}</td>
|
||||
<td>{{$cuota['Fecha Depositada']}}</td>
|
||||
<td>
|
||||
<div class="ui calendar" data-cuota="{{$cuota['id']}}">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_abono{{$cuota['id']}}" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="ui vertical buttons">
|
||||
<button class="ui green icon button abonar" title="Abonar">
|
||||
<i class="check icon"></i>
|
||||
</button>
|
||||
<button class="ui red icon button devolver" title="Devolver">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(() => {
|
||||
const cuotas_tables = new DataTable('#cuotas', {
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas depositadas por abonar',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: '
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
target: 6,
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
target: 2,
|
||||
visible: false,
|
||||
searchable: false
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[6, 'desc'],
|
||||
[0, 'asc'],
|
||||
[2, 'asc']
|
||||
]
|
||||
})
|
||||
$('.ui.calendar').calendar({
|
||||
type: 'date',
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
}
|
||||
})
|
||||
$('.abonar.button').click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const cuota_id = button.data('cuota')
|
||||
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
|
||||
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
|
||||
fetch('{{$urls->api}}/ventas/cuota/abonar', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.depositada) {
|
||||
const button = $(".depositar.button[data-cuota='" + data.cuota_id + "']")
|
||||
const cell = button.parent()
|
||||
const row = cell.parent()
|
||||
cuotas_tables.row(row).remove().draw()
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.devolver.button').click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const cuota_id = button.data('cuota')
|
||||
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
|
||||
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
|
||||
fetch('{{$urls->api}}/ventas/cuota/devolver', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.depositada) {
|
||||
const button = $(".depositar.button[data-cuota='" + data.cuota_id + "']")
|
||||
const cell = button.parent()
|
||||
const row = cell.parent()
|
||||
cuotas_tables.row(row).remove().draw()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -6,7 +6,7 @@
|
||||
<div class="ui grid">
|
||||
<div class="two wide column">Total</div>
|
||||
<div class="column">{{count($cuotas_pendientes)}}</div>
|
||||
<div class="column">{{$format->pesos(array_reduce($cuotas_pendientes, function($sum, $cuota) {return $sum + $cuota['Valor'];}, 0))}}</div>
|
||||
<div class="two wide column">{{$format->pesos(array_reduce($cuotas_pendientes, function($sum, $cuota) {return $sum + $cuota['Valor'];}, 0))}}</div>
|
||||
</div>
|
||||
<table class="ui striped table" id="cuotas">
|
||||
<thead>
|
||||
@ -14,13 +14,14 @@
|
||||
<th class="two wide column">Proyecto</th>
|
||||
<th class="column">Departamento</th>
|
||||
<th>Departamento Sort</th>
|
||||
<th class="two wide column">Propietario</th>
|
||||
<th class="column">Cuota</th>
|
||||
<th class="column">Banco</th>
|
||||
<th class="column">Valor</th>
|
||||
<th class="column">Día</th>
|
||||
<th class="column">Cuota</th>
|
||||
<th class="two wide column">Propietario</th>
|
||||
<th class="column">Banco</th>
|
||||
<th class="two wide column">Fecha Cheque (Días)</th>
|
||||
<th>Fecha ISO</th>
|
||||
<th class="two wide column">Fecha Deposito</th>
|
||||
<th class="column">Depositar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -34,16 +35,24 @@
|
||||
</a>
|
||||
</td>
|
||||
<td>{{str_pad($cuota['Departamento'], 4, '0', STR_PAD_LEFT)}}</td>
|
||||
<td>{{$cuota['Propietario']}}</td>
|
||||
<td>{{$cuota['Numero']}}</td>
|
||||
<td>{{$cuota['Banco']}}</td>
|
||||
<td>{{$format->pesos($cuota['Valor'])}}</td>
|
||||
<td>{{$cuota['Dia']}}</td>
|
||||
<td>{{$cuota['Numero']}}</td>
|
||||
<td>{{$cuota['Propietario']}}</td>
|
||||
<td>{{$cuota['Banco']}}</td>
|
||||
<td>{{$cuota['Fecha Cheque']}} ({{$cuota['Vencida']}})</td>
|
||||
<td>{{$cuota['Fecha ISO']}}</td>
|
||||
<td>
|
||||
<div class="ui calendar" data-cuota="{{$cuota['id']}}">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_deposito{{$cuota['id']}}" />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="ui icon button depositar" data-cuota="{{$cuota['id']}}">
|
||||
<i class="currency icon"></i>
|
||||
<i class="dollar icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@ -85,11 +94,19 @@
|
||||
[2, 'asc']
|
||||
]
|
||||
})
|
||||
$('.ui.calendar').calendar({
|
||||
type: 'date',
|
||||
formatter: {
|
||||
date: 'DD-MM-YYYY'
|
||||
}
|
||||
})
|
||||
$('.depositar.button').click(event => {
|
||||
const button = $(event.currentTarget)
|
||||
const cuota_id = button.data('cuota')
|
||||
fetch('{{$urls->base}}/ventas/cuota/depositar', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id})
|
||||
const calendar = $(".ui.calendar[data-cuota='" + cuota_id + "']").calendar('get date')
|
||||
const fecha = [calendar.getFullYear(), calendar.getMonth()+1, calendar.getDate()].join('-')
|
||||
fetch('{{$urls->api}}/ventas/cuota/depositar', {
|
||||
method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({cuota_id, fecha})
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
|
@ -117,7 +117,11 @@
|
||||
this.data.venta_ids = data.ventas
|
||||
const promises = []
|
||||
data.ventas.forEach(venta_id => {
|
||||
promises.push(this.get().venta(venta_id))
|
||||
const promise = this.get().venta(venta_id)
|
||||
/*promise.then(() => {
|
||||
this.draw().ventas(true)
|
||||
})*/
|
||||
promises.push(promise)
|
||||
})
|
||||
Promise.all(promises).then(() => {
|
||||
this.draw().ventas()
|
||||
@ -181,7 +185,7 @@
|
||||
parent.show()
|
||||
parent.find('.item.proyecto').click(this.actions().get)
|
||||
},
|
||||
ventas: () => {
|
||||
ventas: (loading = false) => {
|
||||
const title = $(this.ids.title)
|
||||
const parent = $(this.ids.proyectos)
|
||||
const table = $(this.ids.table)
|
||||
@ -195,6 +199,11 @@
|
||||
}
|
||||
|
||||
title.html('Ventas de ' + this.data.proyecto + ' [' + this.data.ventas.length + ']')
|
||||
if (loading) {
|
||||
title.append(
|
||||
$('<span></span>').addClass('ui active inline loader')
|
||||
)
|
||||
}
|
||||
|
||||
const tbody = $('<tbody></tbody>')
|
||||
this.data.ventas.forEach(venta => {
|
||||
|
257
app/resources/views/ventas/pagos/pendientes.blade.php
Normal file
257
app/resources/views/ventas/pagos/pendientes.blade.php
Normal file
@ -0,0 +1,257 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_title')
|
||||
Pagos Pendientes
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Pagos Pendientes</h2>
|
||||
<div class="ui basic segment" id="pendientes"></div>
|
||||
<h2 class="ui header">Para Abonar<span id="total_abonar"></span></h2>
|
||||
<div class="ui basic segment" id="abonar"></div>
|
||||
<h2 class="ui header">Pagos Devueltos<span id="total_devueltos"></span></h2>
|
||||
<div class="ui basic segment" id="devueltos"></div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.chartjs')
|
||||
@include('layout.head.styles.datatables')
|
||||
@include('layout.body.scripts.datatables')
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
const historicos = {
|
||||
id: '',
|
||||
data: {
|
||||
total: {
|
||||
pendientes: 0,
|
||||
depositados: 0
|
||||
},
|
||||
graph: {}
|
||||
},
|
||||
get: function() {
|
||||
return {
|
||||
pagos: () => {
|
||||
const uri = '{{$urls->api}}/ventas/pagos/pendientes'
|
||||
fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data.total.pendientes = data.pagos.historicos
|
||||
this.data.total.depositados = data.abonos.historicos
|
||||
this.data.graph = data
|
||||
|
||||
this.draw().all()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
all: () => {
|
||||
const parent = $(this.id)
|
||||
parent.append(this.draw().table())
|
||||
this.draw().graph(parent)
|
||||
},
|
||||
table: () => {
|
||||
return $('<table></table>').append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').attr('rowspan', 2).html('Históricos')
|
||||
).append(
|
||||
$('<td></td>').html('Pendientes')
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/ventas/cuotas/pendientes').html(this.data.total.pendientes)
|
||||
)
|
||||
)
|
||||
).append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html('Depositadas')
|
||||
).append(
|
||||
$('<td></td>').append(
|
||||
$('<a></a>').attr('href', '{{$urls->base}}/ventas/cuotas/abonar').html(this.data.total.depositados)
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
graph: parent => {
|
||||
const canvas = $('<canvas></canvas>').attr('id', 'pagos_historicos')
|
||||
parent.append(canvas)
|
||||
const chart = new Chart(canvas, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: this.data.graph.fechas,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Pagos',
|
||||
data: this.data.graph.pagos.data,
|
||||
backgroundColor: this.data.graph.pagos.backgroundColor
|
||||
},
|
||||
{
|
||||
label: 'Abonos',
|
||||
data: this.data.graph.abonos.data,
|
||||
backgroundColor: this.data.graph.abonos.backgroundColor
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
x: [
|
||||
{
|
||||
stacked: true
|
||||
}
|
||||
],
|
||||
y: [
|
||||
{
|
||||
stacked: true
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: {
|
||||
chartJSPluginBarchartBackground: {
|
||||
color: 'rgb(100, 100, 100)'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id) {
|
||||
this.id = id
|
||||
this.get().pagos()
|
||||
}
|
||||
}
|
||||
const depositados = {
|
||||
ids: {
|
||||
data: '',
|
||||
total: ''
|
||||
},
|
||||
data: [],
|
||||
total: 0,
|
||||
get: function() {
|
||||
return {
|
||||
pendientes: () => {
|
||||
const uri = '{{$urls->api}}/ventas/pagos/abonar'
|
||||
fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data = data.pagos
|
||||
this.total = data.total
|
||||
this.draw().all()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
all: () => {
|
||||
this.draw().total()
|
||||
this.draw().table($(this.ids.data))
|
||||
},
|
||||
total: () => {
|
||||
$(this.ids.total).html(' [' + this.total + ']')
|
||||
},
|
||||
table: parent => {
|
||||
const header_row = $('<tr></tr>')
|
||||
['Proyecto', 'Departamento', 'Propietario', 'Tipo', 'Fecha Deposito', 'Valor'].forEach(title => {
|
||||
header_row.append(
|
||||
$('<th></th>').html(title)
|
||||
)
|
||||
})
|
||||
const tbody = $('<tbody></tbody>')
|
||||
this.data.forEach(pago => {
|
||||
tbody.append(
|
||||
$('<tr></tr>').append(
|
||||
$('<td></td>').html(pago.proyecto)
|
||||
).append(
|
||||
$('<td></td>').html(pago.departamento)
|
||||
).append(
|
||||
$('<td></td>').html(pago.propietario)
|
||||
).append(
|
||||
$('<td></td>').html(pago.tipo)
|
||||
).append(
|
||||
$('<td></td>').html(pago.fecha)
|
||||
).append(
|
||||
$('<td></td>').html(pago.valor)
|
||||
)
|
||||
)
|
||||
})
|
||||
const table = $('<table></table>').attr('id', 'pendientes_table').append(
|
||||
$('<thead></thead>').append(header_row)
|
||||
).append(tbody)
|
||||
parent.append(table)
|
||||
const dt = new DataTable('#pendientes_table', {
|
||||
language: {
|
||||
info: 'Mostrando página _PAGE_ de _PAGES_',
|
||||
infoEmpty: 'No hay cuotas depositadas por abonar',
|
||||
infoFiltered: '(filtrado de _MAX_ cuotas)',
|
||||
lengthMenu: 'Mostrando de a _MENU_ cuotas',
|
||||
zeroRecords: 'No se encotró cuotas con ese criterio',
|
||||
search: 'Buscar: '
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id, total_id) {
|
||||
this.ids.data = id
|
||||
this.ids.total = total_id
|
||||
this.get().pendientes()
|
||||
}
|
||||
}
|
||||
const devueltos = {
|
||||
ids: {
|
||||
data: '',
|
||||
total: ''
|
||||
},
|
||||
data: [],
|
||||
total: 0,
|
||||
get: function() {
|
||||
return {
|
||||
devueltos: () => {
|
||||
const uri = '{{$urls->api}}/ventas/pagos/rebotes'
|
||||
fetch(uri).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
}
|
||||
}).then(data => {
|
||||
this.data = data.pagos
|
||||
this.total = data.total
|
||||
this.draw().all()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
draw: function() {
|
||||
return {
|
||||
all: () => {
|
||||
this.draw().total()
|
||||
this.draw().table($(this.ids.data))
|
||||
},
|
||||
total: () => {
|
||||
$(this.ids.total).html(' [' + this.total + ']')
|
||||
},
|
||||
table: parent => {}
|
||||
}
|
||||
},
|
||||
setup: function(id, total_id) {
|
||||
this.ids.data = id
|
||||
this.ids.total = total_id
|
||||
this.get().devueltos()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
historicos.setup('#pendientes')
|
||||
depositados.setup('#abonar', '#total_abonar')
|
||||
devueltos.setup('#devueltos', '#total_devueltos')
|
||||
})
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user