This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item(models.Model): | |
item_number = models.CharField(u"항목번호", max_length=3) | |
category = models.ForeignKey(Category, verbose_name=u"범주") | |
title = models.CharField(max_length=50, verbose_name=u"항목명") | |
slug = models.SlugField(blank=True) | |
description = models.TextField(blank=True, verbose_name=u'메모') | |
class Meta: | |
ordering = ["item_number"] | |
verbose_name = u'항목' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Accounts(object): | |
accountNumber = 0 | |
def __int__(self, name, balance): | |
self.name = name | |
self.balance = balance | |
Accounts.accountNumber += 1 | |
def withdraw(self, atm): | |
self.balance = self.balance - atm | |
return self.balance | |
def deposit(self, atm): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
today = datetime.datetime.now() | |
categoryNumber_list = Category.objects.all().values_list("categoryNumber",flat=True) | |
category_list = Category.objects.all() | |
income_list = Income.objects.filter(date__year=today.year) | |
monthly_list = [] | |
for i in categoryNumber_list: | |
if int(i)<100: | |
for j in range(1,13): | |
temp_money = sum(Income.objects.filter(category__categoryNumber="%s" %i, date__year=today.year, date__month="%s" %j).values_list("money",flat=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
today = datetime.datetime.now() | |
income_list = [] | |
outcome_list = [] | |
item_number_list = Item.objects.all().values_list("item_number", flat=True) | |
for month in range(1,13): | |
for n in item_number_list: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
income_list = [] | |
for n in range(1,13): | |
temp = sum(Income.objects.filter(date__month="%s" %n).values_list("money", flat=True)) | |
income_list.append(temp) | |
#EXPECTED RESULT | |
[100000, 0, 250000, ......, 0] 의 원소 12개 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Income(models.Model): | |
date = models.DateField(verbose_name=u"날짜", auto_now_add=True) | |
item = models.ForeignKey(Item, verbose_name=u"항목") | |
member = models.ForeignKey(Member, verbose_name=u"이름", blank=True, null=True) | |
money = models.IntegerField(verbose_name=u"금액") | |
comment = models.TextField(blank=True, verbose_name=u"비고") | |
week = models.IntegerField(blank=True, verbose_name=u"주차", editable=False) | |
class Meta: | |
ordering = ["-date", "item"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Category | |
categoryNumber item description | |
000 전년도이월 | |
001 급여 | |
002 상여금 | |
003 은행이자 | |
004 기타수입 | |
111 임대료(관리비) | |
112 전기요금(관리비) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table id="contents" align="center" border="1px" cellspacing="0"> | |
<tr bgcolor="#efffff"> | |
<td align="center" width="15%">항목</td> | |
{% for p in month_list %} | |
<td width="5%" align="center">{{ p }}월</td> | |
{% endfor %} | |
<td width="6%" align="center">합계</td> | |
<td width="6%" align="center">예산</td> | |
<td width="6%" align="center">항목예산대비</td> | |
<td width="6%" align="center">예산총액대비</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
from django.db import models | |
import datetime | |
today = datetime.datetime.now() | |
class Category(models.Model): | |
categoryNumber = models.CharField(max_length=3, verbose_name="항목번호") | |
item = models.CharField(max_length=40, verbose_name="항목") | |
description = models.TextField(blank=True, verbose_name="메모") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def report_total(request): | |
today = datetime.datetime.now() | |
categoryNumber_list = Category.objects.all().values_list("categoryNumber",flat=True) | |
category_list = Category.objects.all().values_list("item",flat=True) | |
monthly_list = [] | |
for i in categoryNumber_list: | |
if int(i)<100: | |
for j in range(1,13): | |
temp_money = sum(Income.objects.filter(category__categoryNumber="%s" %i, date__year=today.year, date__month="%s" %j).values_list("money",flat=True)) | |
monthly_list.append((int(i),temp_money),) |
NewerOlder