Пример #1
0
    def createLayout(self, item):
        layout = QFormLayout()

        types = QGroupBox("Tipo", self)
        self.bank = QRadioButton("Banco")
        self.bank.setChecked(True)
        self.card = QRadioButton("Cartão de Crédito")
        self.broker = QRadioButton("Corretora")
        hbox = QHBoxLayout()
        hbox.addWidget(self.bank)
        hbox.addWidget(self.card)
        hbox.addWidget(self.broker)
        types.setLayout(hbox)
        layout.addRow(types)

        self.name = QLineEdit()
        self.name.textChanged.connect(self.enableButton)
        self.name.setMaxLength(20)
        layout.addRow("Nome", self.name)

        self.limit = QDoubleSpinBox()
        self.limit.setPrefix("R$ ")
        self.limit.setDecimals(2)
        self.limit.setSingleStep(100)
        self.limit.setRange(0, 100000000)
        self.broker.toggled.connect(lambda: self.limit.setEnabled(not self.broker.isChecked()))
        layout.addRow("Limite", self.limit)

        self.expiration = QSpinBox()
        self.expiration.setPrefix("Dia ")
        self.expiration.setRange(1, 31)
        self.expiration.setEnabled(False)
        self.card.toggled.connect(lambda: self.expiration.setEnabled(self.card.isChecked()))
        layout.addRow("Vencimento da fatura", self.expiration)

        sublayout = QHBoxLayout()
        self.ok = QPushButton("Adicionar")
        self.ok.clicked.connect(self.accept)
        self.ok.setEnabled(False)
        cancel = QPushButton("Cancelar")
        cancel.clicked.connect(self.reject)
        sublayout.addWidget(self.ok)
        sublayout.addWidget(cancel)
        layout.addRow(sublayout)

        if item:
            self.name.setText(item.text(0))
            account = DATABASE.getAccounts(True, item.text(0))
            self.limit.setValue(account[2])
            if account[1] == BANK:
                self.bank.setChecked(True)
            elif account[1] == CARD:
                self.card.setChecked(True)
            else:
                self.broker.setChecked(True)
            if account[3]:
                self.expiration.setValue(account[3])
            self.ok.setText("Editar")

        self.setLayout(layout)
Пример #2
0
 def deleteItems(self):
     items = DATABASE.getAccounts()
     dialog = DeleteDialog(self, "Deletar Contas", "del-inst.png",
                           ["Conta", "Transações"], items)
     result = dialog.exec_()
     if result:
         dialog.process(_type=ACCOUNT)
         self.mainWindow.loadInfo()
Пример #3
0
 def attPeriod(self, index):
     info = DATABASE.getAccounts(name=self.account.itemText(index), info=True)
     currentDate = QDate.currentDate()
     if info[3]:
         currentDate.setDate(currentDate.year(), currentDate.month() - 1, info[3] + 1)
         self.period1.setDate(currentDate.addDays(-10))
         self.period2.setDate(currentDate.addMonths(1).addDays(-11))
         self.showTable()
     else:
         currentDate.setDate(currentDate.year(), currentDate.month(), 1)
         self.period1.setDate(currentDate)
         self.period2.setDate(QDate(currentDate.year(), currentDate.month(), currentDate.daysInMonth()))
         self.showTable(inverse=True)
Пример #4
0
    def createLayout(self):
        layout = QFormLayout()

        self.date = QDateEdit()
        self.date.setDate(QDate.currentDate())
        self.date.setCalendarPopup(True)
        self.date.setFocusPolicy(Qt.StrongFocus)
        layout.addRow("Data", self.date)

        self.description = QLineEdit()
        self.description.setMaxLength(40)
        completer = QCompleter(DATABASE.getDescriptions())
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setCompletionMode(QCompleter.PopupCompletion)
        self.description.setCompleter(completer)
        layout.addRow("Descrição", self.description)

        self.account1 = QComboBox()
        self.account2 = QComboBox()
        self.account1.setEditable(False)
        self.account2.setEditable(False)
        accounts = DATABASE.getAccounts()
        for item in accounts:
            self.account1.addItem(item)
            self.account2.addItem(item)
        self.account2.setCurrentIndex(1)
        layout.addRow("De", self.account1)
        layout.addRow("Para", self.account2)

        self.value = QDoubleSpinBox()
        self.value.setDecimals(2)
        self.value.setPrefix("R$ ")
        self.value.setSingleStep(100)
        self.value.setRange(0, 1000000000)
        layout.addRow("Valor", self.value)

        sublayout = QHBoxLayout()
        self.ok = QPushButton("Adicionar")
        self.ok.clicked.connect(self.accept)
        if not accounts:
            self.ok.setEnabled(False)

        cancel = QPushButton("Cancelar")
        cancel.clicked.connect(self.reject)

        sublayout.addWidget(self.ok)
        sublayout.addWidget(cancel)
        layout.addRow(sublayout)

        self.setLayout(layout)
Пример #5
0
    def loadInfo(self):
        self.view.clear()
        self.view.setHeaderLabels(COLUMNS)

        banks = TreeItem(self.view, "Bancos")
        banks.setFont(1, BOLD)
        banks.setTextAlignment(1, Qt.AlignRight)
        banks.setFont(2, BOLD)
        banks.setTextAlignment(2, Qt.AlignRight)
        cards = TreeItem(self.view, u"Cartões de Crédito")
        cards.setFont(1, BOLD)
        cards.setTextAlignment(1, Qt.AlignRight)
        cards.setFont(2, BOLD)
        cards.setTextAlignment(2, Qt.AlignRight)
        brokers = TreeItem(self.view, "Corretoras")
        brokers.setFont(1, BOLD)
        brokers.setTextAlignment(1, Qt.AlignRight)

        accounts = DATABASE.getAccounts(info=True)
        for account in accounts:
            balance = DATABASE.getBalance(account[0])
            if account[1] == BANK:
                item = TreeItem(banks, account[0])
                if balance >= 0:
                    item.setText(2, "R$ %.2f" % account[2])
                else:
                    item.setText(2, "R$ %.2f" % (account[2] + balance))
                item.setText(1, "R$ %.2f" % balance)
                defineColor(item, balance, 1)

            elif account[1] == CARD:
                item = TreeItem(cards, account[0])
                item.setText(2, "R$ %.2f" % (account[2] + balance))
                item.setText(1, "R$ %.2f" % balance)
                defineColor(item, balance, 1)
            else:
                item = TreeItem(brokers, account[0])
                item.setText(
                    1, "R$ %.2f" %
                    (balance + DATABASE.getBalanceFromBroker(account[0])))
                defineColor(
                    item, balance + DATABASE.getBalanceFromBroker(account[0]),
                    1)
            item.setTextAlignment(1, Qt.AlignRight)
            item.setTextAlignment(2, Qt.AlignRight)

        value = DATABASE.getBalance(_type=BANK)
        banks.setText(1, "R$ %.2f" % value)
        defineColor(banks, value, 1)
        accounts = DATABASE.getAccounts(info=True)
        limitDisp = 0
        for account in accounts:
            balance = DATABASE.getBalance(account[0])
            if account[1] == BANK and balance < 0:
                limitDisp += account[2] + balance
            elif account[1] == BANK:
                limitDisp += account[2]
        banks.setText(2, "R$ %.2f" % limitDisp)

        value = DATABASE.getBalance(_type=CARD)
        cards.setText(1, "R$ %.2f" % value)
        defineColor(cards, value, 1)
        limitDisp = 0
        for account in accounts:
            balance = DATABASE.getBalance(account[0])
            if account[1] == CARD:
                limitDisp += account[2] + balance
        cards.setText(2, "R$ %.2f" % limitDisp)

        brokers.setText(
            1, "R$ %.2f" % (DATABASE.getBalance(_type=BROKER) +
                            DATABASE.getBalanceFromBroker()))
        defineColor(
            brokers,
            DATABASE.getBalance(_type=BROKER) +
            DATABASE.getBalanceFromBroker(), 1)

        balance = DATABASE.getBalance() + DATABASE.getBalanceFromBroker()
        self.balance.setText("Balanço Total: R$ %.2f" % balance)
        if balance > 0:
            self.balance.setStyleSheet("QLabel {color:#007E00}")
        elif balance == 0:
            self.balance.setStyleSheet("QLabel {color:#000000}")
        else:
            self.balance.setStyleSheet("QLabel {color:#7E0000}")

        self.view.expandAll()
        self.view.resizeColumnToContents(0)
        self.view.sortItems(0, Qt.AscendingOrder)
Пример #6
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setFixedSize(600, 650)
        self.setWindowTitle("Ver Fatura\Extrato: ")
        self.setWindowIcon(Icon('fatura.png'))

        layout = QFormLayout()
        self.account = QComboBox()
        accounts = DATABASE.getAccounts()
        for account in accounts:
            self.account.addItem(account)
        self.account.activated.connect(self.attPeriod)
        layout.addRow("Conta", self.account)

        self.period1 = QDateEdit()
        self.period1.setCalendarPopup(True)
        label = QLabel(" a ")
        label.setAlignment(Qt.AlignCenter)
        self.period2 = QDateEdit()
        self.period2.setCalendarPopup(True)
        dateLayout = QHBoxLayout()
        dateLayout.addWidget(self.period1, 1)
        dateLayout.addWidget(label)
        dateLayout.addWidget(self.period2, 1)
        layout.addRow("Periodo", dateLayout)

        infoBox = QHBoxLayout()
        infos = QFormLayout()
        self.accountView = QLabel()
        self.totalValue = QLabel()
        self.date1 = QLabel()
        label2 = QLabel(" a ")
        label2.setAlignment(Qt.AlignCenter)
        self.date2 = QLabel()
        dateLayout2 = QHBoxLayout()
        dateLayout2.addWidget(self.date1, 1)
        dateLayout2.addWidget(label2)
        dateLayout2.addWidget(self.date2, 1)
        infos.addRow("Conta", self.accountView)
        infos.addRow("Período ", dateLayout2)
        infos.addRow("Total", self.totalValue)
        infoBox.addLayout(infos)

        left = QToolButton()
        left.setArrowType(Qt.LeftArrow)
        left.clicked.connect(self.previousMonth)
        right = QToolButton()
        right.setArrowType(Qt.RightArrow)
        right.clicked.connect(self.nextMonth)
        infoBox.addWidget(left)
        infoBox.addWidget(right)
        infoBox.addStretch(1)
        layout.addRow(infoBox)

        self.table = Tree(4)
        self.table.setHeaderLabels(['Data', 'Descrição', 'Categoria', 'Valor'])
        self.table.setResizeColumn(2)
        self.table.itemDoubleClicked.connect(self.editItem)
        self.table.itemClicked.connect(self.alterSum)
        layout.addRow(self.table)

        self.attPeriod(0)
        self.period1.dateChanged.connect(self.showTable)
        self.period2.dateChanged.connect(self.showTable)
        self.setLayout(layout)
    def createLayout(self, item):
        layout = QFormLayout()

        types = QGroupBox("Tipo", self)
        self.expense = QRadioButton("Despesa")
        self.expense.setChecked(True)
        self.expense.toggled.connect(lambda: changePrefix(self))
        self.income = QRadioButton("Receita")
        self.income.toggled.connect(lambda: changePrefix(self))

        hbox = QHBoxLayout()
        hbox.addWidget(self.expense)
        hbox.addWidget(self.income)
        types.setLayout(hbox)
        layout.addRow(types)

        self.date = QDateEdit()
        self.date.setDate(QDate.currentDate())
        self.date.setCalendarPopup(True)
        self.date.setFocusPolicy(Qt.StrongFocus)
        layout.addRow("Data", self.date)

        self.description = QLineEdit()
        self.description.setMaxLength(40)
        completer = QCompleter(DATABASE.getDescriptions())
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setCompletionMode(QCompleter.InlineCompletion)
        self.description.setCompleter(completer)
        layout.addRow("Descrição", self.description)

        self.category = QComboBox()
        self.category.setEditable(True)
        self.category.completer().setCompletionMode(QCompleter.PopupCompletion)
        categories = DATABASE.getCategories()
        if not categories:
            DATABASE.populateCategories()
            categories = DATABASE.getCategories()
        for cat in categories:
            self.category.addItem(cat)
        layout.addRow("Categoria", self.category)

        self.account = QComboBox()
        self.account.setEditable(False)
        accounts = DATABASE.getAccounts()
        for acc in accounts:
            self.account.addItem(acc)
        layout.addRow("Conta", self.account)

        self.value = QDoubleSpinBox()
        self.value.setDecimals(2)
        self.value.setSingleStep(100)
        self.value.setRange(0, 1000000000)
        layout.addRow("Valor", self.value)

        divBox = QHBoxLayout()
        self.initial = QSpinBox()
        self.initial.setRange(1, 1000)
        label = QLabel(" de ")
        label.setAlignment(Qt.AlignCenter)
        self.subdivision = QSpinBox()
        self.subdivision.setRange(1, 1000)
        self.subdivision.setSuffix(" parcelas")
        self.subdivision.setAlignment(Qt.AlignCenter)
        divBox.addWidget(self.initial)
        divBox.addWidget(label)
        divBox.addWidget(self.subdivision)
        layout.addRow("Parcelas", divBox)

        sublayout = QHBoxLayout()
        self.ok = QPushButton("Adicionar")
        self.ok.clicked.connect(self.accept)
        if not accounts:
            self.ok.setEnabled(False)

        cancel = QPushButton("Cancelar")
        cancel.clicked.connect(self.reject)
        sublayout.addWidget(self.ok)
        sublayout.addWidget(cancel)
        layout.addRow(sublayout)

        if item:
            info = DATABASE.getTransactions(ident=item.ident)
            if info[-1] >= 0:
                self.income.setChecked(True)
                self.value.setPrefix("R$ ")
            else:
                self.expense.setChecked(True)
                self.value.setPrefix("R$ -")
            self.date.setDate(QDate(info[3], info[2], info[1]))
            self.description.setText(info[4])
            idx = self.category.findText(info[5], Qt.MatchExactly)
            self.category.setCurrentIndex(idx)
            idx = self.account.findText(info[7], Qt.MatchExactly)
            self.account.setCurrentIndex(idx)
            self.value.setValue(abs(info[8]))
            self.ok.setText("Editar")
            self.initial.setEnabled(False)
            label.setEnabled(False)
            self.subdivision.setEnabled(False)

        self.setLayout(layout)