Exemple #1
0
def get_all_buy_info():
    sql_text = '''
                SELECT
                      bi.id,
                      bi.buy_date,                      
                      si.brand_name,
                      si.model_name,
                      bi.number,
                      si.unit,
                      bi.unit_price,
                      bi.total,
                      bi.supplier_id,
                      sl.supplier_name,
                      si.first_service_name || '-' || si.second_service_name,
                      bi.paid,
                      bi.unpaid,
                      di.value_desc,
                      bi.stock_id                
                 FROM buy_info bi, stock_info si, supplier sl, service sr, dictionary di
                WHERE bi.stock_id = si.id
                  AND bi.supplier_id = sl.id
                  AND sr.id = si.second_service_id
                  AND di.key_id = bi.buy_type
                  AND di.group_name = 'buy_type'
                  AND bi.buy_type in({},{})
                ORDER BY buy_date DESC'''.format(BuyInfo.bought(),
                                                 BuyInfo.returned())

    result = execute(sql_text)

    return result
Exemple #2
0
    def _add_buy_info(stock_id, supplier_id, price, number, buy_date, unpaid, paid, total, payment, note):
        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)
        # 判断是进货还是退货
        if number < 0:
            buy_info.buy_type(BuyInfo.returned())
        else:
            buy_info.buy_type(BuyInfo.bought())
            buy_info.left(number)

        return buy_handler.add_buy_info(buy_info)
Exemple #3
0
def get_buy_info_detail_by_time(start_time: str, end_time: str):
    sql_text = '''
                        SELECT 
                          bi.buy_date,                      
                          si.brand_name,
                          si.model_name,
                          bi.number,
                          si.unit,
                          bi.unit_price,
                          bi.total,
                          sl.supplier_name,
                          si.first_service_name || '-' || si.second_service_name,
                          bi.paid,
                          bi.unpaid,
                          di.value_desc
                          FROM buy_info bi, stock_info si, dictionary di, supplier sl
                         WHERE bi.stock_id = si.id
                           and di.key_id = bi.buy_type
                           and di.group_name = 'buy_type'
                           and sl.id = bi.supplier_id
                           and bi.buy_date BETWEEN '{}' and '{}'
                           and bi.buy_type in ({},{})
                    '''.format(start_time, end_time, BuyInfo.bought(),
                               BuyInfo.returned())

    result = execute(sql_text)

    return result
Exemple #4
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)