Exemple #1
0
def getNote(i_acc_bot_uid):
    if u.isIntAndNotZero(i_acc_bot_uid) == False:
        return ''
    else:
        if db.Budget.objects.filter(acc_bot_uid=i_acc_bot_uid).exists():
            qs_acc_list = db.Budget.objects.filter(acc_bot_uid=i_acc_bot_uid)
            for qs_acc in qs_acc_list:
                strFrom = qs_acc.from_field
                strFor = qs_acc.for_field
                if isTermInNow(strFrom, strFor):
                    return qs_acc.note
        return ''
Exemple #2
0
def regist(request):
    #入力チェックと登録用データ作成
    #TODO 入力チェックとUI側の入力チェックもこっちへ移す
    groupid = u.get_nowdt().strftime('%Y%m%d%H%M%S%f')
    strdate = request.POST['journal_date'].replace('-','')
    log.info('regist date as: ' + strdate)

    register_corresp = []
    register_corresp.append({'br_a': 'br_1_a', 'cr_a': 'cr_1_a', 'br_c': 'br_1_c', 'cr_c': 'cr_1_c'})
    register_corresp.append({'br_a': 'br_2_a', 'cr_a': 'cr_2_a', 'br_c': 'br_2_c', 'cr_c': 'cr_2_c'})
    register_corresp.append({'br_a': 'br_3_a', 'cr_a': 'cr_3_a', 'br_c': 'br_3_c', 'cr_c': 'cr_3_c'})
    register_corresp.append({'br_a': 'br_4_a', 'cr_a': 'cr_4_a', 'br_c': 'br_4_c', 'cr_c': 'cr_4_c'})
    register_corresp.append({'br_a': 'br_5_a', 'cr_a': 'cr_5_a', 'br_c': 'br_5_c', 'cr_c': 'cr_5_c'})
    register_corresp.append({'br_a': 'br_6_a', 'cr_a': 'cr_6_a', 'br_c': 'br_6_c', 'cr_c': 'cr_6_c'})
    register_corresp.append({'br_a': 'br_7_a', 'cr_a': 'cr_7_a', 'br_c': 'br_7_c', 'cr_c': 'cr_7_c'})
    register_corresp.append({'br_a': 'br_8_a', 'cr_a': 'cr_8_a', 'br_c': 'br_8_c', 'cr_c': 'cr_8_c'})
    registerd = False
    note_temp = ''
    for cor in register_corresp:
        if u.isIntAndNotZero(request.POST[cor['br_a']]) or u.isIntAndNotZero(request.POST[cor['cr_a']]):
            if registerd == True:
                note_temp = ''
            else:
                note_temp = request.POST['note']
            db.Journal.objects.create(
                date = strdate,
                group_id = groupid,
                br_acc_bot_uid = db.AccBot.objects.get(uid=request.POST[cor['br_c']]),
                br_amount = u.getEmptyOrValueInt(request.POST[cor['br_a']]),
                cr_acc_bot_uid = db.AccBot.objects.get(uid=request.POST[cor['cr_c']]),
                cr_amount = u.getEmptyOrValueInt(request.POST[cor['cr_a']]),
                note = note_temp,
            )
            registerd = True
            log.info('register journal object')
    # TODO ハードコーディングなのでショートカットにするとか200
    return redirect('/magi/sdss')