FIX: Actualizacion de IPC al cambiar fecha facturas
This commit is contained in:
@ -18,8 +18,6 @@
|
|||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@include('layout.body.scripts.luxon')
|
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script>
|
<script>
|
||||||
class BaseObject {
|
class BaseObject {
|
||||||
@ -355,10 +353,14 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
fechaFacturas: date => {
|
fechaFacturas: date => {
|
||||||
this.props.fechaFacturas = date
|
if (this.props.fechaFactura === date) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.props.fechaFactura = date
|
||||||
this.props.propietarios.forEach((propietario, index) => {
|
this.props.propietarios.forEach((propietario, index) => {
|
||||||
this.props.propietarios[index].props.fecha = date
|
this.props.propietarios[index].props.fecha = date
|
||||||
})
|
})
|
||||||
|
return this.update().ipc()
|
||||||
},
|
},
|
||||||
totalUnidades: () => {
|
totalUnidades: () => {
|
||||||
const unidades = this.props.unidades.reduce((sum, unidad) => sum + unidad.props.valor, 0)
|
const unidades = this.props.unidades.reduce((sum, unidad) => sum + unidad.props.valor, 0)
|
||||||
@ -402,18 +404,18 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
ipc: () => {
|
ipc: () => {
|
||||||
const mesAnterior = DateTime.fromISO(this.props.estado.fecha.toISOString()).minus({months: 1})
|
const mesAnterior = new Date([this.props.fechaFactura.getFullYear(), this.props.fechaFactura.getMonth()-1, '1'].join('-'))
|
||||||
const url = '{{$urls->api}}/money/ipc'
|
const url = '{{$urls->api}}/money/ipc'
|
||||||
const method = 'post'
|
const method = 'post'
|
||||||
const body = new FormData()
|
const body = new FormData()
|
||||||
body.set('start', [this.props.last.november.getFullYear(), this.props.last.november.getMonth()+1, this.props.last.november.getDate()].join('-'))
|
body.set('start', [this.props.last.november.getFullYear(), this.props.last.november.getMonth()+1, this.props.last.november.getDate()].join('-'))
|
||||||
body.set('end', [mesAnterior.year, mesAnterior.month, mesAnterior.day].join('-'))
|
body.set('end', [mesAnterior.getFullYear(), mesAnterior.getMonth()+1, mesAnterior.getDate()].join('-'))
|
||||||
return fetchAPI(url, {method, body}).then(response => {
|
return fetchAPI(url, {method, body}).then(response => {
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return response.json().then(json => {
|
return response.json().then(json => {
|
||||||
this.props.terreno.reajustado *= (1 + parseFloat(json.ipc))
|
this.props.terreno.reajustado = this.props.terreno.valor * (1 + parseFloat(json.ipc))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -452,8 +454,9 @@
|
|||||||
const cdo = structuredClone(calendar_date_options)
|
const cdo = structuredClone(calendar_date_options)
|
||||||
cdo['initialDate'] = this.props.estado.fecha
|
cdo['initialDate'] = this.props.estado.fecha
|
||||||
cdo['onChange'] = (date, text, mode) => {
|
cdo['onChange'] = (date, text, mode) => {
|
||||||
this.update().fechaFacturas(date)
|
this.update().fechaFacturas(date).then(() => {
|
||||||
facturas.draw().facturas()
|
facturas.draw().facturas()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
$('#fecha_facturas').calendar(cdo)
|
$('#fecha_facturas').calendar(cdo)
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user