This file contains hidden or 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
<moolah-card card-title="reportCtrl.cardTitle"> | |
<canvas class="chart chart-line" chart-data="reportCtrl.data" | |
chart-labels="reportCtrl.labels" chart-legend="true" chart-series="reportCtrl.series"> | |
</canvas> | |
</moolah-card> |
This file contains hidden or 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
angular.module('moolah') | |
.controller('dailyTransactionreportController', ['ReportService', function(ReportService) { | |
var self = this; | |
self.cardTitle = 'This Week'; | |
ReportService.dailyTransactionReport().success(function(d) { | |
self.data = d.data; | |
self.labels = d.labels; |
This file contains hidden or 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 DailyTransactionReportView(views.APIView): | |
def _get_week_dates(self, weeks=-1): | |
today = get_timestamp() | |
monday = today + relativedelta(weekday=MO(weeks)) | |
return [monday + timedelta(days=n) | |
for n in range(7)] | |
def get(self, request): | |
t = Transaction.objects | |
labels = ['Monday', |
This file contains hidden or 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
from rest_framwork import views, response | |
from models import Tranaction | |
class SummaryView(views.APIView): | |
def get(self, request): | |
t = Transaction.objects | |
data = {'day': t.today().total(), | |
'week': t.last_week().total(), | |
'month': t.last_month().total(), |
This file contains hidden or 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
angular.module('moolah').factory('TransactionService', ['$resource', 'API_URL', function($resource, API_URL) { | |
return $resource('{}transactions/:id'.format(API_URL)); | |
}]); |
This file contains hidden or 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
angular.module('moolah') | |
.factory('toStatic', ['STATIC_URL', function(STATIC_URL) { | |
return function(i) { | |
return '{}{}'.format(STATIC_URL, i); | |
}; | |
}]); |
This file contains hidden or 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
<script> | |
angular.module('moolah') | |
.constant('STATIC_URL', '/static/') | |
.constant('API_URL', '/api/') | |
.constant('LOGOUT_URL', '{% url 'django.contrib.auth.views.logout' %}') | |
.constant('USER_NAME', '{{ user.get_full_name }}'); | |
</script> |
This file contains hidden or 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
from django.conf.urls import url | |
from django.views.generic import TemplateView | |
from django.contrib.auth.decorators import login_required | |
import routes | |
urlpatterns = [ | |
'''... other rules...''' | |
This file contains hidden or 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
from dateutil import parser | |
def sanitize_dates(func): | |
''' | |
attempt to convert stringy dates | |
to real dates | |
''' | |
def wrapper(self, *args): | |
clean_args = [] |
This file contains hidden or 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 TransactionQuerySet(models.QuerySet): | |
def total(self): | |
return self.aggregate( | |
models.Sum('amount'))['amount__sum'] or 0 | |
def date(self, date): | |
return self.filter(timestamp__month=date.month, | |
timestamp__day=date.day, | |
timestamp__year=date.year) |