Agregar Pie

This commit is contained in:
Juan Pablo Vial
2025-03-26 16:41:54 -03:00
parent 4ce83fb270
commit db36549699
8 changed files with 195 additions and 44 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

@ -1,42 +1,52 @@
@if ($pie !== null)
<tr>
<td>
Pie
<sub>
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie">
<i class="edit icon"></i>
</a>
</sub>
</td>
<td></td>
<td class="right aligned">{{$format->ufs($pie->valor)}}</td>
<td class="right aligned">{{$format->pesos($pie->valor * $pie->uf)}}</td>
<td class="right aligned">Cuotas</td>
<td>
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
<span data-tooltip="Pagadas">{{count($pie->cuotas(true, true))}}</span>/{{$pie->cuotas}}
</a>
@if (count($pie->cuotas(vigentes: true)) < $pie->cuotas)
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
@if ($pie !== null)
<sub>
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie">
<i class="edit icon"></i>
</a>
</sub>
@else
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/add">
<i class="plus icon"></i>
</a>
@endif
</td>
</tr>
<tr>
<td>Pagado</td>
<td></td>
<td class="right aligned">{{$format->ufs($pie->pagado())}}</td>
<td class="right aligned">{{$format->pesos($pie->pagado('pesos'))}}</td>
<td colspan="2"></td>
</tr>
@if ($pie->reajuste)
<tr>
<td>Reajuste</td>
<td></td>
<td class="right aligned">{{$format->ufs($pie->reajuste->valor())}}</td>
<td class="right aligned">{{$format->pesos($pie->reajuste->valor)}}</td>
<td colspan="2"></td>
@if ($pie !== null)
<td class="right aligned">{{$format->ufs($pie->valor)}}</td>
<td class="right aligned">{{$format->pesos($pie->valor * $pie->uf)}}</td>
<td class="right aligned">Cuotas</td>
<td>
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
<span data-tooltip="Pagadas">{{count($pie->cuotas(true, true))}}</span>/{{$pie->cuotas}}
</a>
@if (count($pie->cuotas(vigentes: true)) < $pie->cuotas)
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
<i class="plus icon"></i>
</a>
@endif
</td>
@else
<td colspan="4"></td>
@endif
</tr>
@endif
@if ($pie !== null)
<tr>
<td>Pagado</td>
<td></td>
<td class="right aligned">{{$format->ufs($pie->pagado())}}</td>
<td class="right aligned">{{$format->pesos($pie->pagado('pesos'))}}</td>
<td colspan="2"></td>
</tr>
@if ($pie->reajuste)
<tr>
<td>Reajuste</td>
<td></td>
<td class="right aligned">{{$format->ufs($pie->reajuste->valor())}}</td>
<td class="right aligned">{{$format->pesos($pie->reajuste->valor)}}</td>
<td colspan="2"></td>
</tr>
@endif
@endif