FIX: Actualizacion de IPC al cambiar fecha facturas
This commit is contained in:
@ -18,8 +18,6 @@
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.luxon')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class BaseObject {
|
||||
@ -355,10 +353,14 @@
|
||||
})
|
||||
},
|
||||
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[index].props.fecha = date
|
||||
})
|
||||
return this.update().ipc()
|
||||
},
|
||||
totalUnidades: () => {
|
||||
const unidades = this.props.unidades.reduce((sum, unidad) => sum + unidad.props.valor, 0)
|
||||
@ -402,18 +404,18 @@
|
||||
})
|
||||
},
|
||||
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 method = 'post'
|
||||
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('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 => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
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)
|
||||
cdo['initialDate'] = this.props.estado.fecha
|
||||
cdo['onChange'] = (date, text, mode) => {
|
||||
this.update().fechaFacturas(date)
|
||||
facturas.draw().facturas()
|
||||
this.update().fechaFacturas(date).then(() => {
|
||||
facturas.draw().facturas()
|
||||
})
|
||||
}
|
||||
$('#fecha_facturas').calendar(cdo)
|
||||
},
|
||||
|
Reference in New Issue
Block a user