Fill payment when editing

This commit is contained in:
Juan Pablo Vial
2025-11-13 15:19:52 -03:00
parent a41f306d3f
commit c3a7e7636f

View File

@ -37,13 +37,13 @@
this.prefix = prefix this.prefix = prefix
this.ids = { this.ids = {
pie: { pie: {
checkbox: `${this.prefix}_has_pie`, checkbox: `${this.prefix}_payment_has_pie`,
value: `${this.prefix}_pie`, value: `${this.prefix}_payment_pie`,
installments: `${this.prefix}_cuotas` installments: `${this.prefix}_payment_cuotas`
}, },
credit: { credit: {
checkbox: `${this.prefix}_has_credit`, checkbox: `${this.prefix}_payment_has_credit`,
value: `${this.prefix}_credit` value: `${this.prefix}_payment_credit`
} }
} }
this.setup() this.setup()
@ -77,18 +77,24 @@
this.hide.credit() this.hide.credit()
} }
} }
fill(formaPago) { fill(payment) {
if ('pie' in formaPago && formaPago.pie !== null) { if ('pie' in payment && payment.pie !== null) {
this.components.pie.$checkbox.prop('checked', true) this.components.pie.$checkbox.prop('checked', true)
//this.show.pie() this.show.pie()
this.components.pie.value.value = formaPago.pie.valor this.components.pie.value.querySelector('input').value = payment.pie.valor
this.components.pie.installments.value = formaPago.pie.cuotas this.components.pie.installments.querySelector('input').value = payment.pie.cuotas
} }
if ('credito' in formaPago && formaPago.credito !== null) { if ('credito' in payment && payment.credito !== null) {
this.components.credit.$checkbox.prop('checked', true) this.components.credit.$checkbox.prop('checked', true)
//this.show.credit() this.show.credit()
this.components.credit.value.value = formaPago.credito.value this.components.credit.value.querySelector('input').value = payment.credito.valor
} }
/*if ('subsidio' in payment && payment.subsidio !== null) {
this.components.subsidio.$checkbox.prop('checked', true)
this.components.subsidio.subsidy.value.value = payment.subsidio.subsidio.valor
this.components.subsidio.savings.value.value = payment.subsidio.ahorro.valor
this.show.subsidio()
}*/
} }
setup() { setup() {
this.components.pie.$checkbox = $(`#${this.ids.pie.checkbox}`) this.components.pie.$checkbox = $(`#${this.ids.pie.checkbox}`)