Esempio n. 1
0
def add_one_income(uid, n, t):
    if not is_float(n):
        return {'msg': 'id不存在', 'status': 2}
    if not is_date(t):
        return {'msg': '输入错误', 'status': 2}
    try:
        IncomeDAO.add_income(uid, dt.datetime.strptime(t, '%Y-%m-%d'), n)
    except Exception as e:
        return {'msg': '输入错误:' + str(e), 'status': 2}
    else:
        return {'msg': '添加成功', 'status': 1}
Esempio n. 2
0
def add_one_card(u, s, a, p, f, c):
    if not is_days(a) or not is_days(p):
        return {'msg': '日期错误', 'status': 2}
    if not is_float(f):
        return {'msg': '额度错误', 'status': 2}
    if c not in [0, 1]:
        return {'msg': '卡类错误', 'status': 2}
    try:
        CardDao.add_card(u, s, int(a), int(p), f, c)
    except Exception as e:
        res = {'msg': '输入错误:' + str(e), 'status': 2}
    else:
        res = {'msg': '添加成功!', 'status': 1}
    return res
Esempio n. 3
0
def add_loan(uid,cid,num,ts,en):
    if not str(cid).isdigit():
        return {'status':2,'msg':'id 不存在'}
    if not is_float(num):
        return {'status':2,'msg':'数量错误'}
    if not is_date(ts) or not is_date(en):
        return {'status':2,'msg':'日期错误'}
    d = dateRange(ts,en)
    try:
        DebtDao.add_bulk_debt(uid, cid, d, num)
    except Exception as e:
        res = {'msg':'输入错误:' + str(e),'status':2}
    else:
        res = {'msg':'添加成功','status':1}
    return res
Esempio n. 4
0
def quick_repay_by_income(uid, in_cid, num, date, iid):
    if not str(in_cid).isdigit():
        return {'msg': 'id不存在', 'status': 2}
    if not is_float(num):
        return {'msg': '数量错误', 'status': 2}
    if not is_date(date):
        return {'msg': '日期错误', 'status': 2}
    t = dt.datetime.strptime(date, '%Y-%m-%d')
    try:
        IncomeDao.add_incomego(uid, iid, t, num)
        RepayDao.add_repay(uid, in_cid, t, num)
    except Exception as e:
        res = {'msg': '输入错误:' + str(e), 'status': 1}
    else:
        res = {'msg': '添加成功', 'status': 1}
    return res
Esempio n. 5
0
def add_one_debt(uid,cid,num,t):
    if not str(cid).isdigit():
        return {'msg':'id不存在','status':2}
    if not is_float(num):
        return {'msg':'数量错误','status':2}
    if not is_date(t):
        return {'msg':'日期错误','status':2}
    ll = [v[0] for v in CardDao.find_card(uid)]
    if cid not in ll:
        return {'msg':'id不存在','status':2}
    try:
        DebtDao.add_debt(uid, cid, dt.datetime.strptime(t,'%Y-%m-%d'), num)
    except Exception as e:
        res = {'msg':'输入错误:' + str(e),'status':2}
    else:
        res = {'msg':'添加成功','status':1}
    return res
Esempio n. 6
0
def quick_repay_by_card(uid, in_cid, num, date, out_cid):
    if not str(in_cid).isdigit():
        return {'msg': 'id不存在', 'status': 2}
    if not is_float(num):
        return {'msg': '数量错误', 'status': 2}
    if not is_date(date):
        return {'msg': '日期错误', 'status': 2}
    t = dt.datetime.strptime(date, '%Y-%m-%d')
    # rl = round(num*1.006,2)
    try:
        DebtDao.add_debt(uid, out_cid, t, num)  # 临时改rl为 num
        RepayDao.add_repay(uid, in_cid, t, num)
    except Exception as e:
        res = {'msg': '输入错误:' + str(e), 'status': 1}
    else:
        res = {'msg': '添加成功', 'status': 1}
    return res
Esempio n. 7
0
def quick_repay_by_cash(uid, in_cid, num, date):
    if not str(in_cid).isdigit():
        return {'msg': 'id不存在', 'status': 2}
    if not is_float(num):
        return {'msg': '数量错误', 'status': 2}
    if not is_date(date):
        return {'msg': '日期错误', 'status': 2}
    t = dt.datetime.strptime(date, '%Y-%m-%d')
    try:
        h = IncomeDao.find_income_before_date(uid, t)
        c = max(0, num - h)
        if c:
            IncomeDao.add_income(uid, t, c)
        pad = CardPad()
        for v in IncomeDao.find_incomego_sum(uid):
            pad.set_income(v)
        ll = pad.consume(t.date(), num)
        IncomeDao.add_bulk_incomego(uid, t, ll)
        RepayDao.add_repay(uid, in_cid, t, num)
    except Exception as e:
        res = {'msg': '输入错误:' + str(e), 'status': 1}
    else:
        res = {'msg': '添加成功', 'status': 1}
    return res