Separacion de objetos
This commit is contained in:
@ -186,16 +186,16 @@
|
||||
return unidadesData.join("\n")
|
||||
},
|
||||
unidad: ({unidad, no, classes, formatters}) => {
|
||||
const descuento = Math.round(this.props.detalle.terreno * unidad.prorrateo)
|
||||
const descuento = this.props.detalle.terreno * unidad.prorrateo
|
||||
const bruto = unidad.precio - descuento
|
||||
const neto = bruto / 1.19
|
||||
const data = [
|
||||
no,
|
||||
unidad.descripcion,
|
||||
'1 UNID',
|
||||
formatters.pesos.format(neto * this.props.proporcion),
|
||||
formatters.pesos.format(neto),
|
||||
'AF',
|
||||
formatters.pesos.format(neto * this.props.proporcion)
|
||||
formatters.pesos.format(neto)
|
||||
]
|
||||
|
||||
const row = ['<tr>']
|
||||
@ -308,22 +308,24 @@
|
||||
}
|
||||
}
|
||||
save() {
|
||||
let url = '{{$urls->api}}/venta/{{$venta->id}}/facturas/add'
|
||||
let url = '{{$urls->api}}/ventas/facturas/add'
|
||||
if (this.saved) {
|
||||
url = `{{$urls->api}}/venta/{{$venta->id}}/facturas/${this.props.id}/edit`
|
||||
url = `{{$urls->api}}/ventas/facturas/${this.props.id}/edit`
|
||||
}
|
||||
const method = 'post'
|
||||
const body = new FormData()
|
||||
body.set('venta_id', this.props.venta_id)
|
||||
body.set('venta_id', this.props.venta.id)
|
||||
body.set('index', this.props.index)
|
||||
body.set('proporcion', this.props.proporcion)
|
||||
body.set('cliente', JSON.stringify(this.props.receptor))
|
||||
body.set('terreno', this.props.terreno)
|
||||
body.set('unidades', JSON.stringify(this.props.unidades))
|
||||
body.set('terreno', this.props.detalle.terreno)
|
||||
body.set('unidades', JSON.stringify(this.props.unidades.map(unidad => {
|
||||
return {unidad_id: unidad.unidad.props.id, precio: unidad.precio, prorrateo: unidad.prorrateo}
|
||||
})))
|
||||
body.set('fecha', [this.props.fecha.getFullYear(), this.props.fecha.getMonth()+1, this.props.fecha.getDate()].join('-'))
|
||||
body.set('detalle', JSON.stringify(this.props.detalle))
|
||||
body.set('total', JSON.stringify(this.props.total))
|
||||
body.set('uf', JSON.stringify(this.props.uf))
|
||||
body.set('uf', JSON.stringify({fecha: [this.props.uf.fecha.getFullYear(), this.props.uf.fecha.getMonth()+1, this.props.uf.fecha.getDate()].join('-'), valor: this.props.uf.valor}))
|
||||
return APIClient.fetch(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
@ -345,10 +347,11 @@
|
||||
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.detalle.total = venta.props.valor * this.props.proporcion * venta.props.uf.valor
|
||||
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.descuento = venta.prorrateo * this.props.proporcion
|
||||
},
|
||||
detalle: terreno => {
|
||||
@ -360,7 +363,6 @@
|
||||
},
|
||||
unidades: unidades => {
|
||||
this.props.unidades = []
|
||||
let neto = 0
|
||||
unidades.forEach(unidad => {
|
||||
this.props.unidades.push({
|
||||
unidad: unidad,
|
||||
@ -368,9 +370,7 @@
|
||||
precio: unidad.props.valor * this.props.uf.valor * this.props.proporcion,
|
||||
prorrateo: unidad.props.prorrateo * this.props.proporcion
|
||||
})
|
||||
neto += unidad.props.valor
|
||||
})
|
||||
this.props.total.neto = neto
|
||||
},
|
||||
propietario: propietario => {
|
||||
this.props.proporcion = propietario.props.proporcion
|
||||
|
Reference in New Issue
Block a user