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 _buildModuleData(self, module, isInstalledInSlot, stats):
     itemPrice = module.buyPrices.itemPrice
     inInventory = module.isInInventory
     isInstalled = module.isInstalled(self._vehicle)
     isBought = inInventory or isInstalled
     reason = ''
     if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE and not isInstalled and module.hasSimilarDevicesInstalled(
             self._vehicle):
         isFit, reason = False, GUI_ITEM_ECONOMY_CODE.ITEM_IS_DUPLICATED
     elif isBought:
         isFit, reason = module.mayInstall(self._vehicle, self._slotIndex)
         if reason == 'already installed' or isFit:
             isFit, reason = True, GUI_ITEM_ECONOMY_CODE.UNDEFINED
     else:
         isFit, reason = module.mayPurchase(stats['money'])
         if not isFit:
             if GUI_ITEM_ECONOMY_CODE.isMoneyError(reason):
                 isFit = module.mayPurchaseWithExchange(
                     stats['money'], stats['exchangeRate'])
     if isFit and reason != GUI_ITEM_ECONOMY_CODE.UNLOCK_ERROR:
         reason = _getInstallReason(module, self._vehicle, reason,
                                    self._slotIndex)
     moduleData = self._buildCommonModuleData(module, reason)
     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