def budget_change(request): # TODO 変更履歴の登録 # なければ新規、あれば変更 budget_qs = db.Budget.objects.filter(acc_bot_uid=db.AccBot.objects.get(uid=request.POST['id'])).order_by('for_field') if budget_qs.count() > 0: budget = budget_qs[0] if budget.amount_per_month != request.POST['after']: if budget.for_field == '' or budget.for_field > u.createYesterdayDateString(): budget.for_field = u.createYesterdayDateString() budget.save() db.Budget.objects.create( acc_bot_uid= db.AccBot.objects.get(uid=request.POST['id']), from_field= u.createCurrentDateString(), amount_per_month= request.POST['after'], note= request.POST['cause'], ) return redirect('/magi/sdss/budget')
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/')