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)
    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()
Beispiel #3
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()))