Keep track of children CLINS to update amount

- emit CLIN amount and type when amount changes
- totals are added correctly based on CLIN type
This commit is contained in:
montana
2019-06-14 13:54:18 -04:00
parent c775c7322c
commit 23b7df2153
4 changed files with 48 additions and 17 deletions

View File

@@ -39,6 +39,7 @@ export default {
clinIndex,
obligated: this.initialObligated || 0,
total: this.initialTotal || 0,
clinChildren: {},
}
},
@@ -52,11 +53,24 @@ export default {
++this.clinIndex
},
calculateClinAmounts: function (event) {
this.total += parseFloat(event.amount - this.total)
if (event.clinType.includes('1') || event.clinType.includes('3')) {
this.obligated += parseFloat(event.amount - this.obligated)
calculateClinAmounts: function(event) {
this.clinChildren[event.id] = {
amount: event.amount,
type: event.clinType,
}
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
}
}
)
this.total = newTotal
this.obligated = newObligated
},
},