def regularly_view(request): # output account_name(str), payment_day(str), amount(int), note(str) # toriaezu view only... context = { 'today_date': u.get_nowdt().strftime('%Y-%m-%d'), 'title_jp': '毎月の支払項目とその金額の一覧です。', 'regularly_payment_list': getRegularlyPaymentList(), } return render(request, 'regularly_payment.html', context)
def regist_regularly_payment(request): '''指定された年月日に登録済みの定期支払項目を一括で自動登録する''' today_str = u.createCurrentDateString() strdate = request.POST['reg_regist_date'].replace('-', '') note = u.get_nowdt().strftime('%Y/%m/%d %H:%M') + ' 自動登録です' qs_reg_list = db.RegularlyPayment.objects.all() groupid = u.get_nowdt().strftime('%Y%m%d%H%M%S%f') for qs in qs_reg_list: if qs.is_regist_automaticaly == 1: db.Journal.objects.create( date = strdate, group_id = groupid, br_acc_bot_uid = db.AccBot.objects.get(uid=qs.acc_bot_uid.uid), br_amount = u.getEmptyOrValueInt(qs.amount_per_month), cr_acc_bot_uid = db.AccBot.objects.get(uid=qs.acc_bot_uid_from.uid), cr_amount = u.getEmptyOrValueInt(qs.amount_per_month), note = note, ) return redirect('/magi/sdss/regularly-payment/')
def fixed_asset_addform(request): fixed_asset_acc_qs = db.AccBot.objects.filter(acc_mid_uid=3) fixed_asset_account_list = getAccountList(fixed_asset_acc_qs) context = { 'today': u.get_nowdt().strftime('%Y-%m-%d'), 'acc_list': fixed_asset_account_list, 'title_jp': '固定資産登録画面', } return render(request, 'fixed_asset_add.html', context)
def getAccountSuii(year, month, accID): if accID == 0: return [] strDate = u.createCurrentYearMonthString(year, month) br_direction = db.AccBot.objects.get(uid=accID).acc_mid_uid.acc_top_uid.is_br # BSのみ前月末残高を計算 if db.AccBot.objects.get(uid=accID).acc_mid_uid.acc_top_uid.uid >= 4: total = 0 else: init_qs = db.Journal.objects.filter(date__lt=strDate) init_br = u.getEmptyOrValueInt(init_qs.filter(br_acc_bot_uid=accID).aggregate(Sum('br_amount'))['br_amount__sum']) init_cr = u.getEmptyOrValueInt(init_qs.filter(cr_acc_bot_uid=accID).aggregate(Sum('cr_amount'))['cr_amount__sum']) total = u.diffBrCr(init_br, init_cr, br_direction) print('total=' + str(total)) # summing day by day ... dic = [] nextMonth = u.createNextYearMonthString(year, month) qs = db.Journal.objects.filter(date__range=(strDate, nextMonth)) curr_br_qs = qs.filter(br_acc_bot_uid=accID) curr_cr_qs = qs.filter(cr_acc_bot_uid=accID) # TODO 2019年現在にyearが2020だった場合の考慮はしてないが不要? isSyoribiYM = u.get_nowdt().year == year and u.get_nowdt().month == month # 1日 ~ 31日まで借方と貸方の差分を取得する。2月31日とかも処理するけど文字列型なので問題なし for i in range(1,32): # 処理当日以降のは登録しない if isSyoribiYM and i > u.get_nowdt().day: dic.append(0) else: today_br_sum = u.getEmptyOrValueInt(curr_br_qs.filter(date=(strDate+'{:02}'.format(i))).aggregate(Sum('br_amount'))['br_amount__sum']) today_cr_sum = u.getEmptyOrValueInt(curr_cr_qs.filter(date=(strDate+'{:02}'.format(i))).aggregate(Sum('cr_amount'))['cr_amount__sum']) print(str(i) + ': add to ' + str(u.diffBrCr(today_br_sum, today_cr_sum, br_direction))) total += u.diffBrCr(today_br_sum, today_cr_sum, br_direction) dic.append(total) #else: # dic.append(0) #print(str(dic)) return dic
def getPassedMonths(dt_date): #ymd = str_date.split('/') #if len(ymd) < 3: return 0 #past_date = datetime(int(ymd[0]),int(ymd[1]),int(ymd[2])) if isinstance(dt_date, datetime): now_date=u.get_nowdt() passed_years=now_date.year-dt_date.year passed_months=now_date.month-dt_date.month return passed_years*12+passed_months else: return 0
def index(request): accbot_qs = db.AccBot.objects.order_by('sort_order').all() accbot_dic = getUidAndName(accbot_qs) accbot_list = getAccountList(accbot_qs) accbot_listgroup = getAccountListByGroup() context = { 'i_list': ['1','2','3','4','5', '6', '7', '8'], 'b_or_c': ['br', 'cr'], 'journal_date': u.get_nowdt().strftime('%Y-%m-%d'), 'accbot_dic': accbot_dic, # iru...? 'account_list': accbot_list, # iru...? 'listgroup': accbot_listgroup, 'view_name': 'sdss 2.0 journal input', 'message': '', } return render(request, 'sdss.html', context)
def isTermInNow(strFrom, strFor): strNow = u.get_nowdt().strftime('%Y%m%d') # Nothing from if strFrom is None or strFrom == '': return False else: if strFrom > strNow: return False else: if strFor is None or strFor == '': return True else: if strFor < strNow: return False else: return True
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')