@@ -62,9 +62,9 @@
function editEscritura() {
const url = '{{$urls->api}}/ventas/escritura/{{$venta->id}}/edit'
const data = new FormData()
- data.set('venta', {{$venta->id}})
const fecha = $('#fecha').calendar('get date')
data.set('fecha', fecha.toISOString())
+ data.set('valor', $('#valor').val())
data.set('estado', $('#estado').dropdown('get value'))
return fetchAPI(url, {method: 'post', body: data}).then(response => {
if (response.ok) {
@@ -78,10 +78,11 @@
})
}
$(document).ready(() => {
- calendar_date_options.initialDate = new Date({{$venta->currentEstado()->fecha->format('Y, m-1, j')}})
+ calendar_date_options.initialDate = new Date({{$venta->formaPago()->escritura->pago->currentEstado->fecha->format('Y, m-1, j')}})
$('#fecha').calendar(calendar_date_options)
- $('#estado').dropdown()
- $('#estado').dropdown('set selected', '{{$venta->currentEstado()->id}}')
+ const $estado = $('#estado')
+ $estado.dropdown()
+ $estado.dropdown('set selected', '{{$venta->formaPago()->escritura->pago->currentEstado->tipoEstadoPago->id}}')
$('#edit_form').submit(event => {
event.preventDefault()
editEscritura()
diff --git a/app/resources/views/ventas/facturacion/show.blade.php b/app/resources/views/ventas/facturacion/show.blade.php
index d9bcaba..f936710 100644
--- a/app/resources/views/ventas/facturacion/show.blade.php
+++ b/app/resources/views/ventas/facturacion/show.blade.php
@@ -82,7 +82,7 @@
new Unidad({
id: {{$unidad->id}},
tipo: '{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}',
- descripcion: '{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}} {{ $unidad->descripcion }} (UF {{ number_format($unidad->precio($venta->currentEstado()->fecha)->valor, 2) }})',
+ descripcion: '{{ $unidad->descripcion }}',
prorrateo: {{$unidad->prorrateo}},
propiedad_unidad_id: {{$unidad->pu_id}},
valor: {{($unidad->valor > 0) ? $unidad->valor : $unidad->precio($venta->currentEstado()->fecha)->valor}}
@@ -96,7 +96,7 @@
@if ($terreno->fecha != null) fecha: new Date('{{$terreno->fecha->add(new DateInterval('P1D'))->format('Y-m-d')}}'),
@else fecha: null,
@endif
- valor: {{($terreno->valor ?? 0) * (1+$ipc)}}
+ valor: {{($terreno->valor ?? 0) * (1 + $ipc)}}
},
facturas: []
}
@@ -110,9 +110,9 @@
this.venta.props.facturas.facturas[{{$factura->index - 1}}] = new Factura({
id: {{ $factura->id }},
venta: this.venta.props,
+ proporcion: {{ $factura->proporcion }},
index: {{$factura->index}},
fecha: new Date('{{$factura->fecha->format('Y-m-d')}}'),
- proporcion: {{$factura->proporcion}},
emisor: {
rut: '{{$factura->venta->proyecto()->inmobiliaria()->rut}}',
nombre: '{{$factura->venta->proyecto()->inmobiliaria()->razon}}',
@@ -137,7 +137,7 @@
unidad: new Unidad({
id: {{$unidad->unidad->id}},
tipo: '{{ucwords($unidad->unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}',
- descripcion: '{{ucwords($unidad->unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}} {{ $unidad->unidad->descripcion }} (UF {{ number_format(array_values(array_filter($venta->propiedad()->unidades, function($uni) use ($unidad, $factura) {return $uni->id === $unidad->unidad->id;}))[0]->precio($venta->currentEstado()->fecha)->valor * $factura->proporcion, 2) }})',
+ descripcion: '{{ $unidad->unidad->descripcion }}',
prorrateo: {{$unidad->prorrateo}},
propiedad_unidad_id: {{ array_values(array_filter($venta->propiedad()->unidades, function($uni) use ($unidad) {return $uni->id === $unidad->unidad->id;}))[0]->pu_id }},
valor: {{$unidad->precio}}
@@ -150,7 +150,7 @@
],
detalle: {
base: {{ $factura->base() }},
- terreno: {{ $factura->terreno * $factura->proporcion }},
+ terreno: {{ $factura->terreno * $factura->proporcion * $factura->prorrateo }},
neto: {{ $factura->neto() }},
iva: {{ $factura->iva() }},
bruto: {{ $factura->bruto() }},
diff --git a/app/resources/views/ventas/facturacion/show/factura.blade.php b/app/resources/views/ventas/facturacion/show/factura.blade.php
index b039f68..f77ca5f 100644
--- a/app/resources/views/ventas/facturacion/show/factura.blade.php
+++ b/app/resources/views/ventas/facturacion/show/factura.blade.php
@@ -5,6 +5,10 @@
venta: null,
index: 0,
proporcion: 0,
+ terreno: {
+ fecha: null,
+ valor: 0
+ },
emisor: {
rut: '',
nombre: '',
@@ -50,6 +54,9 @@
get saved() {
return this.props.id > 0
}
+ get prorrateo() {
+ return this.props.unidades.reduce((sum, unidad) => sum + unidad.prorrateo, 0)
+ }
draw() {
return {
divider: () => {
@@ -186,7 +193,7 @@
return unidadesData.join("\n")
},
unidad: ({unidad, no, classes, formatters}) => {
- const descuento = this.props.detalle.terreno * unidad.prorrateo
+ const descuento = this.props.terreno.valor * unidad.prorrateo * this.props.proporcion
const bruto = unidad.precio - descuento
const neto = bruto / 1.19
const data = [
@@ -240,6 +247,20 @@
return row.join('')
},
totales: ({formatters}) => {
+ let tooltips = {
+ neto: null,
+ iva: null,
+ total: null
+ }
+ if (this.props.total.neto !== this.props.detalle.neto) {
+ tooltips.neto = ` data-tooltip="No coinciden netos! Promesa: ${formatters.pesos.format(this.props.detalle.neto)} - Unidades: ${formatters.pesos.format(this.props.total.neto)}"`
+ }
+ if (this.props.total.iva !== this.props.detalle.iva) {
+ tooltips.iva = ` data-tooltip="No coinciden ivas! Promesa: ${formatters.pesos.format(this.props.detalle.iva)} - Unidades: ${formatters.pesos.format(this.props.total.iva)}"`
+ }
+ if (this.props.total.total !== this.props.detalle.total) {
+ tooltips.total = ` data-tooltip="No coinciden totales! Promesa: ${formatters.pesos.format(this.props.detalle.total)} - Unidades: ${formatters.pesos.format(this.props.total.total)}"`
+ }
return [
'
',
'
',
@@ -253,7 +274,7 @@
'
',
'',
'Monto Neto | ',
- ''+formatters.pesos.format(this.props.total.neto)+' | ',
+ `${formatters.pesos.format(this.props.total.neto)} | `,
'
',
'',
'Monto Exento | ',
@@ -261,11 +282,11 @@
'
',
'',
'19% IVA | ',
- ''+formatters.pesos.format(this.props.total.iva)+' | ',
+ `${formatters.pesos.format(this.props.total.iva)} | `,
'
',
'',
'Monto Total | ',
- ''+formatters.pesos.format(this.props.total.total)+' | ',
+ `${formatters.pesos.format(this.props.total.total)} | `,
'
',
'',
'