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)
def single_pay(self): buy_id = table_utils.get_table_current_index_info( self.detail_table, 10) if not buy_id: QMessageBox.information(self.single_button, '提示', '请选择一条明细!') return buy_info = BuyInfo() buy_info.buy_id(int(buy_id)) unpaid = Decimal( table_utils.get_table_current_index_info(self.detail_table, 9)) paid = Decimal( table_utils.get_table_current_index_info(self.detail_table, 8)) supplier_id = self._get_supplier_id() buy_info.paid(paid) buy_info.unpaid(unpaid) buy_info.note(self.supplier_name) buy_info.supplier_id(supplier_id) dialog = PayOffArrearsDialog(buy_info) dialog.exec() self._init_table()
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 __init__(self, buy: BuyInfo): super(PayOffArrearsDialog, self).__init__() self.setupUi(self) self.setWindowTitle('请填写支付金额') self._init_input_info(buy) self._init_signal_and_slot() self.buy_id = buy.buy_id() self.supplier_id = buy.supplier_id()
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()
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