FIX: escriturar

This commit is contained in:
2024-01-18 15:18:07 -03:00
parent e1462657fc
commit 01af47fba1
2 changed files with 64 additions and 10 deletions

View File

@ -86,7 +86,7 @@
<div class="ui calendar" id="fecha_pago">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" class="fecha_pago" />
<input type="text" name="fecha_pago" />
</div>
</div>
</div>
@ -160,13 +160,13 @@
</div>
</div>
@endif
@if (isset($venta->formaPago()->credito) and $venta->formaPago()->credito->pago->banco === null)
@if (!isset($venta->formaPago()->credito) or $venta->formaPago()->credito->pago->banco === null)
<h4 class="ui header">Crédito</h4>
<div class="fields">
<div class="field">
<label for="valor_credito">Valor [UF]</label>
<div class="ui right labeled disabled input">
<input type="text" value="{{$format->number($venta->formaPago()->credito->pago->valor(), 2)}}" />
<div class="ui right labeled input">
<input type="text" id="valor_credito" name="valor_credito" value="{{$venta->formaPago()->credito?->pago->valor() ?? ''}}" />
<div class="ui basic label">UF</div>
</div>
</div>
@ -254,9 +254,15 @@
$('#escriturar_form').submit(event => {
event.preventDefault()
const url = '{{$urls->api}}/venta/{{$venta->id}}/escriturar'
const data = new FormData(event.currentTarget)
data.set('fecha', $('#fecha').calendar('get date').toISOString())
fetchAPI(url, {method: 'post', body: data}).then(response => {
const body = new FormData(event.currentTarget)
body.set('fecha', $('#fecha').calendar('get date').toISOString())
if (body.get('fecha_pago') !== '') {
body.set('fecha_pago', $('#fecha_pago').calendar('get date').toISOString())
}
if (body.get('fecha_reajuste') !== '') {
body.set('fecha_reajuste', $('#fecha_reajuste').calendar('get date').toISOString())
}
fetchAPI(url, {method: 'post', body}).then(response => {
if (response.ok) {
return response.json()
}
@ -267,6 +273,8 @@
})
return false
})
$('#fecha_pago').calendar(calendar_date_options)
$('#fecha_reajuste').calendar(calendar_date_options)
})
</script>
@endpush