|
|
|
|
@ -160,7 +160,10 @@ class HHBuilder { |
|
|
|
|
|
|
|
|
|
when (actionType) { |
|
|
|
|
Action.Type.CALL -> { |
|
|
|
|
val significantAmount = getLastSignificantAction(index)?.action?.amount ?: throw PAIllegalStateException("Cannot happen") |
|
|
|
|
val significantAction = getLastSignificantAction(index) |
|
|
|
|
?: throw PAIllegalStateException("There must be a previously set significant action for a call to be set") |
|
|
|
|
val significantAmount = significantAction.action.amount |
|
|
|
|
?: throw PAIllegalStateException("There must be a set amount on the action for the call to be set") |
|
|
|
|
val committedAmount = getPreviousCommittedAmount(index) ?: 0.0 |
|
|
|
|
computedAction.setEffectiveAmount(significantAmount - committedAmount) |
|
|
|
|
} |
|
|
|
|
@ -181,8 +184,8 @@ class HHBuilder { |
|
|
|
|
* We want drop all non-auto added rows after the index |
|
|
|
|
*/ |
|
|
|
|
private fun dropNextActionsIfNecessary(index: Int) { |
|
|
|
|
val dropIndex = index + 1 // TODO determine dropIndex |
|
|
|
|
this.sortedActions.drop(dropIndex) |
|
|
|
|
// val dropIndex = index + 1 // TODO determine dropIndex |
|
|
|
|
// this.sortedActions = this.sortedActions.take(dropIndex) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
@ -235,7 +238,7 @@ class HHBuilder { |
|
|
|
|
val position = action.position |
|
|
|
|
val street = action.street |
|
|
|
|
|
|
|
|
|
val previousActions = this.sortedActions.drop(index) |
|
|
|
|
val previousActions = this.sortedActions.take(index) |
|
|
|
|
val previousComputedAction = previousActions.lastOrNull { |
|
|
|
|
it.action.position == position && it.action.street == street |
|
|
|
|
} |
|
|
|
|
@ -257,7 +260,9 @@ class HHBuilder { |
|
|
|
|
*/ |
|
|
|
|
private fun getLastUserAction(index: Int): ComputedAction? { |
|
|
|
|
val action = this.actionForIndex(index).action |
|
|
|
|
val previousActions = this.sortedActions.drop(index) |
|
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
|
val previousActions = this.sortedActions.take(index) |
|
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
|
return previousActions.lastOrNull { it.action.position == action.position } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -265,7 +270,9 @@ class HHBuilder { |
|
|
|
|
* Returns the last significant player action, if any, for the action at the provided [index] |
|
|
|
|
*/ |
|
|
|
|
private fun getLastSignificantAction(index: Int): ComputedAction? { |
|
|
|
|
val previousActions = this.sortedActions.drop(index) |
|
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
|
val previousActions = this.sortedActions.take(index) |
|
|
|
|
Timber.d("**** this.sortedActions.size = ${this.sortedActions.size}") |
|
|
|
|
return previousActions.lastOrNull { it.action.isActionSignificant } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|