feature/cierres (#25)

Varios cambios

Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #25
This commit is contained in:
2025-07-22 13:18:00 +00:00
parent ba57cad514
commit 307f2ac7d7
418 changed files with 20045 additions and 984 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

@ -33,6 +33,8 @@
</form>
@endsection
@include('layout.body.scripts.number_input')
@push('page_scripts')
<script>
$(document).ready(() => {
@ -40,13 +42,17 @@
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 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 => {
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()
}

View File

@ -61,6 +61,9 @@
<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}}"
@ -201,7 +204,7 @@
@include('layout.body.scripts.datatables.buttons')
@push('page_scripts')
<script type="text/javascript">
<script>
$(document).ready(() => {
function updateRow({pago_id, valor, fecha, color, estado, remove_fecha=false, add_reject=false, disable=false}) {
const tr = $("tr[data-pago='" + pago_id + "']")

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()))