package gr.grnet.aquarium.computation
-import scala.collection.mutable
import gr.grnet.aquarium.util.{ContextualLogger, Loggable}
+import gr.grnet.aquarium.util.shortClassNameOf
import gr.grnet.aquarium.util.date.{TimeHelpers, MutableDateCalc}
import gr.grnet.aquarium.logic.accounting.dsl.DSLResourcesMap
import gr.grnet.aquarium.computation.state.parts._
case Some(dslResource) ⇒
val costPolicy = dslResource.costPolicy
clog.debug("%s for %s", costPolicy, dslResource)
- val isBillable = costPolicy.isBillableEventBasedOnValue(theValue)
+ val isBillable = costPolicy.isBillableEvent(currentResourceEvent)
if(!isBillable) {
// The resource event is not billable
clog.debug("Ignoring not billable %s", currentResourceEventDebugInfo)
val newCreditsDiff = fullChargeslots.map(_.computedCredits.get).sum
val newCredits = oldCredits - newCreditsDiff
- if(stateChangeReason.shouldStoreCalculatedWalletEntries) {
- val newWalletEntry = NewWalletEntry(
- userStateWorker.userID,
- newCreditsDiff,
- oldCredits,
- newCredits,
- TimeHelpers.nowMillis(),
- referenceTimeslot,
- billingMonthInfo.year,
- billingMonthInfo.month,
- if(havePreviousResourceEvent)
- List(currentResourceEvent, previousResourceEventOpt1.get)
- else
- List(currentResourceEvent),
- fullChargeslots,
- dslResource,
- currentResourceEvent.isSynthetic
- )
- clog.debug("New %s", newWalletEntry)
-
- walletEntryRecorder.apply(newWalletEntry)
- } else {
- clog.debug("newCreditsDiff = %s, newCredits = %s", newCreditsDiff, newCredits)
- }
+ val newWalletEntry = NewWalletEntry(
+ userStateWorker.userID,
+ newCreditsDiff,
+ oldCredits,
+ newCredits,
+ TimeHelpers.nowMillis(),
+ referenceTimeslot,
+ billingMonthInfo.year,
+ billingMonthInfo.month,
+ if(havePreviousResourceEvent)
+ List(currentResourceEvent, previousResourceEventOpt1.get)
+ else
+ List(currentResourceEvent),
+ fullChargeslots,
+ dslResource,
+ currentResourceEvent.isSynthetic
+ )
+ clog.debug("%s = %s", shortClassNameOf(newWalletEntry), newWalletEntry)
+
+ walletEntryRecorder.apply(newWalletEntry)
_workingUserState = _workingUserState.copy(
totalCredits = newCredits,
// def shouldStoreUserState: Boolean =
// booleanFromDetails(UserStateChangeReason.Names.shouldStoreUserState, false)
- def shouldStoreCalculatedWalletEntries: Boolean =
- booleanFromDetails(UserStateChangeReason.Names.shouldStoreCalculatedWalletEntries, false)
+// def shouldStoreCalculatedWalletEntries: Boolean =
+// booleanFromDetails(UserStateChangeReason.Names.shouldStoreCalculatedWalletEntries, false)
def calculateCreditsForImplicitlyTerminated: Boolean =
booleanFromDetails(UserStateChangeReason.Names.calculateCreditsForImplicitlyTerminated, false)
final val imEvent = "imEvent"
final val forWhenMillis = "forWhenMillis"
- final val shouldStoreUserState = "shouldStoreUserState"
- final val shouldStoreCalculatedWalletEntries = "shouldStoreCalculatedWalletEntries"
+// final val shouldStoreUserState = "shouldStoreUserState"
+// final val shouldStoreCalculatedWalletEntries = "shouldStoreCalculatedWalletEntries"
final val calculateCreditsForImplicitlyTerminated = "calculateCreditsForImplicitlyTerminated"
}
}
Map(
UserStateChangeReason.Names.name -> name,
// UserStateChangeReason.Names.shouldStoreUserState -> true,
- UserStateChangeReason.Names.shouldStoreCalculatedWalletEntries -> true.toString,
+// UserStateChangeReason.Names.shouldStoreCalculatedWalletEntries -> true.toString,
UserStateChangeReason.Names.calculateCreditsForImplicitlyTerminated -> true.toString
),
Some(billingMongthInfo),