Editar cuota
This commit is contained in:
@ -4,6 +4,12 @@
|
||||
Cuotas - Pie
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const bancos = JSON.parse('{!! json_encode($bancos) !!}')
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@section('venta_content')
|
||||
@if (count($asociadas) > 0)
|
||||
<div class="ui grid">
|
||||
@ -60,7 +66,12 @@
|
||||
@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>
|
||||
@ -172,6 +183,8 @@
|
||||
<div class="ui tiny basic right aligned segment">
|
||||
* Porcentaje calculado sobre el valor de la venta
|
||||
</div>
|
||||
|
||||
@include('ventas.pies.cuotas.edit')
|
||||
@endsection
|
||||
|
||||
@include('layout.head.styles.datatables')
|
||||
@ -186,7 +199,11 @@
|
||||
const tr = $("tr[data-pago='" + pago_id + "']")
|
||||
|
||||
tr.find(':nth-child(6)').html(valor)
|
||||
tr.find(':nth-child(7)').attr('class', color).html(estado)
|
||||
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)
|
||||
}
|
||||
@ -273,6 +290,44 @@
|
||||
})
|
||||
})
|
||||
}
|
||||
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.find(':nth-child(1)').html(json.pago.numero)
|
||||
const fecha = json.pago.fecha.split(' ')[0].split('-').reverse().join('-')
|
||||
tr.find(':nth-child(2)').html(fecha)
|
||||
tr.find(':nth-child(3)').html(json.pago.banco.nombre)
|
||||
tr.find(':nth-child(4)').html(json.pago.identificador)
|
||||
const pesosFormatter = Intl.NumberFormat('es-CL', {style: 'currency', currency: 'CLP'})
|
||||
tr.find(':nth-child(5)').html(pesosFormatter.format(json.pago.valor))
|
||||
const ufFormatter = Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||
tr.find(':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.find(':nth-child(1)').text().split('<')[0].trim()
|
||||
const fecha = tr.find(':nth-child(2)').text()
|
||||
const banco_id = bancos.filter(banco => banco.nombre === tr.find(':nth-child(3)').text())[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})
|
||||
})
|
||||
$('.fecha_estado').calendar({
|
||||
type: 'date',
|
||||
formatter: {
|
||||
|
Reference in New Issue
Block a user