Example #1
0
    def _add_buy_info(stock_id, supplier_id, price, number, buy_date, unpaid,
                      paid, total, payment, note, balance):
        buy_info = BuyInfo()
        buy_info.buy_date(buy_date)
        buy_info.stock_id(stock_id)
        buy_info.supplier_id(supplier_id)
        buy_info.unit_price(price)
        buy_info.payment_method(payment)

        buy_info.number(abs(number))

        create_time = time_utils.get_now()
        buy_info.create_time(create_time)
        create_op = Common.config.login_user_info[0]
        buy_info.create_op(create_op)

        buy_info.paid(abs(paid))
        buy_info.unpaid(abs(unpaid))
        buy_info.total(abs(total))

        buy_info.note(note)
        buy_info.buy_type(BuyInfo.bought())
        # 计算剩余量
        if balance < 0:
            left_number = number + balance
        else:
            left_number = number

        buy_info.left(left_number)

        return buy_handler.add_buy_info(buy_info)
Example #2
0
def add_buy_info(stock_id,
                 supplier_id,
                 price,
                 number,
                 buy_date,
                 unpaid,
                 paid,
                 total,
                 payment,
                 note,
                 left_number,
                 op=None,
                 buy_type=None,
                 state=0):
    buy_info = BuyInfo()
    buy_info.buy_date(buy_date)
    buy_info.stock_id(stock_id)
    buy_info.supplier_id(supplier_id)
    buy_info.unit_price(price)
    buy_info.payment_method(payment)

    if buy_type == BuyInfo.calibrated():
        buy_info.number(number)
        buy_info.total(total)
    else:
        buy_info.number(abs(number))
        buy_info.total(abs(total))

    create_time = time_utils.get_now()
    buy_info.create_time(create_time)
    if not op:
        create_op = common.config.login_user_info[0]
    else:
        create_op = op
    buy_info.create_op(create_op)

    buy_info.paid(abs(paid))
    buy_info.unpaid(abs(unpaid))

    buy_info.note(note)
    # 判断是进货还是退货
    if not buy_type:
        if number < 0:
            buy_info.buy_type(BuyInfo.returned())
            left_number = 0
        else:
            buy_info.buy_type(BuyInfo.bought())
    else:
        buy_info.buy_type(buy_type)

    if state:
        buy_info.state(state)

    buy_info.left(left_number)

    return buy_handler.add_buy_info(buy_info)
    def _submit(self):
        # stock = Stock()
        #
        # brand = self.brand_combo
        # stock.brand_name(brand.currentText()).brand_id(brand.currentData())
        #
        # model = self.model_combo
        # stock.model_name(model.currentText()).model_id(model.currentData())
        #
        # name = brand.currentText() + '-' + model.currentText()
        # stock.name(name)
        # # stock.unit(self.unit.text())
        # stock.create_op(self.staffComb.currentData())
        # stock.create_time(self.dateEdit.text())
        #
        # stock_id = stock_handler.add_stock_info(stock)
        model = self.model_combo
        stock_info = stock_handler.get_stock_by_model(model.currentData())
        buy_info = BuyInfo()
        buy_info.buy_date(self.dateEdit.text())
        buy_info.stock_id(stock_info[0])
        buy_info.supplier_id("99999")
        buy_info.unit_price(Decimal(self.money.text()))

        create_time = time_utils.get_now()
        buy_info.create_time(create_time)
        create_op = self.staffComb.currentData()
        buy_info.create_op(create_op)

        # buy_info.paid(abs(paid))
        # buy_info.unpaid(abs(unpaid))
        buy_info.total(Decimal(self.toal.text()))

        buy_info.note(self.notes.text())
        buy_info.buy_type("8")
        buy_handler.add_buy_info(buy_info)
        QMessageBox.information(self.addButton, '提示', '校准成功!')
        self.close()
Example #4
0
def add_buy_info(buy_info: BuyInfo) -> int:
    sql_text = '''
                INSERT INTO buy_info( 
                                STOCK_ID,
                                SUPPLIER_ID,
                                UNIT_PRICE,
                                NUMBER,
                                BUY_DATE,
                                CREATE_TIME,
                                CREATE_OP,
                                UNPAID,
                                PAID,
                                TOTAL,
                                BUY_TYPE,
                                note,
                                left_number,
                                state
                               )
              VALUES (
                      {},
                      {},
                      {:.2f},
                      {},
                      '{}',
                      '{}',
                      {},
                      {:.2f},
                      {:.2f},
                      {:.2f},
                      {},
                      '{}',
                      {},
                      {}
              )''' \
        .format(buy_info.stock_id(), buy_info.supplier_id(),
                buy_info.unit_price(), buy_info.number(), buy_info.buy_date(), buy_info.create_time(),
                buy_info.create_op(), buy_info.unpaid(), buy_info.paid(), buy_info.total(),
                buy_info.buy_type(), buy_info.note(), buy_info.left(), buy_info.state())
    new_buy_id = execute(sql_text)

    return new_buy_id