Ejemplo n.º 1
0
    def test_last_day_of_a_year(self):
        # Last day from 2015
        expected = datetime.datetime(2015, 12, 31).date()

        result = last_day_of(year=2015, month=12)

        self.assertEqual(expected, result)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
    def test_last_day_from_february(self):
        expected = datetime.datetime(2015, 2, 28).date()

        result = last_day_of(year=2015, month=2)

        self.assertEqual(expected, result)