Beispiel #1
0
class EditBookie(QWidget):
    def __init__(self, mainWindows, id):
        QWidget.__init__(self)
        uic.loadUi(directory + "/../ui/new_bookie.ui", self)
        self.mainWindows = mainWindows
        self.btnAccept.clicked.connect(self.accept)
        self.btnCancel.clicked.connect(self.cancel)
        self.mainWindows.setWindowTitle("Modificar Casa | Betcon v" +
                                        mainWindows.version)
        self.txtName.returnPressed.connect(self.btnAccept.click)

        self.item = Bookie()
        self.item.setId(id)

        self.initData()

    def initData(self):
        self.txtName.setText(self.item.name)

    def close(self):
        self.mainWindows.setCentralWidget(Bookies(self.mainWindows))

    def cancel(self):
        self.close()

    def accept(self):
        self.item.setName(self.txtName.text())
        err = self.item.update()

        if err == 0:
            QMessageBox.information(self, "Actualizada", "Casa actualizada.")
        else:
            QMessageBox.critical(self, "Error", str(err))

        self.close()
Beispiel #2
0
    def initTree(self):

        self.treeBookie.clear()
        data = Bookie.selectAll()

        items = []
        for i in data:
            bank = Bookie.sumAll("bookie=" + str(i.id))
            bank = 0.0 if bank is None else bank
            bonus = Bookie.sumBonus("bookie=" + str(i.id))
            bonus = 0.0 if bonus is None else bonus
            bank += bonus
            if 0.01 > bank > -0.01:
                continue
            item = QTreeWidgetItem(
                [i.name, "{0:.2f}".format(bank) + self.coin])
            items.append(item)

        self.treeBookie.addTopLevelItems(items)

        self.treeMovement.clear()

        bd = Bbdd()
        data = bd.select("movement", "date DESC")

        items = []
        for i in data:
            id = i[0]
            try:
                sDate = datetime.strptime(i[1], "%d/%m/%y")
            except:
                sDate = datetime.strptime(i[1], "%d/%m/%Y")  # Fix for Windows
            sDate = date.strftime(sDate, "%Y/%m/%d")
            account = i[2]
            if account == 1:
                account = "Banco"
            elif account == 2:
                account = "Paypal"
            elif account == 3:
                account = "Skrill"
            bookie = bd.getValue(i[3], "bookie")
            money = i[4]
            if money < 0:
                type = _("Withdrawal to the bank.")
            else:
                type = _("Deposit at bookie")

            item = QTreeWidgetItem([
                str(sDate),
                str(id), bookie, type,
                str(account),
                str(money) + self.coin
            ])

            items.append(item)

        self.treeMovement.addTopLevelItems(items)

        bd.close()
Beispiel #3
0
        def _process(self):
            self.msg = self._receive(True)

            if self.msg:
                request = json.loads(self.msg.content)
                if request['request_type'] == 'games':
                    bookie = Bookie()
                    self.send_message(
                        json.dumps({
                            'request_type': 'games',
                            'data': bookie.get_games()
                        }))

                if request['request_type'] == 'bet':
                    bookie = Bookie()
                    data = bookie.make_random_evaluation(
                        request['number_of_teams'])
                    self.send_message(
                        json.dumps({
                            'request_type': 'game_evaluation',
                            'data': data
                        }))

                if request['request_type'] == 'team_selection':
                    bookie = Bookie()
                    data = bookie.make_evaluation(request['teams'])
                    self.send_message(
                        json.dumps({
                            'request_type': 'game_evaluation',
                            'data': data
                        }))

                else:
                    pass
Beispiel #4
0
    def accept(self):

        bookie = Bookie()
        bookie.setAll(self.txtName.text(), self.txtCountry.text())
        err = bookie.insert()

        if err == 0:
            QMessageBox.information(self, _("Added"), _("New bookie added."))
        else:
            QMessageBox.critical(self, _("Error"), str(err))

        self.close()
Beispiel #5
0
	def deleteItem(self):
		resultado = QMessageBox.question(self, "Eliminar", "¿Estas seguro que desas eliminar la casa y las apuestas asociadas?",
										 QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
		if resultado == QMessageBox.Yes:
			err = Bookie.delete(self.itemSelected)
			Bookie.deleteWhere("bet", "bookie=" + str(self.itemSelected))
			Bookie.deleteWhere("bonus", "bookie=" + str(self.itemSelected))
			if err != 0:
				QMessageBox.critical(self, "Error", "Se ha producido un error al borrar la casa")

			self.mainWindows.setCentralWidget(Bookies(self.mainWindows))
			self.mainWindows.enableTools()
Beispiel #6
0
    def accept(self):

        bookie = Bookie()
        bookie.setAll(self.txtName.text())
        err = bookie.insert()

        if err == 0:
            QMessageBox.information(self, "Añadida", "Nueva casa añadida.")
        else:
            QMessageBox.critical(self, "Error", str(err))

        self.close()
Beispiel #7
0
    def __init__(self, mainWindows, id):
        QWidget.__init__(self)
        uic.loadUi(directory + "/../ui/new_bookie.ui", self)
        self.mainWindows = mainWindows
        self.btnAccept.clicked.connect(self.accept)
        self.btnCancel.clicked.connect(self.cancel)
        self.mainWindows.setWindowTitle("Modificar Casa | Betcon v" +
                                        mainWindows.version)
        self.txtName.returnPressed.connect(self.btnAccept.click)

        self.item = Bookie()
        self.item.setId(id)

        self.initData()
Beispiel #8
0
    def deleteItem(self):
        resultado = QMessageBox.question(
            self, _("Remove"),
            _("Are you sure you want to eliminate the bookie and the associated bets?"
              ), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if resultado == QMessageBox.Yes:
            err = Bookie.delete(self.itemSelected)
            Bookie.deleteWhere("bet", "bookie=" + str(self.itemSelected))
            Bookie.deleteWhere("bonus", "bookie=" + str(self.itemSelected))
            if err != 0:
                QMessageBox.critical(
                    self, _("Error"),
                    _("There was an error deleting the house"))

            self.mainWindows.setCentralWidget(Bookies(self.mainWindows))
            self.mainWindows.enableTools()
Beispiel #9
0
    def __init__(self, mainWindows, id):
        QWidget.__init__(self)
        uic.loadUi(directory + "/../ui/new_bookie.ui", self)
        gettext.textdomain("betcon")
        gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang)
        gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang)
        self.mainWindows = mainWindows
        self.btnAccept.clicked.connect(self.accept)
        self.btnCancel.clicked.connect(self.cancel)
        self.mainWindows.setWindowTitle(_("Modify Bookie") + " | Betcon v" + mainWindows.version)
        self.txtName.returnPressed.connect(self.btnAccept.click)

        self.item = Bookie()
        self.item.setId(id)
        self.btnBrowse.clicked.connect(self.browseImage)

        self.initData()
        NewBookie.translate(self)
Beispiel #10
0
class EditBookie(QWidget):
    def __init__(self, mainWindows, id):
        QWidget.__init__(self)
        uic.loadUi(directory + "/../ui/new_bookie.ui", self)
        gettext.textdomain("betcon")
        gettext.bindtextdomain("betcon", "../lang/mo" + mainWindows.lang)
        gettext.bindtextdomain("betcon", "/usr/share/locale" + mainWindows.lang)
        self.mainWindows = mainWindows
        self.btnAccept.clicked.connect(self.accept)
        self.btnCancel.clicked.connect(self.cancel)
        self.mainWindows.setWindowTitle(_("Modify Bookie") + " | Betcon v" + mainWindows.version)
        self.txtName.returnPressed.connect(self.btnAccept.click)

        self.item = Bookie()
        self.item.setId(id)
        self.btnBrowse.clicked.connect(self.browseImage)

        self.initData()
        NewBookie.translate(self)

    def initData(self):
        self.txtName.setText(self.item.name)
        self.txtCountry.setText(self.item.country)

    def browseImage(self):
            file = QFileDialog.getOpenFileName(None, _("Image of the bookie"), expanduser("~/"), "*.png")
            if file[0] != '':
                ruta = file[0]
                self.item.setRuta(ruta)
                self.lblBrowse.setText(ruta)

    def close(self):
            self.mainWindows.setCentralWidget(Bookies(self.mainWindows))

    def cancel(self):
        self.close()

    def accept(self):
        self.item.setName(self.txtName.text())
        self.item.setCountry(self.txtCountry.text())
        err = self.item.update()

        if err == 0:
            QMessageBox.information(self, _("Updated"), _("Updated bookie."))
        else:
            QMessageBox.critical(self, _("Error"), str(err))

        self.close()
Beispiel #11
0
    def initTree(self):
        data = Bookie.selectAll()

        items = []
        for i in data:
            item = QTreeWidgetItem([i.name, str(i.id), i.country])
            items.append(item)

        self.treeMain.addTopLevelItems(items)
        self.treeMain.sortByColumn(0, QtCore.Qt.AscendingOrder)
Beispiel #12
0
    def initData(self):
        self.txtDeposit.setText("{0:.2f}".format(Bookie.sumAll("money>0")) +
                                self.coin)
        self.txtTakeOut.setText("{0:.2f}".format(Bookie.sumAll("money<0")) +
                                self.coin)
        bookies = Bookie.sumAll()
        bonus = Bookie.sumBonus()
        self.txtBonus.setText("{0:.2f}".format(bonus) + self.coin)
        self.txtBookie.setText("{0:.2f}".format(bookies + bonus) + self.coin)

        bd = Bbdd()

        tipsters = bd.sum("tipster_month", "money")
        conjuntas = bd.sum("conjunta", "money")
        self.txtTipster.setText("-" + str(tipsters + conjuntas) + self.coin)
        profits = bd.sum("bet", "profit") + bonus
        self.txtProfit.setText("{0:.2f}".format(profits - tipsters -
                                                conjuntas) + self.coin)
        bets = bd.sum("bet", "bet")
        try:
            yields = "{0:.2f}%".format((profits / bets) * 100)
        except ZeroDivisionError:
            yields = "0.0%"
        self.txtYield.setText(yields)

        # CC
        cc = bd.select("bank", None, "id=1", "bank")
        cc = cc[0][0]
        self.txtCc.setText("{0:.2f}".format(cc) + self.coin)

        # Paypal
        paypal = bd.select("bank", None, "id=2", "bank")
        paypal = paypal[0][0]
        self.txtPaypal.setText("{0:.2f}".format(paypal) + self.coin)

        # SKRILL
        skrill = bd.select("bank", None, "id=3", "bank")
        skrill = skrill[0][0]
        self.txtSkrill.setText("{0:.2f}".format(skrill) + self.coin)

        total = "{0:.2f}".format(cc + paypal + skrill + bonus + bookies)
        self.txtTotal.setText(total + self.coin)
Beispiel #13
0
	def calcBank(self):
		bd = Bbdd()
		bookies = Bookie.sumAll()
		bonus = Bookie.sumBonus()

		# CC
		cc = bd.select("bank", None, "id=1", "bank")
		cc = cc[0][0]

		# Paypal
		paypal = bd.select("bank", None, "id=2", "bank")
		paypal = paypal[0][0]

		# SKRILL
		skrill = bd.select("bank", None, "id=3", "bank")
		skrill = skrill[0][0]

		total = "{0:.2f}".format(cc + paypal + skrill + bonus + bookies)
		total = float(total) * (self.txtPercentage.value() * 0.01)
		self.txtStake.setValue(float(total))
Beispiel #14
0
	def initTree(self):
		data = Bookie.selectAll()

		index = 0
		items = []
		for i in data:
			index += 1
			item = QTreeWidgetItem([str(index), str(i.id), i.name])
			items.append(item)

		self.treeMain.addTopLevelItems(items)
Beispiel #15
0
    def calcStake(self):
        self.config = LibYaml()
        if self.config.stake["type"] == 0:
            bd = Bbdd()
            bookies = Bookie.sumAll()
            bonus = Bookie.sumBonus()

            # CC
            cc = bd.select("bank", None, "id=1", "bank")
            cc = cc[0][0]

            # Paypal
            paypal = bd.select("bank", None, "id=2", "bank")
            paypal = paypal[0][0]

            # SKRILL
            skrill = bd.select("bank", None, "id=3", "bank")
            skrill = skrill[0][0]

            total = "{0:.2f}".format(cc + paypal + skrill + bonus + bookies)
            total = float(total) * (self.config.stake["percentage"] * 0.01)
            self.txtOne.setValue(float(total))
        else:
            self.txtOne.setValue(self.config.stake["stake"])
Beispiel #16
0
    def getMonth(year=None, month=None, day=None):
        date = str(year)
        if month is not None and month is not "":
            date += "-" + str(month)
        if day is not None and day is not "":
            date += "-" + day
        sql = 'select SUM(bet), ' \
           '(select SUM(profit) from bet as b1 WHERE profit>0 AND b1.date LIKE "' + date + '%"), ' \
           '(select SUM(profit) from bet as b1 WHERE profit<0 AND b1.date LIKE "' + date + '%"), ' \
           'SUM(profit), (select SUM(bet) from bet as b1 WHERE b1.result=0 AND bet.date LIKE "' + date + '%"), ' \
           'AVG(quota), count(bet), (select COUNT(*) from bet as b1 WHERE profit>0 AND b1.date LIKE "' + date + '%"), ' \
           '(select count(*) from bet as b1 WHERE profit<0 AND b1.result<>0 AND b1.date LIKE "' + date + '%"),' \
           '(select count(*) from bet as b1 WHERE profit=0 AND b1.date LIKE "' + date + '%"), AVG(bet)' \
           ' from bet WHERE bet.date LIKE "' + date + '%"'

        bd = Bbdd()
        datasql = bd.executeQuery(sql)
        bd.close()
        bonus = Bookie.sumBonus("date LIKE '" + date + "%'")
        datasql = datasql[0]
        if bonus is None:
            bonus = 0

        if datasql[0] == 0:
            return [0, 0, 0, 0, 0, "0%", 0, 0, 0, 0, 0, "0%", 0]
        yi = "{0:.2f}%".format(
            round(((datasql[3] + bonus) / datasql[0]) * 100, 2))
        quota = float("{0:.2f}".format(datasql[5], 2))
        bet = float("{0:.2f}".format(datasql[10], 2))

        aciertos = "{0:.2f}%".format(round((datasql[7] / datasql[6]) * 100, 2))
        data0 = "{0:.2f}".format(round(datasql[0], 2))
        data1 = 0.0 if datasql[1] is None else "{0:.2f}".format(
            round(datasql[1] + bonus, 2))
        data2 = 0.0 if datasql[2] is None else "{0:.2f}".format(
            round(datasql[2], 2))
        data3 = 0.0 if datasql[3] is None else "{0:.2f}".format(
            round(datasql[3] + bonus, 2))
        data4 = 0.0 if datasql[4] is None else "{0:.2f}".format(
            round(datasql[4], 2))
        data = [
            data0, data1, data2, data3, data4, yi, quota, datasql[6],
            datasql[7], datasql[8], datasql[9], aciertos, bet
        ]

        return data
Beispiel #17
0
        def _process(self):
            self.msg = self._receive(True)

            if self.msg:
                request = json.loads(self.msg.content)
                if request['request_type'] == 'games':
                    bookie = Bookie()
                    self.send_message(json.dumps({'request_type': 'games', 'data': bookie.get_games()}))

                if request['request_type'] == 'bet':
                    bookie = Bookie()
                    data = bookie.make_random_evaluation(request['number_of_teams'])
                    self.send_message(json.dumps({'request_type': 'game_evaluation', 'data': data}))

                if request['request_type'] == 'team_selection':
                    bookie = Bookie()
                    data = bookie.make_evaluation(request['teams'])
                    self.send_message(json.dumps({'request_type': 'game_evaluation', 'data': data}))

                else:
                    pass