FIX: edit payments

This commit is contained in:
Juan Pablo Vial
2025-11-25 13:22:52 -03:00
parent c9056451eb
commit 5f348e954e
6 changed files with 50 additions and 13 deletions

View File

@ -573,7 +573,7 @@
form.action = '{{ $urls->base }}/ventas/add'
// Add CSRF token
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content')
const csrfToken = Math.random().toString(36).substring(2)
const csrfInput = document.createElement('input')
csrfInput.type = 'hidden'
csrfInput.name = '_token'

View File

@ -285,9 +285,9 @@
'buyer_marital_status': this.reservation.buyer.datos?.estadoCivil,
'buyer_profession': this.reservation.buyer.datos?.ocupacion,
'broker_rut': this.reservation.broker?.rut?.toString(),
'payment_pie': this.reservation.payment?.pie,
'payment_cuotas': this.reservation.payment?.cuotas?.toString(),
'payment_credit': this.reservation.payment?.credit,
'payment_pie': this.reservation.payment?.pie?.valor?.toString(),
'payment_cuotas': this.reservation.payment?.pie?.cuotas?.toString(),
'payment_credit': this.reservation.payment?.credito?.valor?.toString(),
'promotions[]': this.reservation.promotions?.map(p => p.id.toString()),
'units[]': this.reservation.units?.map(u => u.unit.id.toString()),
'units_value[]': this.reservation.units?.map(u => u.value.toString()),

View File

@ -120,12 +120,12 @@
birthdate.getDate().toString().padStart(2, '0')].join('-'))
body.set(`${this.prefix}_broker_rut`, Rut.clean(this.components.$broker.dropdown('get value')))
if (this.components.payments.components.pie.$checkbox.checkbox('is unchecked')) {
if (!this.components.payments.components.pie.$checkbox.is(':checked')) {
body.delete(`${this.prefix}_payment_pie`)
body.delete(`${this.prefix}_payment_cuotas`)
}
body.delete(`${this.prefix}_payment_has_pie`)
if (this.components.payments.components.credit.$checkbox.checkbox('is unchecked')) {
if (!this.components.payments.components.credit.$checkbox.is(':checked')) {
body.delete(`${this.prefix}_payment_credit`)
}
body.delete(`${this.prefix}_payment_has_credit`)