Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #45
This commit is contained in:
2025-10-04 11:40:52 -03:00
parent 6ddc48ec60
commit 742de657c5
815 changed files with 62089 additions and 3287 deletions

View File

@ -0,0 +1,50 @@
@extends('ventas.base')
@section('venta_subtitle')
Pie
@endsection
@section('venta_content')
<div class="ui basic compact segment">
Valor Promesa: {{ $format->ufs($venta->valor) }} <br />
10% {{ $format->ufs($venta->valor * 0.1) }}
</div>
<form class="ui form" id="add_pie">
<input type="hidden" name="venta" value="{{ $venta->id }}" />
<input type="hidden" name="fecha" value="{{ $venta->fecha->format('Y-m-d') }}" />
<div class="three wide field">
<label for="valor">Valor</label>
<div class="ui right labeled input">
<input type="text" name="valor" id="valor" value="{{ round($venta->valor * 0.1, 2) }}" />
<div class="ui basic label">UF</div>
</div>
</div>
<div class="three wide field">
<label for="cuotas"># Cuotas</label>
<input type="number" name="cuotas" id="cuotas" />
</div>
<button class="ui button">Agregar</button>
</form>
@endsection
@push('page_scripts')
<script>
$(document).ready(() => {
$('#add_pie').submit(event => {
event.preventDefault()
const data = new FormData(event.currentTarget)
return fetchAPI('{{ $urls->api }}/venta/{{ $venta->id }}/pie/add', {method: 'post', body: data}).then(response => {
if (response.ok) {
return response.json()
}
}).then(json => {
if (json.success) {
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
return true
}
return false
})
})
})
</script>
@endpush

View File

@ -0,0 +1,61 @@
@extends('ventas.base')
@section('venta_subtitle')
Agregar Bono - Pie
@endsection
@section('venta_content')
<div class="ui compact segment">
<p>Valor Promesa {{$format->ufs($venta->valor)}}</p>
@if (isset($venta->formaPago()->pie))
<p>Valor Anticipo {{$format->ufs($venta->formaPago()->pie->valor)}}</p>
@endif
<p>Valor 10% {{$format->ufs($venta->valor * 0.1)}}</p>
</div>
<form class="ui form" id="add_bono">
<div class="three wide field">
<label for="fecha">Fecha</label>
<div class="ui calendar" id="fecha">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" placeholder="Fecha" />
</div>
</div>
</div>
<div class="three wide field">
<label for="valor">Valor</label>
<div class="ui right labeled input">
<input type="text" name="valor" id="valor" />
<div class="ui basic label">UF</div>
</div>
</div>
<button class="ui button">Agregar</button>
</form>
@endsection
@push('page_scripts')
<script>
$(document).ready(() => {
calendar_date_options.initialDate = new Date({{$venta->fecha->format('Y, m-1, j')}})
$('#fecha').calendar(calendar_date_options)
$('#add_bono').submit(submitEvent => {
submitEvent.preventDefault()
const url = '{{$urls->api}}/venta/{{$venta->id}}/bono_pie/add'
const data = new FormData()
data.set('fecha', $('#fecha').calendar('get date').toISOString())
data.set('valor', $('#valor').val())
return APIClient.fetch(url, {method: 'post', body: data}).then(response => {
if (response.ok) {
return response.json()
}
}).then(json => {
if (!json.success) {
return
}
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
})
})
})
</script>
@endpush

View File

@ -0,0 +1,68 @@
@extends('ventas.base')
@section('venta_subtitle')
Editar Bono - Pie
@endsection
@section('venta_content')
<div class="ui compact segment">
<p>Valor Promesa {{$format->ufs($venta->valor)}}</p>
@if (isset($venta->formaPago()->pie))
<p>Valor Anticipo {{$format->ufs($venta->formaPago()->pie->valor)}}</p>
@endif
<p>Valor 10% {{$format->ufs($venta->valor * 0.1)}}</p>
</div>
<form class="ui form" id="add_bono">
<div class="three wide field">
<label for="fecha">Fecha</label>
<div class="ui calendar" id="fecha">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" placeholder="Fecha" />
</div>
</div>
</div>
<div class="three wide field">
<label for="valor">Valor</label>
<div class="ui right labeled input">
<input type="text" name="valor" id="valor" value="{{ round($venta->formaPago()->bonoPie->pago->valor(), 2) }}" />
<div class="ui basic label">UF</div>
</div>
</div>
<button class="ui button">Editar</button>
</form>
@endsection
@include('layout.body.scripts.number_input')
@push('page_scripts')
<script>
$(document).ready(() => {
const fecha = $('#fecha')
fecha.calendar(calendar_date_options)
fecha.calendar('set date', new Date({{$venta->formaPago()->bonoPie->pago->fecha->format('Y, m-1, j')}}))
const numberInput = new NumberInput({input: document.querySelector('input[name="valor"]'), isRational: true})
numberInput.watch()
$('#add_bono').submit(submitEvent => {
submitEvent.preventDefault()
const url = '{{$urls->api}}/venta/{{$venta->id}}/bono_pie/edit'
const method = 'post'
const body = new FormData()
body.set('fecha', $('#fecha').calendar('get date').toISOString())
body.set('valor', numberInput.currentValue)
return APIClient.fetch(url, {method, body}).then(response => {
if (response.ok) {
return response.json()
}
}).then(json => {
if (!json.success) {
return
}
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
})
})
})
</script>
@endpush

View File

@ -4,8 +4,45 @@
Cuotas - Pie
@endsection
@push('page_scripts')
<script>
const bancos = JSON.parse('{!! json_encode($bancos) !!}')
const estados = JSON.parse('{!! json_encode($estados) !!}')
</script>
@endpush
@section('venta_content')
<table class="ui table" id="cuotas">
@if (count($asociadas) > 0)
<div class="ui grid">
<div class="two wide column">Asociados</div>
<div class="six wide column">
{!! implode(' - ', array_map(function(Incoviba\Model\Venta $venta) use ($urls) {
return "<a href=\"{$urls->base}/venta/{$venta->id}\">{$venta->propiedad()->departamentos()[0]->descripcion}</a>";
}, $asociadas)) !!}
</div>
@if ($venta->formaPago()->pie->asociado !== null)
<div class="row">
<div class="ui tiny basic segment">
* Este pie no es la base para el cálculo de las cuotas
</div>
</div>
@endif
</div>
@endif
<div class="ui grid">
<div class="column">Valor</div>
<div class="four wide column">
{{$format->ufs($venta->formaPago()->pie->valor)}}
@if (count($asociadas) > 0)
[{{$format->ufs($venta->formaPago()->pie->valor + array_reduce($asociadas, function(float $sum, Incoviba\Model\Venta $venta) {
return $sum + $venta->formaPago()->pie->valor;
}, 0.0))}}]
@endif
</div>
<div class="column">Cuotas</div>
<div class="column">{{$venta->formaPago()->pie->cuotas}}</div>
</div>
<table class="ui compact table" id="cuotas">
<thead>
<tr>
<th>#</th>
@ -24,45 +61,63 @@
<tbody>@php
$now = new DateTimeImmutable();
$uf_venta = $venta->uf === 0.0 ? $UF->get($venta->currentEstado()->fecha) : $venta->uf;
if ($uf_venta === 0.0) {
$uf_venta = $UF->get();
}
@endphp
@foreach ($venta->formaPago()->pie->cuotas() as $cuota)
<tr data-pago="{{$cuota->pago->id}}"
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
class="disabled"
@endif >
<td>{{$cuota->numero}}</td>
<td>
{{$cuota->numero}}
<button class="ui mini tertiary icon button edit_cuota" data-cuota="{{$cuota->pago->id}}">
<i class="edit icon"></i>
</button>
</td>
<td>{{$cuota->pago->fecha->format('d-m-Y')}}</td>
<td>{{$cuota->pago->fecha->format('Y-m-d')}}</td>
<td>{{$cuota->pago->banco->nombre}}</td>
<td>{{$cuota->pago->identificador}}</td>
<td class="right aligned">{{$format->pesos($cuota->pago->valor)}}</td>
<td class="right aligned">
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' and $cuota->pago->currentEstado->fecha <= $now)
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['depositado', 'abonado'])
and $cuota->pago->currentEstado->fecha <= $now)
{{$format->ufs($cuota->pago->valor())}}
@else
~{{$format->ufs($cuota->pago->valor / $uf_venta)}}
@endif
</td>
<td
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado')
class="green"
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
class="yellow"
@elseif ($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1)
class="red"
@endif
>{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}</td>
<td{!! ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'abonado' ? ' class="green"' :
($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado' ? ' class="yellow"' :
($cuota->pago->currentEstado->tipoEstadoPago->activo !== 1 ? ' class="red"' : ''))) !!}>
{{ucwords($cuota->pago->currentEstado->tipoEstadoPago->descripcion)}}
<button class="ui mini tertiary icon button edit_estado_cuota" data-cuota="{{$cuota->pago->id}}"
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->id}}"
data-fecha="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
<i class="edit icon"></i>
</button>
</td>
<td>
@if (in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['abonado', 'anulado', 'reemplazado']))
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
@elseif (!in_array($cuota->pago->currentEstado->tipoEstadoPago->descripcion, ['anulado', 'reemplazado']))
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
{{$cuota->pago->currentEstado->fecha->format('d-m-Y')}}
@endif
<div class="ui calendar fecha_estado" data-date="{{$cuota->pago->currentEstado->fecha->format('Y-m-d')}}">
<div class="ui action left icon input">
<i class="calendar icon"></i>
<input type="text" name="fecha_estado" />
<button class="ui green basic icon button accept_estado" data-pago="{{$cuota->pago->id}}" data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
<button class="ui green basic icon button accept_estado"
data-pago="{{$cuota->pago->id}}"
data-estado="{{$cuota->pago->currentEstado->tipoEstadoPago->descripcion}}">
<i class="check icon"></i>
</button>
@if ($cuota->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado')
<button class="ui red basic icon button reject_estado" data-pago="{{$cuota->pago->id}}">
<button class="ui red basic icon button reject_estado"
data-pago="{{$cuota->pago->id}}">
<i class="remove icon"></i>
</button>
@endif
@ -85,13 +140,13 @@
<tr>
<th colspan="5">TOTAL</th>
<th class="right aligned">
{{$format->pesos($total_pesos = array_reduce($venta->formaPago()->pie->cuotas(),
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
{{$format->pesos($total_pesos = array_reduce($venta->formaPago()->pie->cuotas(vigentes: true),
function(int $sum, Incoviba\Model\Venta\Cuota $cuota) {
return $sum + $cuota->pago->valor;
}, 0))}}
</th>
<th class="right aligned">
{{$format->ufs($total = array_reduce($venta->formaPago()->pie->cuotas(),
{{$format->ufs($total = array_reduce($venta->formaPago()->pie->cuotas(vigentes: true),
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) use ($now, $uf_venta) {
return $sum + (($cuota->pago->fecha > $now or $cuota->pago->uf === null) ?
$cuota->pago->valor / $uf_venta :
@ -103,19 +158,20 @@
<tr>
<th colspan="5">TOTAL PAGADO</th>
<th class="right aligned">
{{$format->pesos($pagado_pesos = array_reduce($venta->formaPago()->pie->cuotas(true),
{{$format->pesos($pagado_pesos = array_reduce($venta->formaPago()->pie->cuotas(pagadas: true, vigentes: true),
function(int $sum, Incoviba\Model\Venta\Cuota $cuota) {
return $sum + $cuota->pago->valor;
}, 0))}}
</th>
<th class="right aligned">
{{$format->ufs($pagado = array_reduce($venta->formaPago()->pie->cuotas(true),
{{$format->ufs($pagado = array_reduce($venta->formaPago()->pie->cuotas(pagadas: true, vigentes: true),
function(float $sum, Incoviba\Model\Venta\Cuota $cuota) {
return $sum + $cuota->pago->valor();
}, 0.0))}}
</th>
<th class="right aligned">
{{$format->number($pagado / $total * 100, 2)}}%
{{ $format->percent(($total > 0) ? $pagado / $total : 0, 2, true) }} Pie<br />
{{ $format->percent($pagado / $venta->valor, 2, true) }} Promesa
</th>
<th colspan="3"></th>
</tr>
@ -128,12 +184,18 @@
{{$format->ufs($total - $pagado)}}
</th>
<th class="right aligned">
{{$format->number(($total - $pagado) / $total * 100, 2)}}%
{{$format->percent(($total > 0) ? ($total - $pagado) / $total * 100 : 0, 2)}}*
</th>
<th colspan="3"></th>
</tr>
</tfoot>
</table>
<div class="ui tiny basic right aligned segment">
* Porcentaje calculado sobre el valor de la venta
</div>
@include('ventas.pies.cuotas.edit')
@include('ventas.pies.cuotas.estados.edit')
@endsection
@include('layout.head.styles.datatables')
@ -142,12 +204,17 @@
@include('layout.body.scripts.datatables.buttons')
@push('page_scripts')
<script type="text/javascript">
<script>
$(document).ready(() => {
function updateRow({pago_id, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
const tr = $("tr[data-pago='" + pago_id + "']")
tr.find(':nth-child(7)').attr('class', color).html(estado)
tr.find(':nth-child(6)').html(valor)
if (typeof color !== 'undefined') {
tr.find(':nth-child(7)').attr('class', color).html(estado)
} else {
tr.find(':nth-child(7)').html(estado)
}
if (remove_fecha) {
tr.find(':nth-child(8)').html(fecha)
}
@ -181,7 +248,7 @@
if (!json.depositado) {
return
}
updateRow({pago_id: json.pago_id, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
updateRow({pago_id: json.pago_id, valor: json.pago.valor_uf, fecha: json.input.fecha, estado: 'Depositado', color: 'yellow', add_reject: true})
button.attr('data-estado', 'depositado')
})
})
@ -189,7 +256,7 @@
function abonar(pago_id, fecha) {
const url = '{{$urls->api}}/ventas/pago/' + pago_id + '/abonar'
const body = new FormData()
body.set('fecha', fecha.toISOString())
body.set('fecha', [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'))
return fetchAPI(url, {method: 'post', body}).then(response => {
if (!response) {
return
@ -234,6 +301,66 @@
})
})
}
function editar(id, body) {
const url = '{{$urls->api}}/ventas/pago/' + id
return fetchAPI(url, {method: 'post', body}).then(response => {
if (!response) {
return
}
return response.json().then(json => {
if (!json.editado) {
return
}
const tr = $(`tr[data-pago='${json.pago.id}']`)
tr.children(':nth-child(1)').html(json.pago.numero)
const fecha = json.pago.fecha.split(' ')[0].split('-').reverse().join('-')
tr.children(':nth-child(2)').html(fecha)
tr.children(':nth-child(3)').html(json.pago.banco.nombre)
tr.children(':nth-child(4)').html(json.pago.identificador)
const pesosFormatter = Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
tr.children(':nth-child(5)').html(pesosFormatter.format(json.pago.valor))
const ufFormatter = Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
tr.children(':nth-child(6)').html(ufFormatter.format(json.pago.valor_uf) + ' UF')
})
})
}
const editModal = new EditModal({id: '#edit_cuota_modal', approve: ({id, data}) => {
editar(id, data)
}})
$('.edit_cuota').on('click', clickEvent => {
const id = $(clickEvent.currentTarget).data('cuota')
const tr = $(`tr[data-pago='${id}']`)
const number = tr.children(':nth-child(1)').text().split('<')[0].trim()
const fecha = tr.children(':nth-child(2)').text()
const nombre_banco = tr.children(':nth-child(3)').text()
const banco_id = bancos.filter(banco => banco.nombre === nombre_banco)[0].id
const identificador = tr.find(':nth-child(4)').text()
const valor = parseInt(tr.find(':nth-child(5)').text().replace('$', '').replaceAll('.', '').trim())
editModal.open({id, number, fecha, banco_id, identificador, valor})
})
const editCuotaModal = new EditEstadoModal({id: '#edit_estado_cuota_modal', approve: ({id, data}) => {
const url = '{{$urls->api}}/ventas/pago/' + id + '/estado'
return fetchAPI(url, {method: 'post', body: data}).then(response => {
if (!response) {
return
}
return response.json().then(json => {
if (!json.editado) {
return
}
window.location.reload()
})
})
}})
$('.edit_estado_cuota').on('click', clickEvent => {
const id = $(clickEvent.currentTarget).data('cuota')
const estado_id = $(clickEvent.currentTarget).data('estado')
const fecha = $(clickEvent.currentTarget).data('fecha')
editCuotaModal.open({id, estado_id, fecha})
})
$('.fecha_estado').calendar({
type: 'date',
formatter: {
@ -270,17 +397,30 @@
zeroRecords: 'No se encotró cuotas con ese criterio',
search: 'Buscar: '
},
pageLength: "25",
pageLength: "100",
columnDefs: [
{
target: 1,
orderData: [2]
orderData: [2],
className: 'dt-center'
},
{
target: 2,
visible: false,
searchable: false
},
{
target: 3,
className: 'dt-center'
},
{
targets: [5, 6],
className: 'dt-right'
},
{
target: 7,
className: 'dt-center'
},
{
target: 8,
orderData: [9]

View File

@ -86,7 +86,7 @@
@include('layout.body.scripts.dayjs')
@push('page_scripts')
<script type="text/javascript">
<script>
function setDate(index, calendar, date = new Date()) {
const d = dayjs(date)
$(calendar).calendar('set date', new Date(d.add(index, 'M').valueOf()))

View File

@ -0,0 +1,108 @@
<div class="ui mini modal" id="edit_cuota_modal">
<div class="header">Editar Cuota <span class="numero"></span></div>
<div class="content">
<form class="ui form" id="edit_cuota_form">
<input type="hidden" name="id" />
<div class="field">
<label>Fecha de Pago</label>
<div class="ui calendar" id="edit_fecha">
<div class="ui icon input">
<input type="text" name="fecha" />
<i class="calendar icon"></i>
</div>
</div>
</div>
<div class="field">
<label>Banco</label>
<div class="ui search selection dropdown" id="edit_banco">
<i class="dropdown icon"></i>
<input type="hidden" name="banco" />
<div class="default text">Banco</div>
<div class="menu">
@foreach($bancos as $banco)
<div class="item" data-value="{{ $banco->id }}">{{ $banco->nombre }}</div>
@endforeach
</div>
</div>
</div>
<div class="field">
<label>Identificador</label>
<input type="text" name="identificador" />
</div>
<div class="field">
<label>Valor</label>
<div class="ui labeled input">
<div class="ui label">$</div>
<input type="text" name="valor" />
</div>
</div>
</form>
</div>
<div class="actions">
<button class="ui positive approve icon button">
<i class="check icon"></i>
</button>
<button class="ui negative cancel icon button">
<i class="times icon"></i>
</button>
</div>
</div>
@push('page_scripts')
<script>
class EditModal {
id
approveCallback
data
constructor({id, approve}) {
this.id = id
this.approveCallback = approve;
$(this.id).modal({
onApprove: $element => {
return this.approve($element)
}
})
$(this.id).find('#edit_fecha').calendar(calendar_date_options)
$(this.id).find('#edit_banco').dropdown()
}
open({id, number, fecha, banco_id, identificador, valor}) {
this.data = {id, fecha: fecha.split('-').reverse().join('-'), banco: banco_id, identificador, valor}
$(this.id).find('.numero').text(number)
$(this.id).find('input[name="id"]').val(id)
const dateParts = fecha.split('-')
const date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0])
$(this.id).find('#edit_fecha').calendar('set date', date)
$(this.id).find('#edit_banco').dropdown('set selected', banco_id)
$(this.id).find('input[name="identificador"]').val(identificador)
$(this.id).find('input[name="valor"]').val(valor)
$(this.id).modal('show')
}
approve($element) {
const $form = $(this.id).find('#edit_cuota_form')
const temp = new FormData(document.getElementById('edit_cuota_form'))
const date = $form.find('#edit_fecha').calendar('get date')
temp.set('fecha', date.getFullYear() + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getDate().toString().padStart(2, '0'))
temp.set('banco', $form.find('#edit_banco').dropdown('get value'))
temp.set('valor', temp.get('valor'))
const data = new FormData()
Object.entries(this.data).forEach(([key, value]) => {
if (key === 'id') {
return;
}
if (temp.get(key) === value.toString()) {
return;
}
data.set(key, temp.get(key))
})
return this.approveCallback({id: this.data.id, data})
}
}
</script>
@endpush

View File

@ -0,0 +1,93 @@
<div class="ui mini modal" id="edit_estado_cuota_modal">
<div class="header">Editar Estado Cuota <span class="numero"></span></div>
<div class="content">
<form class="ui form" id="edit_estado_cuota_form">
<input type="hidden" name="id" />
<div class="field">
<label>Estado</label>
<div class="ui search selection dropdown" id="edit_estado_estado">
<i class="dropdown icon"></i>
<input type="hidden" name="estado" />
<div class="default text">Estado</div>
<div class="menu">
@foreach($estados as $estado)
<div class="item" data-value="{{ $estado->id }}">{{ ucwords($estado->descripcion) }}</div>
@endforeach
</div>
</div>
</div>
<div class="field">
<label>Fecha Estado</label>
<div class="ui calendar" id="edit_estado_fecha">
<div class="ui icon input">
<input type="text" name="fecha" />
<i class="calendar icon"></i>
</div>
</div>
</div>
</form>
</div>
<div class="actions">
<button class="ui positive approve icon button">
<i class="check icon"></i>
</button>
<button class="ui negative cancel icon button">
<i class="times icon"></i>
</button>
</div>
</div>
@push('page_scripts')
<script>
class EditEstadoModal {
id
approveCallback
data
constructor({id, approve}) {
this.id = id
this.approveCallback = approve;
$(this.id).modal({
onApprove: $element => {
return this.approve($element)
}
})
$(this.id).find('#edit_estado_estado').dropdown()
$(this.id).find('#edit_estado_fecha').calendar(calendar_date_options)
}
open({id, estado_id, fecha}) {
this.data = {id, fecha: fecha, estado: estado_id}
$(this.id).find('input[name="id"]').val(id)
$(this.id).find('#edit_estado_estado').dropdown('set selected', estado_id)
const dateParts = fecha.split('-')
const date = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
$(this.id).find('#edit_estado_fecha').calendar('set date', date)
$(this.id).modal('show')
}
approve($element) {
const $form = $(this.id).find('#edit_estado_cuota_form')
const temp = new FormData(document.getElementById('edit_estado_cuota_form'))
const date = $form.find('#edit_estado_fecha').calendar('get date')
temp.set('estado', $form.find('#edit_estado_estado').dropdown('get value'))
temp.set('fecha', date.getFullYear() + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getDate().toString().padStart(2, '0'))
const data = new FormData()
Object.entries(this.data).forEach(([key, value]) => {
if (key === 'id') {
return;
}
if (temp.get(key) === value.toString()) {
return;
}
data.set(key, temp.get(key))
})
return this.approveCallback({id: this.data.id, data})
}
}
</script>
@endpush