예제 #1
0
    def test_month(self):
        # February
        expected = 2015, 2

        result = month_before_of(year=2015, month=3)

        self.assertEqual(expected, result)
예제 #2
0
파일: views.py 프로젝트: delete/estofadora
def cash_month(request):
    context = {}
    date = datetime.now().date()
    year = date.year
    month = date.month

    # If a date was not given, filter by the atual date.
    content = Cash.filter_by_date(month=month, year=year)
    total_value = Cash.total_value_by_date(month=month, year=year)

    if request.method == 'POST':
        month = int(request.POST.get('selectmonth'))
        year = int(request.POST.get('selectyear'))

        content = Cash.filter_by_date(month=month, year=year)
        total_value = Cash.total_value_by_date(month=month, year=year)

    y, m = month_before_of(year, month)
    last_day_of_month_before = last_day_of(y, m)

    total_before = Balance.total_balance_before(last_day_of_month_before)

    content, total_value = Cash.create_balance(content, total_before)

    context['content'] = content
    context['total_value'] = total_value
    context['total_before'] = total_before
    context['choose_month'] = month
    context['choose_year'] = year
    context['months'] = MONTHS
    context['years'] = Cash.list_years()
    context['section'] = 'cash_month'
    return render(request, 'statement/cash_month.html', context)
예제 #3
0
    def test_first_month_of_a_year(self):
        # December
        expected = 2015, 12

        result = month_before_of(year=2016, month=1)

        self.assertEqual(expected, result)
예제 #4
0
파일: views.py 프로젝트: delete/estofadora
def cash_annual(request):
    context = {}
    # If an year was not given, use the atual year.
    year = datetime.now().date().year

    if request.method == 'POST':
        year = int(request.POST.get('selectyear'))

    balances = []
    month = 1
    while month < 13:
        # Get the total balance from January to December.
        balance = Balance.balance_from_month(year=year, month=month)
        balances.append(float(balance))
        month += 1

    total_value = Cash.total_value_by_date(year=year)

    # Get the previous year to sum the total of it.
    january = 1
    y, m = month_before_of(year, january)
    last_day_year_before = last_day_of(y, m)

    total_before = Balance.total_balance_before(last_day_year_before)

    context['total_value'] = total_value
    context['total_before'] = total_before
    context['choose_year'] = year
    context['balances'] = balances
    context['years'] = Cash.list_years()
    context['section'] = 'cash_annual'

    return render(request, 'statement/cash_annual.html', context)