def _buildModuleData(self, vehicleModule, isInstalledInSlot, stats):
     itemPrice = vehicleModule.buyPrices.itemPrice
     inInventory = vehicleModule.isInInventory
     isInstalled = vehicleModule.isInstalled(self._vehicle)
     isBought = inInventory or isInstalled
     isEnoughMoney, purchaseReason = vehicleModule.mayPurchase(stats['money'])
     if isBought:
         isFit, reason = vehicleModule.mayInstall(self._vehicle, self._slotIndex)
         if reason == 'already installed' or isFit:
             isFit, reason = True, GUI_ITEM_ECONOMY_CODE.UNDEFINED
     else:
         isFit, reason = isEnoughMoney, purchaseReason
         if not isFit:
             if GUI_ITEM_ECONOMY_CODE.isCurrencyError(reason):
                 isFit = vehicleModule.mayPurchaseWithExchange(stats['money'], stats['exchangeRate'])
     if reason != GUI_ITEM_ECONOMY_CODE.UNLOCK_ERROR:
         installReason = _getInstallReason(vehicleModule, self._vehicle, reason, self._slotIndex)
     else:
         installReason = reason
     self._checkCounters(vehicleModule)
     moduleData = self._buildCommonModuleData(vehicleModule, installReason)
     moduleData.update({'targetVisible': isBought,
      'showPrice': not isBought,
      'isSelected': isInstalledInSlot,
      'disabled': not isFit or isInstalled and not isInstalledInSlot,
      'removeButtonLabel': MENU.MODULEFITS_REMOVENAME,
      'removeButtonTooltip': MENU.MODULEFITS_REMOVETOOLTIP,
      'itemPrices': getItemPricesVOWithReason(reason, itemPrice)})
     return moduleData
def _getInstallReason(module, vehicle, reason, slotIdx=None):
    _, installReason = module.mayInstall(vehicle, slotIdx)
    return installReason or reason if GUI_ITEM_ECONOMY_CODE.isCurrencyError(reason) else installReason