FIX: Fechas revisadas.

This commit is contained in:
Juan Pablo Vial
2025-02-24 14:02:12 -03:00
parent 8b386b8b44
commit 7b63cbc757
3 changed files with 63 additions and 34 deletions

View File

@ -251,12 +251,21 @@
event.preventDefault()
const url = '{{$urls->api}}/venta/{{$venta->id}}/escriturar'
const body = new FormData(event.currentTarget)
body.set('fecha', $('#fecha').calendar('get date').toISOString())
if (body.get('fecha_pago') !== '') {
body.set('fecha_pago', $('#fecha_pago').calendar('get date').toISOString())
const fecha = $('#fecha').calendar('get date')
body.set('fecha', [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-'))
const $fechaPago = $('#fecha_pago')
if ($fechaPago.length > 0) {
const fechaPago = $fechaPago.calendar('get date')
if (fechaPago !== null) {
body.set('fecha_pago', [fechaPago.getFullYear(), fechaPago.getMonth()+1, fechaPago.getDate()].join('-'))
}
}
if (body.get('fecha_reajuste') !== '') {
body.set('fecha_reajuste', $('#fecha_reajuste').calendar('get date').toISOString())
const $fechaReajuste = $('#fecha_reajuste')
if ($fechaReajuste.length > 0) {
const fechaReajuste = $fechaReajuste.calendar('get date')
if (fechaReajuste !== null) {
body.set('fecha_reajuste', [fechaReajuste.getFullYear(), fechaReajuste.getMonth()+1, fechaReajuste.getDate()].join('-'))
}
}
fetchAPI(url, {method: 'post', body}).then(response => {
if (response.ok) {