FIX: Calculos corregidos en factura
This commit is contained in:
@ -82,7 +82,7 @@
|
|||||||
new Unidad({
|
new Unidad({
|
||||||
id: {{$unidad->id}},
|
id: {{$unidad->id}},
|
||||||
tipo: '{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}',
|
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}},
|
prorrateo: {{$unidad->prorrateo}},
|
||||||
propiedad_unidad_id: {{$unidad->pu_id}},
|
propiedad_unidad_id: {{$unidad->pu_id}},
|
||||||
valor: {{($unidad->valor > 0) ? $unidad->valor : $unidad->precio($venta->currentEstado()->fecha)->valor}}
|
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')}}'),
|
@if ($terreno->fecha != null) fecha: new Date('{{$terreno->fecha->add(new DateInterval('P1D'))->format('Y-m-d')}}'),
|
||||||
@else fecha: null,
|
@else fecha: null,
|
||||||
@endif
|
@endif
|
||||||
valor: {{($terreno->valor ?? 0) * (1+$ipc)}}
|
valor: {{($terreno->valor ?? 0) * (1 + $ipc)}}
|
||||||
},
|
},
|
||||||
facturas: []
|
facturas: []
|
||||||
}
|
}
|
||||||
@ -112,7 +112,6 @@
|
|||||||
venta: this.venta.props,
|
venta: this.venta.props,
|
||||||
index: {{$factura->index}},
|
index: {{$factura->index}},
|
||||||
fecha: new Date('{{$factura->fecha->format('Y-m-d')}}'),
|
fecha: new Date('{{$factura->fecha->format('Y-m-d')}}'),
|
||||||
proporcion: {{$factura->proporcion}},
|
|
||||||
emisor: {
|
emisor: {
|
||||||
rut: '{{$factura->venta->proyecto()->inmobiliaria()->rut}}',
|
rut: '{{$factura->venta->proyecto()->inmobiliaria()->rut}}',
|
||||||
nombre: '{{$factura->venta->proyecto()->inmobiliaria()->razon}}',
|
nombre: '{{$factura->venta->proyecto()->inmobiliaria()->razon}}',
|
||||||
@ -137,7 +136,7 @@
|
|||||||
unidad: new Unidad({
|
unidad: new Unidad({
|
||||||
id: {{$unidad->unidad->id}},
|
id: {{$unidad->unidad->id}},
|
||||||
tipo: '{{ucwords($unidad->unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}',
|
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}},
|
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 }},
|
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}}
|
valor: {{$unidad->precio}}
|
||||||
@ -150,7 +149,7 @@
|
|||||||
],
|
],
|
||||||
detalle: {
|
detalle: {
|
||||||
base: {{ $factura->base() }},
|
base: {{ $factura->base() }},
|
||||||
terreno: {{ $factura->terreno * $factura->proporcion }},
|
terreno: {{ $factura->terreno * $factura->proporcion * $factura->prorrateo }},
|
||||||
neto: {{ $factura->neto() }},
|
neto: {{ $factura->neto() }},
|
||||||
iva: {{ $factura->iva() }},
|
iva: {{ $factura->iva() }},
|
||||||
bruto: {{ $factura->bruto() }},
|
bruto: {{ $factura->bruto() }},
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
venta: null,
|
venta: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
proporcion: 0,
|
proporcion: 0,
|
||||||
|
terreno: {
|
||||||
|
fecha: null,
|
||||||
|
valor: 0
|
||||||
|
},
|
||||||
emisor: {
|
emisor: {
|
||||||
rut: '',
|
rut: '',
|
||||||
nombre: '',
|
nombre: '',
|
||||||
@ -50,6 +54,9 @@
|
|||||||
get saved() {
|
get saved() {
|
||||||
return this.props.id > 0
|
return this.props.id > 0
|
||||||
}
|
}
|
||||||
|
get prorrateo() {
|
||||||
|
return this.props.unidades.reduce((sum, unidad) => sum + unidad.prorrateo, 0)
|
||||||
|
}
|
||||||
draw() {
|
draw() {
|
||||||
return {
|
return {
|
||||||
divider: () => {
|
divider: () => {
|
||||||
@ -186,7 +193,7 @@
|
|||||||
return unidadesData.join("\n")
|
return unidadesData.join("\n")
|
||||||
},
|
},
|
||||||
unidad: ({unidad, no, classes, formatters}) => {
|
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 bruto = unidad.precio - descuento
|
||||||
const neto = bruto / 1.19
|
const neto = bruto / 1.19
|
||||||
const data = [
|
const data = [
|
||||||
@ -240,6 +247,20 @@
|
|||||||
return row.join('')
|
return row.join('')
|
||||||
},
|
},
|
||||||
totales: ({formatters}) => {
|
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 [
|
return [
|
||||||
'<div class="row">',
|
'<div class="row">',
|
||||||
'<div class="ten wide column"></div>',
|
'<div class="ten wide column"></div>',
|
||||||
@ -253,7 +274,7 @@
|
|||||||
'<tbody>',
|
'<tbody>',
|
||||||
'<tr>',
|
'<tr>',
|
||||||
'<td class="grey">Monto Neto</td>',
|
'<td class="grey">Monto Neto</td>',
|
||||||
'<td class="right aligned" id="neto">'+formatters.pesos.format(this.props.total.neto)+'</td>',
|
`<td class="right aligned${this.props.total.neto !== this.props.detalle.neto ? ' red' : ''}"${this.props.total.neto !== this.props.detalle.neto ? tooltips.neto : ''} id="neto">${formatters.pesos.format(this.props.total.neto)}</td>`,
|
||||||
'</tr>',
|
'</tr>',
|
||||||
'<tr>',
|
'<tr>',
|
||||||
'<td class="grey">Monto Exento</td>',
|
'<td class="grey">Monto Exento</td>',
|
||||||
@ -261,11 +282,11 @@
|
|||||||
'</tr>',
|
'</tr>',
|
||||||
'<tr>',
|
'<tr>',
|
||||||
'<td class="grey">19% IVA</td>',
|
'<td class="grey">19% IVA</td>',
|
||||||
'<td class="right aligned" id="iva">'+formatters.pesos.format(this.props.total.iva)+'</td>',
|
`<td class="right aligned${this.props.total.iva !== this.props.detalle.iva ? ' red' : ''}"${this.props.total.iva !== this.props.detalle.iva ? tooltips.iva : ''} id="iva">${formatters.pesos.format(this.props.total.iva)}</td>`,
|
||||||
'</tr>',
|
'</tr>',
|
||||||
'<tr>',
|
'<tr>',
|
||||||
'<td class="grey">Monto Total</td>',
|
'<td class="grey">Monto Total</td>',
|
||||||
'<td class="right aligned"><strong id="total">'+formatters.pesos.format(this.props.total.total)+'</strong></td>',
|
`<td class="right aligned${(this.props.total.total !== this.props.detalle.total) ? ' red' : ''}"${(this.props.total.total !== this.props.detalle.total) ? tooltips.total : ''}><strong id="total">${formatters.pesos.format(this.props.total.total)}</strong></td>`,
|
||||||
'</tr>',
|
'</tr>',
|
||||||
'</tbody>',
|
'</tbody>',
|
||||||
'</table>',
|
'</table>',
|
||||||
@ -364,12 +385,10 @@
|
|||||||
this.props.uf.valor = venta.props.uf.valor
|
this.props.uf.valor = venta.props.uf.valor
|
||||||
this.update().propietario(venta.props.propietarios.find(propietario => propietario.props.index === this.props.index))
|
this.update().propietario(venta.props.propietarios.find(propietario => propietario.props.index === this.props.index))
|
||||||
this.update().unidades(venta.props.unidades)
|
this.update().unidades(venta.props.unidades)
|
||||||
this.props.total.total = this.props.detalle.total = venta.props.valor * this.props.proporcion * venta.props.uf.valor
|
this.props.detalle.total = venta.props.valor * this.props.proporcion * venta.props.uf.valor
|
||||||
this.update().detalle(venta.props.facturas.terreno.valor * venta.prorrateo)
|
this.update().detalle(venta.props.facturas.terreno.valor * this.prorrateo)
|
||||||
this.props.total.exento = this.props.detalle.terreno
|
|
||||||
this.props.total.iva = this.props.detalle.iva
|
|
||||||
this.props.total.neto = this.props.unidades.reduce((sum, unidad) => sum + unidad.precio, 0)
|
|
||||||
this.props.detalle.descuento = venta.prorrateo * this.props.proporcion
|
this.props.detalle.descuento = venta.prorrateo * this.props.proporcion
|
||||||
|
this.update().total()
|
||||||
},
|
},
|
||||||
detalle: terreno => {
|
detalle: terreno => {
|
||||||
this.props.detalle.terreno = terreno * this.props.proporcion
|
this.props.detalle.terreno = terreno * this.props.proporcion
|
||||||
@ -378,14 +397,20 @@
|
|||||||
this.props.detalle.iva = this.props.detalle.neto * 0.19
|
this.props.detalle.iva = this.props.detalle.neto * 0.19
|
||||||
this.props.detalle.base = this.props.detalle.neto + this.props.detalle.terreno
|
this.props.detalle.base = this.props.detalle.neto + this.props.detalle.terreno
|
||||||
},
|
},
|
||||||
|
total: () => {
|
||||||
|
this.props.total.exento = this.props.detalle.terreno
|
||||||
|
this.props.total.neto = (this.props.unidades.reduce((sum, unidad) => sum + unidad.precio, 0) - this.props.total.exento) / 1.19
|
||||||
|
this.props.total.iva = this.props.total.neto * 0.19
|
||||||
|
this.props.total.total = this.props.total.neto + this.props.total.iva + this.props.total.exento
|
||||||
|
},
|
||||||
unidades: unidades => {
|
unidades: unidades => {
|
||||||
this.props.unidades = []
|
this.props.unidades = []
|
||||||
unidades.forEach(unidad => {
|
unidades.forEach(unidad => {
|
||||||
this.props.unidades.push({
|
this.props.unidades.push({
|
||||||
unidad: unidad,
|
unidad: unidad,
|
||||||
descripcion: unidad.changeDescripcion(this.props.proporcion || 1),
|
descripcion: unidad.changeDescripcion(this.props.proporcion || 1),
|
||||||
precio: unidad.props.valor * this.props.uf.valor * this.props.proporcion,
|
precio: unidad.props.valor * this.props.uf.valor,
|
||||||
prorrateo: unidad.props.prorrateo * this.props.proporcion
|
prorrateo: unidad.props.prorrateo
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
changeDescripcion(proporcion = 1) {
|
changeDescripcion(proporcion = 1) {
|
||||||
return this.descripcion = [this.props.tipo, this.props.descripcion, `[UF ${facturas.formatters.ufs.format(this.props.valor * proporcion)}]`].join(' ')
|
return this.descripcion = [this.props.tipo, this.props.descripcion, `(UF ${facturas.formatters.ufs.format(this.props.valor * proporcion)})`].join(' ')
|
||||||
}
|
}
|
||||||
update() {
|
update() {
|
||||||
return {
|
return {
|
||||||
|
@ -403,6 +403,7 @@
|
|||||||
venta: this.props,
|
venta: this.props,
|
||||||
index: propietario.props.index,
|
index: propietario.props.index,
|
||||||
proporcion: propietario.props.proporcion,
|
proporcion: propietario.props.proporcion,
|
||||||
|
terreno: this.props.facturas.terreno,
|
||||||
emisor: {
|
emisor: {
|
||||||
rut: this.props.inmobiliaria.rut,
|
rut: this.props.inmobiliaria.rut,
|
||||||
nombre: this.props.inmobiliaria.nombre,
|
nombre: this.props.inmobiliaria.nombre,
|
||||||
|
Reference in New Issue
Block a user