From 4ace61cdee89f19f53c09a9eb58f28e87069ef36 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Wed, 30 Oct 2013 12:50:32 +0530 Subject: [PATCH] Added: Purchases report --- brewman/__init__.py | 2 + brewman/static/partial/cash-flow.html | 2 +- brewman/static/partial/purchases.html | 56 +++++++++++++++++++++++ brewman/static/scripts/angular_service.js | 4 ++ brewman/static/scripts/cash-flow.js | 2 +- brewman/static/scripts/overlord.js | 1 + brewman/static/scripts/purchases.js | 33 +++++++++++++ brewman/templates/angular_base.mako | 4 +- brewman/views/reports/purchases.py | 56 +++++++++++++++++++++++ 9 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 brewman/static/partial/purchases.html create mode 100644 brewman/static/scripts/purchases.js create mode 100644 brewman/views/reports/purchases.py diff --git a/brewman/__init__.py b/brewman/__init__.py index 7d8691b9..c2ebb120 100644 --- a/brewman/__init__.py +++ b/brewman/__init__.py @@ -111,6 +111,8 @@ def main(global_config, **settings): add_route(config, 'trial_balance', '/TrialBalance', has_list=False, variable='date') config.add_route('api_net_transactions', '/api/NetTransactions') config.add_route('net_transactions', '/NetTransactions') + config.add_route('api_purchases', '/api/Purchases') + config.add_route('purchases', '/Purchases') add_route(config, 'closing_stock', '/ClosingStock', has_list=False, variable='date') add_route(config, 'cash_flow', '/CashFlow', has_list=False) diff --git a/brewman/static/partial/cash-flow.html b/brewman/static/partial/cash-flow.html index f83ea7dd..8cc957b2 100644 --- a/brewman/static/partial/cash-flow.html +++ b/brewman/static/partial/cash-flow.html @@ -44,7 +44,7 @@ - {{item.Name}} + {{item.Name}} {{item.Inflow | currency | clr}} {{item.Outflow | currency | clr}} diff --git a/brewman/static/partial/purchases.html b/brewman/static/partial/purchases.html new file mode 100644 index 00000000..4a0d9c5a --- /dev/null +++ b/brewman/static/partial/purchases.html @@ -0,0 +1,56 @@ +
+

Purchases

+ +
+ + +
+
+ + + + +
+
+
+
+ + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductQuantityRateAmount
{{item.Name}}{{item.Quantity | number:2 | clr}}{{item.Rate | currency | clr}}{{item.Amount | currency | clr}}
{{item.Name}}{{item.Quantity | number:2 | clr}}{{item.Rate | currency | clr}}{{item.Amount | currency | clr}}
+
diff --git a/brewman/static/scripts/angular_service.js b/brewman/static/scripts/angular_service.js index 2e4241af..c0ac6619 100644 --- a/brewman/static/scripts/angular_service.js +++ b/brewman/static/scripts/angular_service.js @@ -138,6 +138,10 @@ overlord_service.factory('NetTransactions', ['$resource', function ($resource) { return $resource('/api/NetTransactions'); }]); +overlord_service.factory('Purchases', ['$resource', function ($resource) { + return $resource('/api/Purchases'); +}]); + overlord_service.factory('PurchaseEntries', ['$resource', function ($resource) { return $resource('/api/PurchaseEntries'); }]); diff --git a/brewman/static/scripts/cash-flow.js b/brewman/static/scripts/cash-flow.js index dd9b1132..fb01b67e 100644 --- a/brewman/static/scripts/cash-flow.js +++ b/brewman/static/scripts/cash-flow.js @@ -12,7 +12,7 @@ var CashFlowCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'cash_f $location.path('/CashFlow').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate}); }; $('#txtStartDate').focus(); -}] +}]; CashFlowCtrl.resolve = { cash_flow:['$q', '$route', 'CashFlow', function ($q, $route, CashFlow) { var deferred = $q.defer(); diff --git a/brewman/static/scripts/overlord.js b/brewman/static/scripts/overlord.js index ee3e6f6b..6ffee7e3 100644 --- a/brewman/static/scripts/overlord.js +++ b/brewman/static/scripts/overlord.js @@ -55,6 +55,7 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte when('/StockMovement', {templateUrl: '/partial/stock-movement.html', controller: StockMovementCtrl, resolve: StockMovementCtrl.resolve}). when('/NetTransactions', {templateUrl: '/partial/net-transactions.html', controller: NetTransactionsCtrl, resolve: NetTransactionsCtrl.resolve}). when('/PurchaseEntries', {templateUrl: '/partial/purchase-entries.html', controller: PurchaseEntriesCtrl, resolve: PurchaseEntriesCtrl.resolve}). + when('/Purchases', {templateUrl: '/partial/purchases.html', controller: PurchasesCtrl, resolve: PurchasesCtrl.resolve}). when('/EmployeeFunctions', {templateUrl: '/partial/employee-functions.html', controller: EmployeeFunctionsCtrl}). when('/BalanceSheet', {templateUrl: '/partial/balance-sheet.html', controller: BalanceSheetCtrl, resolve: BalanceSheetCtrl.resolve}). diff --git a/brewman/static/scripts/purchases.js b/brewman/static/scripts/purchases.js new file mode 100644 index 00000000..1c6ea3d0 --- /dev/null +++ b/brewman/static/scripts/purchases.js @@ -0,0 +1,33 @@ +'use strict'; + +var PurchasesCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'purchases', function ($scope, $routeParams, $location, dateFilter, purchases) { + $scope.info = purchases; + $scope.show = function () { + if (angular.isDate($scope.info.StartDate)) { + $scope.info.StartDate = dateFilter($scope.info.StartDate, 'dd-MMM-yyyy'); + } + if (angular.isDate($scope.info.FinishDate)) { + $scope.info.FinishDate = dateFilter($scope.info.FinishDate, 'dd-MMM-yyyy'); + } + $location.path('/Purchases').search({s:$scope.info.StartDate, f:$scope.info.FinishDate}); + }; +}]; +PurchasesCtrl.resolve = { + purchases:['$q', '$route', 'Purchases', function ($q, $route, Purchases) { + var deferred = $q.defer(); + + var start_date = $route.current.params.s; + var finish_date = $route.current.params.f; + + var successCb = function (result) { + deferred.resolve(result); + }; + + if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') { + Purchases.get({}, successCb); + } else { + Purchases.get({s:start_date, f:finish_date}, successCb); + } + return deferred.promise; + }] +}; diff --git a/brewman/templates/angular_base.mako b/brewman/templates/angular_base.mako index c1c19b0d..1e85cd64 100644 --- a/brewman/templates/angular_base.mako +++ b/brewman/templates/angular_base.mako @@ -70,6 +70,7 @@ + @@ -138,12 +139,13 @@