import gr.grnet.aquarium.actor.message.GetUserWalletResponseData
import gr.grnet.aquarium.actor.message.config.AquariumPropertiesLoaded
import gr.grnet.aquarium.actor.message.config.InitializeUserActorState
-import gr.grnet.aquarium.charging.bill.AbstractBillEntry
import gr.grnet.aquarium.charging.state.{UserStateModel, UserAgreementHistoryModel, UserStateBootstrap}
import gr.grnet.aquarium.computation.BillingMonthInfo
import gr.grnet.aquarium.message.avro.gen.{IMEventMsg, ResourceEventMsg, UserStateMsg}
import gr.grnet.aquarium.service.event.BalanceEvent
import gr.grnet.aquarium.util.date.TimeHelpers
import gr.grnet.aquarium.util.{LogHelpers, shortClassNameOf}
+import gr.grnet.aquarium.policy.{ResourceType, PolicyModel}
+import gr.grnet.aquarium.charging.bill.BillEntryMsg
/**
*
val eventMonth = eventBillingMonthInfo.month
def computeBatch(): Unit = {
- DEBUG("Going for out of sync charging")
+ DEBUG("Going for out of sync charging for %s", rcEvent.getOriginalID)
this._userState = chargingService.replayMonthChargingUpTo(
nowBillingMonthInfo,
// Take into account that the event may be out-of-sync.
}
def computeRealtime(): Unit = {
- DEBUG("Going for in sync charging")
+ DEBUG("Going for in sync charging for %s", rcEvent.getOriginalID)
chargingService.processResourceEvent(
rcEvent,
this._userState,
def onGetUserBillRequest(event: GetUserBillRequest): Unit = {
try{
val timeslot = event.timeslot
+ val resourceTypes = aquarium.policyStore.
+ loadSortedPolicyModelsWithin(timeslot.from.getTime,
+ timeslot.to.getTime).
+ values.headOption match {
+ case None => Map[String,ResourceType]()
+ case Some(policy:PolicyModel) => policy.resourceTypesMap
+ }
val state= if(haveUserState) Some(this._userState.msg) else None
- val billEntry = AbstractBillEntry.fromWorkingUserState(timeslot,this._userID,state)
- val billData = GetUserBillResponseData(this._userID,billEntry)
+ val billEntryMsg = BillEntryMsg.fromWorkingUserState(timeslot,this._userID,state,resourceTypes)
+ //val billEntryMsg = MessageFactory.createBillEntryMsg(billEntry)
+ //logger.debug("BILL ENTRY MSG: " + billEntryMsg.toString)
+ val billData = GetUserBillResponseData(this._userID,billEntryMsg)
sender ! GetUserBillResponse(Right(billData))
} catch {
case e:Exception =>