FIX: Calculos corregidos en factura
This commit is contained in:
@ -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,10 @@
|
||||
return row.join('')
|
||||
},
|
||||
totales: ({formatters}) => {
|
||||
let tooltip
|
||||
if (this.props.total.total !== this.props.detalle.total) {
|
||||
tooltip = ` data-tooltip="No coinciden totales! Promesa: ${formatters.pesos.format(this.props.detalle.total)} - Unidades: ${formatters.pesos.format(this.props.total.total)}"`
|
||||
}
|
||||
return [
|
||||
'<div class="row">',
|
||||
'<div class="ten wide column"></div>',
|
||||
@ -265,7 +276,7 @@
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<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) ? tooltip : ''}><strong id="total">${formatters.pesos.format(this.props.total.total)}</strong></td>`,
|
||||
'</tr>',
|
||||
'</tbody>',
|
||||
'</table>',
|
||||
@ -364,12 +375,10 @@
|
||||
this.props.uf.valor = venta.props.uf.valor
|
||||
this.update().propietario(venta.props.propietarios.find(propietario => propietario.props.index === this.props.index))
|
||||
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.update().detalle(venta.props.facturas.terreno.valor * venta.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.total = venta.props.valor * this.props.proporcion * venta.props.uf.valor
|
||||
this.update().detalle(venta.props.facturas.terreno.valor * this.prorrateo)
|
||||
this.props.detalle.descuento = venta.prorrateo * this.props.proporcion
|
||||
this.update().total()
|
||||
},
|
||||
detalle: terreno => {
|
||||
this.props.detalle.terreno = terreno * this.props.proporcion
|
||||
@ -378,14 +387,20 @@
|
||||
this.props.detalle.iva = this.props.detalle.neto * 0.19
|
||||
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 => {
|
||||
this.props.unidades = []
|
||||
unidades.forEach(unidad => {
|
||||
this.props.unidades.push({
|
||||
unidad: unidad,
|
||||
descripcion: unidad.changeDescripcion(this.props.proporcion || 1),
|
||||
precio: unidad.props.valor * this.props.uf.valor * this.props.proporcion,
|
||||
prorrateo: unidad.props.prorrateo * this.props.proporcion
|
||||
precio: unidad.props.valor * this.props.uf.valor,
|
||||
prorrateo: unidad.props.prorrateo
|
||||
})
|
||||
})
|
||||
},
|
||||
|
Reference in New Issue
Block a user