Пример #1
0
 def _init_ui(self):
     Payment.add_all_payment(self.payment)
     completer = QCompleter(self._get_all_supplier())
     completer.setCaseSensitivity(Qt.CaseInsensitive)
     completer.setFilterMode(Qt.MatchContains)
     self.supplier.setCompleter(completer)
     pyqt_utils.set_validator(self.price, 'float')
     pyqt_utils.set_validator(self.unpaid, 'float')
Пример #2
0
 def _init_first_line(self):
     self.line_number = 1
     self.buy_date_1.setDateTime(QDateTime.fromString(time_utils.get_now(), 'yyyy-MM-dd hh:mm:ss'))
     self._add_all_service_item(self.service_1)
     Payment.add_all_payment(self.payment_1)
     for title in self.line_title:
         name = title + '_' + '1'
         editor = getattr(self, name)
         self._set_completer(editor, title)
     pyqt_utils.set_validator(self.price_1, 'float')
     pyqt_utils.set_validator(self.paid_1, 'float')
     self.paid_1.setText('0.0')
     self.price_1.setText('0.0')
     self.total_1.setText('0.0')
     self.unpaid_1.setText('0.0')
Пример #3
0
    def _init_input_info(self, total, supplier_name):
        self.pay_to.setText(supplier_name)
        self.pay.setText(str(total))

        payments = Payment.get_payment_method()
        for key in list(payments.keys()):
            self.payment_method.addItem(payments[key], key)
Пример #4
0
def add_payment_detail(payment: Payment):
    sql_text = '''
                INSERT INTO PAYMENT_DETAIL(
                                BUY_ID,
                                PAYMENT_METHOD,
                                PAID,
                                UNPAID,
                                CREATE_TIME,
                                CREATE_OP,
                                refund_type,
                                supplier_id,
                                note
                               )
                VALUES (
                         {},
                         {},
                        {:.2f},
                        {:.2f},
                        '{}',
                         {},
                         {},
                         {},
                        '{}'
                       )''' \
        .format(payment.buy_id(), payment.payment_method(), payment.paid(), payment.unpaid(),
                get_now(), common.config.login_user_info[0], payment.refund_type(), payment.supplier_id(),
                payment.note())

    result = execute(sql_text)

    return result
Пример #5
0
 def _add_new_payment_method(self):
     payment_method, ok = QInputDialog.getText(self.payButton, '新增付款方式',
                                               '请输入付款方式')
     if ok and not payment_method:
         QMessageBox.warning(self.payButton, '警告', '付款方式不能为空,请重新添加!')
         return
     exist_num = dictionary_handler.get_count_by_group_and_value(
         Payment.group_name(), payment_method)
     if exist_num:
         QMessageBox.warning(self.payButton, '警告', '付款方式已经存在,请重新添加!')
         return
     key_id = dictionary_handler.get_max_key_id_by_group_name(
         Payment.group_name()) + 1
     dictionary_handler.add_dictionary(key_id, payment_method,
                                       Payment.group_name())
     QMessageBox.warning(self.payButton, '提示', '付款方式添加成功!')
     self.payment_method.insertItem(0, payment_method, key_id)
     self.payment_method.setCurrentIndex(0)
    def _init_input_info(self, buy):
        self.pay_to.setText(buy.note())
        self.unpaid.setText('0.0')
        self.need_pay.setText(str(buy.unpaid()))
        self.paid.setText(str(buy.paid()))
        self.pay.setText(str(buy.unpaid()))

        payment_methods = Payment.get_payment_method()

        for key in list(payment_methods.keys()):
            self.payment_method.addItem(payment_methods[key], key)
        self.pay.setFocus()
Пример #7
0
    def _submit(self):
        money_changed = self.money_changed.text()
        balance_changed = self.balance_changed.text()
        if not money_changed or not balance_changed:
            QMessageBox.information(self.addButton, '提示', '调整金额和调整数量不能为空!')
            self.balance_changed.setFocus()
            return
        money_changed = Decimal(money_changed)
        balance_changed = int(balance_changed)

        if money_changed == self.original_cost and balance_changed == self.original_balance:
            QMessageBox.information(self.addButton, '提示', '金额和数量未做调整,请重新填写!')
            self.balance_changed.setFocus()
            return

        changed_number = balance_changed - self.original_balance
        changed_cost = money_changed - self.original_cost
        buy_date = self.calibration_date.date().toString('yyyy-MM-dd')
        payment_method = list(Payment.get_payment_method().keys())[0]
        note = self.notes.text()
        create_op = int(self.staffComb.currentData())
        try:
            db_transaction_util.begin()
            logger.info('新增库存校准数据')
            buy_id = buy_service.add_buy_info(self.stock_id, 9999, 0.0,
                                              changed_number, buy_date, 0.0,
                                              0.0, changed_cost,
                                              payment_method, note, 0,
                                              create_op, BuyInfo.calibrated(),
                                              BuyInfo.under_reviewed())
            if changed_number >= 0:
                change_type = StockDetail.by_increased()
            else:
                change_type = StockDetail.by_decreased()

            stock_service.add_stock_detail(self.stock_id, buy_id,
                                           abs(changed_cost),
                                           abs(changed_number), change_type)
            db_transaction_util.commit()
            logger.info('库存校准数据新增完成')
            QMessageBox.information(self.addButton, '提示', '库存校准成功,请等待数据审核!')
            self.close()
        except Exception as e:
            db_transaction_util.rollback()
            logger.error(e)
            logger.error('traceback.format_exc():\n{}'.format(
                traceback.format_exc()))
Пример #8
0
def add_supplier_payment_detail(buy_id,
                                supplier_id,
                                paid,
                                unpaid,
                                payment_method,
                                is_return=False,
                                note=''):
    payment = Payment()
    payment.buy_id(buy_id)
    payment.supplier_id(supplier_id)
    payment.payment_method(payment_method)
    payment.paid(paid)
    payment.unpaid(unpaid)
    payment.create_op(common.config.login_user_info[0])
    payment.create_time(time_utils.get_now())
    payment.note(note)

    if is_return:
        payment.refund_type(Payment.returned())
    else:
        payment.refund_type(Payment.payoff())

    payment_handler.add_payment_detail(payment)

    if unpaid:
        supplier_handler.update_supplier_unpaid(supplier_id, unpaid)
    def _add_payment_detail(self, paid: float, unpaid: float, ):
        payment = Payment()

        payment.buy_id(self.buy_id)

        payment_method = int(self.payment_method.currentData())
        payment.payment_method(payment_method)

        payment.paid(paid)
        payment.unpaid(unpaid)

        payment.create_op(Common.config.login_user_info[0])
        payment.create_time(time_utils.get_now())
        payment.refund_type(Payment.payoff())

        payment_handler.add_payment_detail(payment)
Пример #10
0
    def _add_new_line(self):
        if self.buy_info_container.count() >= 11:
            QMessageBox.information(self.submit, "提示", '添加的行数过多,请提交后再做新增!')
            return

        self.line_number += 1
        line_number = str(self.line_number)
        buy_info_name = 'buy_info' + '_' + line_number
        setattr(self, buy_info_name, QtWidgets.QHBoxLayout())
        buy_info = getattr(self, buy_info_name)
        buy_info.setObjectName(buy_info_name)

        for index, title in enumerate(self.line_title):
            editor = self.create_instance('PyQt5.QtWidgets.' + self.edit_type[index])
            attr_name = title + '_' + line_number
            editor.setObjectName(attr_name)

            first_attr_name = title + '_' + '1'
            first_attr = getattr(self, first_attr_name)

            editor.setMinimumSize(getattr(first_attr, 'minimumSize')())
            editor.setMaximumSize(getattr(first_attr, 'maximumSize')())
            editor.setFont(getattr(first_attr, 'font')())

            if hasattr(first_attr, 'setClearButtonEnabled') and first_attr.isClearButtonEnabled():
                editor.setClearButtonEnabled(True)

            if title == 'buy_date':
                editor.setDisplayFormat("yyyy-MM-dd")
                editor.setDateTime(QDateTime.fromString(time_utils.get_now(), 'yyyy-MM-dd hh:mm:ss'))

            if title == 'remove':
                editor.setText('删除')
                editor.clicked.connect(self.do_remove)
                editor.setObjectName(attr_name)

            if title == 'seq':
                editor.setText(line_number)

            # 只读
            if title in ('total', 'unpaid'):
                editor.setReadOnly(first_attr.isReadOnly())
                editor.setEnabled(first_attr.isEnabled())
                editor.setText('0.0')

            if title in ('paid', 'price'):
                pyqt_utils.set_validator(editor, 'float')
                editor.textEdited.connect(self._text_edit)
                editor.setText('0.0')

            if title == 'number':
                editor.valueChanged.connect(self._text_edit)

            if title == 'service':
                self._add_all_service_item(editor)

            if title == 'payment':
                Payment.add_all_payment(editor)

            self._set_completer(editor, title)
            setattr(self, attr_name, editor)
            buy_info.addWidget(editor)
        self.buy_info_container.addLayout(buy_info)