diff --git a/js/components/clin_fields.js b/js/components/clin_fields.js index a719fa6e..b0805229 100644 --- a/js/components/clin_fields.js +++ b/js/components/clin_fields.js @@ -37,6 +37,7 @@ export default { indexOffset: this.initialLoaCount, loas: loas, clinType: this.initialClinType, + amount: this.initialAmount || 0, } }, @@ -61,17 +62,22 @@ export default { return index + this.indexOffset - 1 }, + clinChangeEvent: function() { + emitEvent('clin-change', this, { + id: this._uid, + clinType: this.clinType, + amount: this.amount, + }) + }, + handleFieldChange: function(event) { if (this._uid === event.parent_uid) { if (event.name.includes(JEDI_CLIN_TYPE)) { this.clinType = event.value - } - else if (event.name.includes(OBLIGATED_AMOUNT)) { - emitEvent('clin-change', this, { - id: this._uid, - clinType: this.clinType, - amount: parseFloat(event.value), - }) + this.clinChangeEvent() + } else if (event.name.includes(OBLIGATED_AMOUNT)) { + this.amount = parseFloat(event.value) + this.clinChangeEvent() } } }, diff --git a/js/components/forms/to_form.js b/js/components/forms/to_form.js index f210fff2..e6429226 100644 --- a/js/components/forms/to_form.js +++ b/js/components/forms/to_form.js @@ -61,14 +61,12 @@ export default { let newTotal = 0 let newObligated = 0 - Object.values(this.clinChildren).forEach( - function(clin) { - newTotal += clin.amount - if (clin.type.includes('1', '3')) { - newObligated += clin.amount - } + Object.values(this.clinChildren).forEach(function(clin) { + newTotal += clin.amount + if (clin.type.includes('1', '3')) { + newObligated += clin.amount } - ) + }) this.total = newTotal this.obligated = newObligated },