From 16b2e8dd514c1945930d46f5b13366ba058429bc Mon Sep 17 00:00:00 2001 From: Tanshu Date: Tue, 16 Oct 2012 15:02:36 +0530 Subject: [PATCH] Split the App js out or autocomplete.js into its own file. Removed dead routes not in use. Made the Home view angular. Product Ledger is not Angular --- Conversion/Converter.vshost.exe | Bin 11608 -> 0 bytes Conversion/Converter.vshost.exe.config | 34 ---- Conversion/Logs/converter.log | 0 brewman/brewman/__init__.py | 13 +- brewman/brewman/static/partial/home.html | 8 + brewman/brewman/static/partial/ledger.html | 30 +-- .../static/partial/product-ledger.html | 70 +++++++ .../brewman/static/scripts/angular_service.js | 77 +------- .../brewman/static/scripts/autocomplete.js | 65 +------ brewman/brewman/static/scripts/issue.js | 16 +- brewman/brewman/static/scripts/ledger.js | 12 ++ brewman/brewman/static/scripts/overlord.js | 71 +++++++ .../brewman/static/scripts/product-ledger.js | 18 ++ .../brewman/static/scripts/productledger.js | 28 --- brewman/brewman/templates/angular_base.mako | 8 +- brewman/brewman/templates/base.mako | 18 -- brewman/brewman/templates/home.mako | 9 - .../templates/reports/product_ledger.mako | 83 -------- brewman/brewman/views/__init__.py | 7 + brewman/brewman/views/other_views.py.exclude | 48 ----- brewman/brewman/views/pages.py | 35 ---- brewman/brewman/views/pages.py.exclude | 148 --------------- brewman/brewman/views/reports/ledger.py | 3 +- .../brewman/views/reports/product_ledger.py | 177 ++++++++---------- brewman/brewman/views/widgets.py | 31 --- 25 files changed, 302 insertions(+), 707 deletions(-) delete mode 100644 Conversion/Converter.vshost.exe delete mode 100644 Conversion/Converter.vshost.exe.config delete mode 100644 Conversion/Logs/converter.log create mode 100644 brewman/brewman/static/partial/home.html create mode 100644 brewman/brewman/static/partial/product-ledger.html create mode 100644 brewman/brewman/static/scripts/overlord.js create mode 100644 brewman/brewman/static/scripts/product-ledger.js delete mode 100644 brewman/brewman/static/scripts/productledger.js delete mode 100644 brewman/brewman/templates/home.mako delete mode 100644 brewman/brewman/templates/reports/product_ledger.mako delete mode 100644 brewman/brewman/views/other_views.py.exclude delete mode 100644 brewman/brewman/views/pages.py.exclude delete mode 100644 brewman/brewman/views/widgets.py diff --git a/Conversion/Converter.vshost.exe b/Conversion/Converter.vshost.exe deleted file mode 100644 index 58da5217c62dda7965cb039639e918719bda6107..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11608 zcmeHt30PCf(rBL~?6L_eB4F5L5yD9T0ohjp*(8V?ib)6%2uVl+h@wJ3kWq2mP+Som zH(XF0ab!?r6gS*O+?P>ja94CxaFoB!0R)$O@BH6;Z|=L_cN0CZtnjxYKMD&12Ha$(8z-MS`s#|oEjtWF545OmasuiPqX1jwZm5%_=^X@9q7m@|g9Y+*=;2$A`o-`1l z@q?f;wTq4IHV7H@wEdNw{)u(6w<^?w`;24A`P1Z3FHi>nZRA>k@4kr+vooYJDG!h& zZ$3~^hEEH=KFJ4~8B)Gb3>^uP5j-P;mOgxak`F?DeX3+}Dj`=$1aB0igpesh+d<|U zWSyLiXhu==F42;ee*%p1mbaUHPF_hXDztQapGTX z3A5qNFAdn1GS$1HUaWGdvL)qw>yW6J^9Ax#**W^>4{FpjKIk|?^{5RsJXn6gL$c+8 z<>5bBHy(LzzaDx{O?UItBBh&G#y#`8)4cE|YkhF7lBGi^^{mzJ6}v1pMoXa#)`rYSjSUHad?V3DjP(jlPa!4p3VLA!30rp3EWVsliI$8wK2(1Tb2J$8_TS>SZ ziK#8Ilxr3 z9v~a#0h~la9$EtB8E88|8A%}@wLp0udIN9?>co7|2AGeQOK7z#5wf#Fzk;;8wB3UZ zCks8jh{_qHNlF`v9^vAI3?bhOWy+GpGPxtmo+p&D82o8`6eyBQv!lcUksO5!cv7)U zoG53+3S=1^AzPl2AP_TxVFXxklvK>)%Va1`#uH100xn`_%jEnt6v<8D^W=!ZlZ&M& zoFfo*H!z|zL~=nIpAjOG^QB@5n=j2200rbPP6PS^u8{95hrPkgkn@p$7#q+Mp@1Wj z_hP$dU_|p1g)oIcEJD6A89$9H%#IPr`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0^6WZo8M_%%ad|sToPzZ%n}>`jF_y^ufK# zEppBN^)FNF;SSLq%YSw;=xb!~m_$=xXydhM<>yuGQkM9}KaH`AxO;o@oD=)b{;}m_ zzTl#R%2VY{sm1vscg=Zkp0zq^+FE?)+)}^G?2Wm@FP5+$W<_Vrs+5i4*_Df$8GpOuS@%X>!(Q!Yn+j z<}ACdW8i;i(!9mFCh3a4CIV3tVIqD9qP-c#*DC_lXIHU)ExW7o{`*rm(s$X%J5JPK z1Wo;U{e@BQ9<5uHwkB1-w(|4*LVPgZaHamR~( ztlWBija6s)AJw@{5AZwZ_r4yS%i`I*Dx-#0J$hS2PZ2CLx1Hc9Et|=x8RF`_P~-ID zo9b70rPfp~`>@)!yi{`Gmy>Fd+3T9i#x$Hglt1P5a)U#+G|Pk2HGf<-cRT(kWt_UZ zUiiE7c1^;EYm8qQ=o-f>-c7udT=>TQ1vd@79*~x+-P-WIPgALQ;=aQvp-#K?YjnOJ lxA=Gchi<}z)e+_@h9gSv{Zg73v2bUkT6*)MeZ+si`5$Qy{ObS! diff --git a/Conversion/Converter.vshost.exe.config b/Conversion/Converter.vshost.exe.config deleted file mode 100644 index 5fdb54fc..00000000 --- a/Conversion/Converter.vshost.exe.config +++ /dev/null @@ -1,34 +0,0 @@ - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Conversion/Logs/converter.log b/Conversion/Logs/converter.log deleted file mode 100644 index e69de29b..00000000 diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py index 75c6cc13..e406ba76 100644 --- a/brewman/brewman/__init__.py +++ b/brewman/brewman/__init__.py @@ -44,13 +44,6 @@ def main(global_config, **settings): config.add_route('login', '/login') config.add_route('logout', '/logout') - config.add_route('contact', '/contact') - config.add_route('json_test', '/json') - config.add_route('blog_add', '/blog/new') - config.add_route('blog_post', '/post/{id}') - config.add_route('blog', '/blog') - config.add_route('gallery', '/gallery') - config.add_route('upload_picture', '/upload') config.add_route('home', '/') config.add_route('cost_center_id', '/CostCenter/{id}') @@ -107,12 +100,12 @@ def main(global_config, **settings): config.add_route('ledger_id', '/Ledger/{id}') config.add_route('ledger', '/Ledger') + config.add_route('product_ledger_id', '/ProductLedger/{id}') + config.add_route('product_ledger', '/ProductLedger') + config.add_route('trial_balance_date', '/TrialBalance/{date}') config.add_route('trial_balance', '/TrialBalance') - config.add_route('product_ledger_id', '/Reports/ProductLedger/{id}') - config.add_route('product_ledger', '/Reports/ProductLedger') - config.add_route('cash_flow_id', '/Reports/CashFlow/{id}') config.add_route('cash_flow', '/Reports/CashFlow') diff --git a/brewman/brewman/static/partial/home.html b/brewman/brewman/static/partial/home.html new file mode 100644 index 00000000..e55e9fc9 --- /dev/null +++ b/brewman/brewman/static/partial/home.html @@ -0,0 +1,8 @@ +
+

Hello, world!

+ +

This is a template for a simple marketing or informational website. It includes a large callout called the hero + unit and three supporting pieces of content. Use it as a starting point to create something more unique.

+ +

Learn more »

+
diff --git a/brewman/brewman/static/partial/ledger.html b/brewman/brewman/static/partial/ledger.html index 0c39917e..5637b076 100644 --- a/brewman/brewman/static/partial/ledger.html +++ b/brewman/brewman/static/partial/ledger.html @@ -14,7 +14,7 @@
- +
@@ -35,24 +35,24 @@ - {{item.Date}} - {{item.Name}} - {{item.Type}} - {{item.Narration}} - {{item.Debit}} - {{item.Credit}} - {{item.Running}} + {{item.Date}} + {{item.Name}} + {{item.Type}} + {{item.Narration}} + {{item.Debit}} + {{item.Credit}} + {{item.Running}} - {{info.Footer.Date}} - {{info.Footer.Name}} - {{info.Footer.Type}} - {{info.Footer.Narration}} - {{info.Footer.Debit}} - {{info.Footer.Credit}} - {{info.Footer.Running}} + {{info.Footer.Date}} + {{info.Footer.Name}} + {{info.Footer.Type}} + {{info.Footer.Narration}} + {{info.Footer.Debit}} + {{info.Footer.Credit}} + {{info.Footer.Running}} diff --git a/brewman/brewman/static/partial/product-ledger.html b/brewman/brewman/static/partial/product-ledger.html new file mode 100644 index 00000000..e2df291b --- /dev/null +++ b/brewman/brewman/static/partial/product-ledger.html @@ -0,0 +1,70 @@ +
+ Product Ledger +
+ + +
+ + +
+
+
+ + +
+ + +
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DateParticularsTypeNarrationDebit QDebit ACredit QCredit ARunning QRunning A
{{item.Date}}{{item.Name}}{{item.Type}}{{item.Narration}}{{item.DebitQ}}{{item.DebitA}}{{item.CreditQ}}{{item.CreditA}}{{item.RunningQ}}{{item.RunningA}}
{{info.Footer.Date}}{{info.Footer.Name}}{{info.Footer.Type}}{{info.Footer.Narration}}{{info.Footer.DebitQ}}{{info.Footer.DebitA}}{{info.Footer.CreditQ}}{{info.Footer.CreditA}}{{info.Footer.RunningQ}}{{info.Footer.RunningA}}
+
+
+
diff --git a/brewman/brewman/static/scripts/angular_service.js b/brewman/brewman/static/scripts/angular_service.js index 84b2eb38..c7f3e518 100644 --- a/brewman/brewman/static/scripts/angular_service.js +++ b/brewman/brewman/static/scripts/angular_service.js @@ -1,72 +1,5 @@ var overlord_service = angular.module('overlord.service', ['ngResource']); -overlord_service.factory('get_voucher', ['$http', function ($http) { - return function (scope) { - $http.post('', scope.voucher). - success(function (data, status) { - scope.voucher = data; - scope.toasts.push({Type:'Success', Message:data.Code}); - }). - error(function (data, status) { - scope.toasts.push({Type:'Error', Message:data}); - }); - }; -}]); - -overlord_service.factory('save_voucher', ['$http', function ($http) { - return function (scope) { - $http.post('', scope.voucher). - success(function (data, status) { - scope.voucher = data; - scope.toasts.push({Type:'Success', Message:data.Code}); - }). - error(function (data, status) { - scope.toasts.push({Type:'Error', Message:data}); - }); - }; -}]); - -overlord_service.factory('delete_voucher', ['$http', function ($http) { - return function (scope) { - $http.post(delete_url, {}). - success(function (data, status) { - scope.voucher = {}; - scope.toasts.push({Type:'Success', Message:data.Code}); - }). - error(function (data, status) { - scope.toasts.push({Type:'Error', Message:data}); - }); - }; -}]); - -overlord_service.factory('post_voucher', ['$http', function ($http) { - return function (scope) { - $http.post(post_url, {}). - success(function (data, status) { - scope.voucher.Posted = true; - scope.voucher.Poster = data.name; - scope.toasts.push({Type:'Success', Message:data.Code}); - }). - error(function (data, status) { - scope.toasts.push({Type:'Error', Message:data}); - }); - }; -}]); - -overlord_service.factory('remove_toast', function () { - return function (toast) { - $http.post(post_url, {}). - success(function (data, status) { - scope.voucher.Posted = true; - scope.voucher.Poster = data.name; - scope.toasts.push({Type:'Success', Message:data.Code}); - }). - error(function (data, status) { - scope.toasts.push({Type:'Error', Message:data}); - }); - }; -}); - // TODO: Replace hardcoded url with route_url overlord_service.factory('issue_grid', ['$resource', function ($resource) { return $resource('/Issues/Services/:date'); @@ -93,6 +26,11 @@ overlord_service.factory('Ledger', ['$resource', function ($resource) { return $resource('/Ledger/:id'); }]); +// TODO: Replace hardcoded url with route_url +overlord_service.factory('ProductLedger', ['$resource', function ($resource) { + return $resource('/ProductLedger/:id'); +}]); + // TODO: Replace hardcoded url with route_url overlord_service.factory('Permission', ['$resource', function ($resource) { return $resource('/Permissions'); @@ -144,11 +82,6 @@ overlord_service.factory('CostCenter', ['$resource', function ($resource) { }]); -// TODO: Replace hardcoded url with route_url -overlord_service.factory('TrialBalance', ['$resource', function ($resource) { - return $resource('/TrialBalance/:date'); -}]); - // TODO: Replace hardcoded url with route_url overlord_service.factory('TrialBalance', ['$resource', function ($resource) { return $resource('/TrialBalance/:date'); diff --git a/brewman/brewman/static/scripts/autocomplete.js b/brewman/brewman/static/scripts/autocomplete.js index 33e32f1d..ff849582 100644 --- a/brewman/brewman/static/scripts/autocomplete.js +++ b/brewman/brewman/static/scripts/autocomplete.js @@ -1,50 +1,4 @@ -var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service']). - config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { - $routeProvider. - when('/Journal', {templateUrl: '/partial/journal.html', controller: JournalCtrl}). - when('/Journal/:id', {templateUrl: '/partial/journal.html', controller: JournalCtrl}). - - when('/Payment', {templateUrl: '/partial/payment.html', controller: PaymentCtrl}). - when('/Payment/:id', {templateUrl: '/partial/payment.html', controller: PaymentCtrl}). - - when('/Receipt', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}). - when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}). - - when('/Purchase', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl}). - when('/Purchase/:id', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl}). - - when('/Issue', {templateUrl: '/partial/issue.html', controller: IssueCtrl}). - when('/Issue/:id', {templateUrl: '/partial/issue.html', controller: IssueCtrl}). - - when('/Ledger', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}). - when('/Ledger/:id', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}). - - when('/TrialBalance', {templateUrl: '/partial/trial-balance.html', controller: TrialBalanceCtrl}). - when('/TrialBalance/:date', {templateUrl: '/partial/trial-balance.html', controller: TrialBalanceCtrl}). - - when('/Accounts', {templateUrl: '/partial/account-list.html', controller: AccountListCtrl}). - when('/Account', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl}). - when('/Account/:id', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl}). - - when('/CostCenters', {templateUrl: '/partial/cost-center-list.html', controller: CostCenterListCtrl}). - when('/CostCenter', {templateUrl: '/partial/cost-center-detail.html', controller: CostCenterCtrl}). - when('/CostCenter/:id', {templateUrl: '/partial/cost-center-detail.html', controller: CostCenterCtrl}). - - when('/Products', {templateUrl: '/partial/product-list.html', controller: ProductListCtrl}). - when('/Product', {templateUrl: '/partial/product-detail.html', controller: ProductCtrl}). - when('/Product/:id', {templateUrl: '/partial/product-detail.html', controller: ProductCtrl}). - - when('/ProductGroups', {templateUrl: '/partial/product-group-list.html', controller: ProductGroupListCtrl}). - when('/ProductGroup', {templateUrl: '/partial/product-group-detail.html', controller: ProductGroupCtrl}). - when('/ProductGroup/:id', {templateUrl: '/partial/product-group-detail.html', controller: ProductGroupCtrl}). - - when('/Users', {templateUrl: '/partial/user-list.html', controller: UserListCtrl}). - when('/User', {templateUrl: '/partial/user-detail.html', controller: UserCtrl}). - when('/User/:id', {templateUrl: '/partial/user-detail.html', controller: UserCtrl}); -// .otherwise({redirectTo: '/phones'}); - $locationProvider.html5Mode(true); -}]); -function AutoComplete(matchFieldName, lookupURL) { +function AutoComplete(matchFieldName, lookupURL) { $(matchFieldName).autocomplete({ source:function (request, response) { $.ajax({ @@ -66,20 +20,3 @@ function AutoComplete(matchFieldName, lookupURL) { autoFocus:true }); } - - - -function BaseCtrl($scope, Permission) { - $scope.perms = Permission.get(); - - $scope.toasts = []; - $scope.clearToast = function(item) { - var idx = $scope.toasts.indexOf(item); - if (idx !== -1) { - //injected into repeater scope by fadey directive - this.destroy(function() { - $scope.toasts.splice(idx, 1); - }); - } - }; -} diff --git a/brewman/brewman/static/scripts/issue.js b/brewman/brewman/static/scripts/issue.js index cf409d53..b4161e3a 100644 --- a/brewman/brewman/static/scripts/issue.js +++ b/brewman/brewman/static/scripts/issue.js @@ -1,5 +1,6 @@ function IssueCtrl($scope, $routeParams, $location, Voucher, CostCenter, issue_grid) { if (typeof $routeParams.id === 'undefined') { +// $scope.voucher = Voucher.get({type:'Issue', date:$routeParams.Date, source:$routeParams.Source, destination:$routeParams.Destination}); $scope.voucher = Voucher.get({type:'Issue'}); } else { $scope.voucher = Voucher.get({id:$routeParams.id}); @@ -60,7 +61,7 @@ } var doUpdate = false; - if (typeof oldJournals !== 'undefined' && typeof $scope.source === 'undefined' ) { + if (typeof oldJournals !== 'undefined' && typeof $scope.source === 'undefined') { for (var i = 0, l = oldJournals.length; i < l; i++) { if (oldJournals[i].Debit === -1) { $scope.source = oldJournals[i].CostCenter.CostCenterID; @@ -74,13 +75,13 @@ if (!doUpdate) { for (var i = 0, l = newJournals.length; i < l; i++) { if (newJournals[i].Debit === -1) { - if (newJournals[i].CostCenter.CostCenterID != $scope.source){ + if (newJournals[i].CostCenter.CostCenterID != $scope.source) { $scope.source = newJournals[i].CostCenter.CostCenterID; doUpdate = true; } } else { - if (newJournals[i].CostCenter.CostCenterID != $scope.destination){ + if (newJournals[i].CostCenter.CostCenterID != $scope.destination) { $scope.destination = newJournals[i].CostCenter.CostCenterID; doUpdate = true; } @@ -106,8 +107,9 @@ }, true); $scope.resetVoucher = function (voucherid) { +// $location.path('/Issue').search({Date:voucher.Date, Source:'', Destination:''}); $scope.voucher = Voucher.get({id:voucherid, type:'Issue'}, function (u, putResponseHeaders) { - $location.path('/Issue') + $location.path('/Issue'); }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); @@ -115,7 +117,7 @@ $scope.get = function (voucherid) { $scope.voucher = Voucher.get({id:voucherid}, function (u, putResponseHeaders) { - $location.path('/Issue/' + u.VoucherID) + $location.path('/Issue/' + u.VoucherID); }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); @@ -123,7 +125,7 @@ $scope.save = function () { $scope.voucher.$save(function (u, putResponseHeaders) { - $location.path('/Issue/' + u.VoucherID) + $location.path('/Issue/' + u.VoucherID); $scope.toasts.push({Type:'Success', Message:u.Code}); $scope.updateGrid(); }, function (data, status) { @@ -133,7 +135,7 @@ $scope.delete = function () { $scope.voucher.$delete(function (u, putResponseHeaders) { - $location.path('/Issue') + $location.path('/Issue').replace(); $scope.toasts.push({Type:'Success', Message:''}); $scope.updateGrid(); }, function (data, status) { diff --git a/brewman/brewman/static/scripts/ledger.js b/brewman/brewman/static/scripts/ledger.js index 147092c6..b40253b5 100644 --- a/brewman/brewman/static/scripts/ledger.js +++ b/brewman/brewman/static/scripts/ledger.js @@ -16,3 +16,15 @@ }; $('#txtLedger').focus(); } + +//LedgerCtrl.resolve = { +// ledger_data:function ($route, Ledger) { +// var params = $route.current.params; +// if (typeof params.id === 'undefined') { +// return Ledger.get({}); +// } else { +// return Ledger.get({id:params.id, StartDate:params.StartDate, FinishDate:params.FinishDate}); +// +// } +// } +//} \ No newline at end of file diff --git a/brewman/brewman/static/scripts/overlord.js b/brewman/brewman/static/scripts/overlord.js new file mode 100644 index 00000000..adf5c212 --- /dev/null +++ b/brewman/brewman/static/scripts/overlord.js @@ -0,0 +1,71 @@ +'use strict'; + +var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service']). + config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { + $routeProvider. + when('/', {templateUrl:'/partial/home.html'}). + + when('/Journal', {templateUrl:'/partial/journal.html', controller:JournalCtrl}). + when('/Journal/:id', {templateUrl:'/partial/journal.html', controller:JournalCtrl}). + + when('/Payment', {templateUrl:'/partial/payment.html', controller:PaymentCtrl}). + when('/Payment/:id', {templateUrl:'/partial/payment.html', controller:PaymentCtrl}). + + when('/Receipt', {templateUrl:'/partial/receipt.html', controller:ReceiptCtrl}). + when('/Receipt/:id', {templateUrl:'/partial/receipt.html', controller:ReceiptCtrl}). + + when('/Purchase', {templateUrl:'/partial/purchase.html', controller:PurchaseCtrl}). + when('/Purchase/:id', {templateUrl:'/partial/purchase.html', controller:PurchaseCtrl}). + + when('/Issue', {templateUrl:'/partial/issue.html', controller:IssueCtrl}). + when('/Issue/:id', {templateUrl:'/partial/issue.html', controller:IssueCtrl}). + + when('/Ledger', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl}). + when('/Ledger/:id', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl}). + + when('/ProductLedger', {templateUrl:'/partial/product-ledger.html', controller:ProductLedgerCtrl}). + when('/ProductLedger/:id', {templateUrl:'/partial/product-ledger.html', controller:ProductLedgerCtrl}). + +// when('/Ledger', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl, resolve: LedgerCtrl.resolve}). +// when('/Ledger/:id', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl, resolve: LedgerCtrl.resolve}). + + when('/TrialBalance', {templateUrl:'/partial/trial-balance.html', controller:TrialBalanceCtrl}). + when('/TrialBalance/:date', {templateUrl:'/partial/trial-balance.html', controller:TrialBalanceCtrl}). + + when('/Accounts', {templateUrl:'/partial/account-list.html', controller:AccountListCtrl}). + when('/Account', {templateUrl:'/partial/account-detail.html', controller:AccountCtrl}). + when('/Account/:id', {templateUrl:'/partial/account-detail.html', controller:AccountCtrl}). + + when('/CostCenters', {templateUrl:'/partial/cost-center-list.html', controller:CostCenterListCtrl}). + when('/CostCenter', {templateUrl:'/partial/cost-center-detail.html', controller:CostCenterCtrl}). + when('/CostCenter/:id', {templateUrl:'/partial/cost-center-detail.html', controller:CostCenterCtrl}). + + when('/Products', {templateUrl:'/partial/product-list.html', controller:ProductListCtrl}). + when('/Product', {templateUrl:'/partial/product-detail.html', controller:ProductCtrl}). + when('/Product/:id', {templateUrl:'/partial/product-detail.html', controller:ProductCtrl}). + + when('/ProductGroups', {templateUrl:'/partial/product-group-list.html', controller:ProductGroupListCtrl}). + when('/ProductGroup', {templateUrl:'/partial/product-group-detail.html', controller:ProductGroupCtrl}). + when('/ProductGroup/:id', {templateUrl:'/partial/product-group-detail.html', controller:ProductGroupCtrl}). + + when('/Users', {templateUrl:'/partial/user-list.html', controller:UserListCtrl}). + when('/User', {templateUrl:'/partial/user-detail.html', controller:UserCtrl}). + when('/User/:id', {templateUrl:'/partial/user-detail.html', controller:UserCtrl}); +// .otherwise({redirectTo: '/phones'}); + $locationProvider.html5Mode(true); +}]); + +function BaseCtrl($scope, Permission) { + $scope.perms = Permission.get(); + + $scope.toasts = []; + $scope.clearToast = function (item) { + var idx = $scope.toasts.indexOf(item); + if (idx !== -1) { + //injected into repeater scope by fadey directive + this.destroy(function () { + $scope.toasts.splice(idx, 1); + }); + } + }; +} diff --git a/brewman/brewman/static/scripts/product-ledger.js b/brewman/brewman/static/scripts/product-ledger.js new file mode 100644 index 00000000..61ee1703 --- /dev/null +++ b/brewman/brewman/static/scripts/product-ledger.js @@ -0,0 +1,18 @@ +function ProductLedgerCtrl($scope, $routeParams, $location, ProductLedger) { + if (typeof $routeParams.id === 'undefined') { + $scope.info = ProductLedger.get({}); + } else { + $scope.info = ProductLedger.get({id:$routeParams.id, StartDate:$routeParams.StartDate, FinishDate:$routeParams.FinishDate}); + + } + $scope.show = function () { + $scope.info = ProductLedger.get({id:$scope.info.Product.ProductID, StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate}, function (u, putResponseHeaders) { + $location.path('/ProductLedger/' + u.Product.ProductID); + $location.search('StartDate', u.StartDate); + $location.search('FinishDate', u.FinishDate); + }, function (data, status) { + $scope.toasts.push({Type:'Error', Message:data.data}); + }); + }; + $('#txtProduct').focus(); +} diff --git a/brewman/brewman/static/scripts/productledger.js b/brewman/brewman/static/scripts/productledger.js deleted file mode 100644 index 8007f153..00000000 --- a/brewman/brewman/static/scripts/productledger.js +++ /dev/null @@ -1,28 +0,0 @@ -function Populate(vouchers, editUrl) { - if (vouchers != null) { - var stateObj = { 'LedgerID':vouchers.id, 'Name':vouchers.name, 'StartDate':vouchers.start_date, 'FinishDate':vouchers.finish_date }; - history.pushState(stateObj, 'Display', vouchers.url); - $('#txtProduct').val(vouchers.name); - $('#tbodyMain').html(vouchers.body); - $('#tfootMain').html(vouchers.footer); - } -} - -function Show(productString, productID, startDate, finishDate) { - $.ajax({ - type:"POST", - contentType:"application/json; charset=utf-8", - url:show_url, - data:JSON.stringify({ productString:productString, productID: productID, startDate:startDate, finishDate:finishDate }), - dataType:"json", - success:function (response) { - Populate(response); - }, - error:function (jqXHR, textStatus) { - $("#ctl00_statusDiv").removeClass().addClass("error"); - var msg = $.parseJSON(jqXHR.responseText).Message; - $("#ctl00_statusDiv").html(msg); - } - }); - return false; -} diff --git a/brewman/brewman/templates/angular_base.mako b/brewman/brewman/templates/angular_base.mako index 11c9eabf..d414a59e 100644 --- a/brewman/brewman/templates/angular_base.mako +++ b/brewman/brewman/templates/angular_base.mako @@ -26,12 +26,7 @@ ${h.JsLink(request, 'angular-1.0.1.js')} ${h.JsLink(request, 'angular-resource-1.0.1.js')} - - - ${h.ScriptLink(request, 'autocomplete.js')} + ${h.ScriptLink(request, 'overlord.js')} ${h.ScriptLink(request, 'angular_directive.js')} ${h.ScriptLink(request, 'angular_filter.js')} ${h.ScriptLink(request, 'angular_service.js')} @@ -44,6 +39,7 @@ ${h.ScriptLink(request, 'issue.js')} ${h.ScriptLink(request, 'ledger.js')} + ${h.ScriptLink(request, 'product-ledger.js')} ${h.ScriptLink(request, 'trial_balance.js')} ${h.ScriptLink(request, 'account.js')} diff --git a/brewman/brewman/templates/base.mako b/brewman/brewman/templates/base.mako index 2b84378c..dba9acc3 100644 --- a/brewman/brewman/templates/base.mako +++ b/brewman/brewman/templates/base.mako @@ -31,26 +31,8 @@ ${h.ScriptLink(request, 'autocomplete.js')} - ${h.ScriptLink(request, 'angular_directive.js')} - ${h.ScriptLink(request, 'angular_filter.js')} - ${h.ScriptLink(request, 'angular_service.js')} ${h.ScriptLink(request, 'session.js')} - ${h.ScriptLink(request, 'journal.js')} - ${h.ScriptLink(request, 'payment.js')} - ${h.ScriptLink(request, 'receipt.js')} - ${h.ScriptLink(request, 'purchase.js')} - ${h.ScriptLink(request, 'issue.js')} - - ${h.ScriptLink(request, 'ledger.js')} - ${h.ScriptLink(request, 'trial_balance.js')} - - ${h.ScriptLink(request, 'account.js')} - ${h.ScriptLink(request, 'user.js')} - ${h.ScriptLink(request, 'cost-center.js')} - ${h.ScriptLink(request, 'product.js')} - ${h.ScriptLink(request, 'product-group.js')} - <%block name="header" /> diff --git a/brewman/brewman/templates/home.mako b/brewman/brewman/templates/home.mako deleted file mode 100644 index 038b172b..00000000 --- a/brewman/brewman/templates/home.mako +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="base.mako"/> -<%block name="content"> -
-

Hello, world!

-

This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.

-

Learn more »

-
- diff --git a/brewman/brewman/templates/reports/product_ledger.mako b/brewman/brewman/templates/reports/product_ledger.mako deleted file mode 100644 index a5a7cd3a..00000000 --- a/brewman/brewman/templates/reports/product_ledger.mako +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="../base.mako"/> -<%block name="header"> - ${h.ScriptLink(request, 'productledger.js')} - - -<%block name="content"> -

Product Ledger

-
- ${h.CsrfToken(request.session)} -

- ${h.Label('Start Date:', 'txtStartDate')} - ${h.TextInput('txtStartDate', css_class = 'non-search-box', autocomplete='off')} -

- -

- ${h.Label('Finish Date:', 'txtFinishDate')} - ${h.TextInput('txtFinishDate', css_class = 'non-search-box', autocomplete='off')} -

- -

- ${h.Label('Product:', 'txtProduct')} - ${h.TextInput('txtProduct', css_class = 'search-box', autocomplete='off', placeholder='Product')} - ${h.SubmitButton('btnSubmit', 'Submit')} -

- -

- - - - - - - - - - - - - - - - - ${body} - - - ${footer} - -
DateParticularsTypeNarrationDebitDebitCreditCreditRunningRunning
-

-
- \ No newline at end of file diff --git a/brewman/brewman/views/__init__.py b/brewman/brewman/views/__init__.py index 0de9dd23..2e3573ad 100644 --- a/brewman/brewman/views/__init__.py +++ b/brewman/brewman/views/__init__.py @@ -1,6 +1,13 @@ from decimal import Decimal import json import uuid +from pyramid.view import view_config + +@view_config(route_name='home', renderer='brewman:templates/angular_base.mako') +def home(request): + return {} + + class DecimalAsFloatHack(float): def __init__(self, d): diff --git a/brewman/brewman/views/other_views.py.exclude b/brewman/brewman/views/other_views.py.exclude deleted file mode 100644 index c4af01dc..00000000 --- a/brewman/brewman/views/other_views.py.exclude +++ /dev/null @@ -1,48 +0,0 @@ -from brewman.models import DBSession, BeerType, Brew - - -def list_beer_types(request): - dbsession = DBSession() - list = dbsession.query(BeerType).all() - return {'list':list, 'project':'brewman'} - -def show_beer_type(request): - id = request.matchdict['id'] - dbsession = DBSession() - item = dbsession.query(BeerType).filter(BeerType.id==id).one() - return {'item':item, 'title':item.name, 'project':'brewman', 'top_block': page_title_and_breadcrumb(request)} - -def add_beer_type(request): -# id = request.matchdict['id'] -# dbsession = DBSession() -# item = dbsession.query(BeerType).filter_by(id==id).one() - return {'title':'Add Beer Style', 'pageclass': "class page-contacts page-sidebar-right", 'top_block': page_title_and_breadcrumb(request)} - -def edit_beer_type(request): - id = request.matchdict['id'] - dbsession = DBSession() - item = dbsession.query(BeerType).filter_by(id==id).one() - return {'item':item, 'project':'brewman'} - -def list_brews(request): - dbsession = DBSession() - list = dbsession.query(Brew).all() - return {'list':list, 'project':'brewman'} - -def show_brew(request): - id = request.matchdict['id'] - dbsession = DBSession() - item = dbsession.query(Brew).filter_by(id==id).one() - return {'item':item, 'project':'brewman'} - -def add_brew(request): - id = request.matchdict['id'] - dbsession = DBSession() - item = dbsession.query(Brew).filter_by(id==id).one() - return {'item':item, 'project':'brewman'} - -def edit_brew(request): - id = request.matchdict['id'] - dbsession = DBSession() - item = dbsession.query(Brew).filter_by(id==id).one() - return {'item':item, 'project':'brewman'} diff --git a/brewman/brewman/views/pages.py b/brewman/brewman/views/pages.py index 3ad5d020..19af8f6d 100644 --- a/brewman/brewman/views/pages.py +++ b/brewman/brewman/views/pages.py @@ -6,43 +6,8 @@ from pyramid.security import remember, forget from pyramid.view import view_config from brewman.models.auth import User -from brewman.views.widgets import footer, contact_widget, recent_posts, categories, archive -@view_config(route_name='home', renderer='brewman:templates/home.mako') -def home(request): - return {'title': 'Hops n Grains - Welcome'} - - -@view_config(route_name='contact', renderer='brewman:templates/contact.pt') -def contact(request): - return {'title': 'Hops n Grains - Contact Us', - 'pageclass': "page-contacts page-sidebar-right skin-5", - 'pagecontentclass': "page-content grid_8", - 'top_block': breadcrumb(request, "Contacts", "Feel free to contact us any time."), - 'widget1': recent_posts(request), - 'wid1': "grid_6", - 'widget2': categories(request), - 'wid2': "grid_3", - 'widget3': archive(request), - 'wid3': "grid_3", - 'footer': footer(request)} - - -@view_config(route_name='gallery', renderer='brewman:templates/gallery.pt') -def gallery(request): - return {'title': 'Hops n Grains - Gallery', - 'pageclass': "page-gallery", - 'pagecontentclass': "page-content", - 'top_block': breadcrumb(request, "Gallery", "Nice and clean gallery grid."), - 'widget1': tweets(request), - 'wid1': "grid_4", - 'widget2': categories(request), - 'wid2': "grid_4", - 'widget3': contact_widget(request), - 'wid3': "grid_4", - 'footer': footer(request), - 'widget_comments': comments(request)} @view_config(context=HTTPNotFound, renderer='brewman:templates/404.mako') diff --git a/brewman/brewman/views/pages.py.exclude b/brewman/brewman/views/pages.py.exclude deleted file mode 100644 index 463b9b0a..00000000 --- a/brewman/brewman/views/pages.py.exclude +++ /dev/null @@ -1,148 +0,0 @@ -import os -import random -import transaction - -from pyramid.httpexceptions import HTTPNotFound, HTTPFound -from pyramid.response import Response -from pyramid.security import authenticated_userid, remember, forget -from pyramid.view import view_config - -from brewman.models import DBSession, UploadedImage, User - -from brewman.views.top_parts import slidernivo, breadcrumb, slider3d, slideraccordion, slidercarousel, sliderstatic, randomslider -from brewman.views.widgets import footer, widget_gallery, tweets, contact_widget, archive, categories, recent_posts, comments, blog_roll, events - - -@view_config(request_method='POST', route_name='upload_picture', renderer='brewman:templates/upload_picture.pt') -def upload_picture_submit(request): - filename = request.POST['picture'].filename - input_file = request.POST['picture'].file - comment = request.POST['comment'] - size = request.POST['size'] - file_path = os.getcwd() + '\\brewman\\static\\pictures\\' + filename - output_file = open(file_path, 'wb') - input_file.seek(0) - while 1: - data = input_file.read(2<<16) - if not data: - break - output_file.write(data) - output_file.close() - - session = DBSession() - pinf = UploadedImage(location='brewman:static/pictures/' + filename, comment=comment, size=size) - session.add(pinf) - session.flush() - transaction.commit() - - return Response(pinf.comment) - -@view_config(request_method='GET', route_name='upload_picture', renderer='brewman:templates/upload_picture.pt') -def upload_picture(request): - return {'title':'Hops n Grains - Upload a picture', - 'pageclass': "page-frontpage skin-4", - 'pagecontentclass': "page-content", - 'top_block': randomslider(request), - 'widget1': widget_gallery(request), - 'wid1': "grid_4", - 'widget2': tweets(request), - 'wid2': "grid_4", - 'widget3': contact_widget(request), - 'wid3': "grid_4", - 'footer': footer(request)} - -@view_config(route_name='home', renderer='brewman:templates/home.pt') -def home(request): - return {'title':'Hops n Grains - Welcome', - 'pageclass': "page-frontpage skin-2", - 'pagecontentclass': "page-content", - 'top_block': randomslider(request), - 'widget1': widget_gallery(request), - 'wid1': "grid_4", - 'widget2': tweets(request), - 'wid2': "grid_4", - 'widget3': contact_widget(request), - 'wid3': "grid_4", - 'footer': footer(request)} - -@view_config(route_name='contact', renderer='brewman:templates/contact.pt') -def contact(request): - return {'title':'Hops n Grains - Contact Us', - 'pageclass': "page-contacts page-sidebar-right skin-5", - 'pagecontentclass': "page-content grid_8", - 'top_block': breadcrumb(request, "Contacts", "Feel free to contact us any time."), - 'widget1': recent_posts(request), - 'wid1': "grid_6", - 'widget2': categories(request), - 'wid2': "grid_3", - 'widget3': archive(request), - 'wid3': "grid_3", - 'footer': footer(request)} - -@view_config(route_name='gallery', renderer='brewman:templates/gallery.pt') -def gallery(request): - return {'title':'Hops n Grains - Gallery', - 'pageclass': "page-gallery", - 'pagecontentclass': "page-content", - 'top_block': breadcrumb(request, "Gallery", "Nice and clean gallery grid."), - 'widget1': tweets(request), - 'wid1': "grid_4", - 'widget2': categories(request), - 'wid2': "grid_4", - 'widget3': contact_widget(request), - 'wid3': "grid_4", - 'footer': footer(request), - 'widget_comments': comments(request)} - -@view_config(context=HTTPNotFound, renderer='brewman:templates/404.pt') -def not_found(request): - return {'title':'Hops n Grains - 404', - 'pageclass': "page-404 skin-9", - 'pagecontentclass': "page-content", - 'top_block': "", - 'widget1': tweets(request), - 'wid1': "grid_4", - 'widget2': recent_posts(request), - 'wid2': "grid_4", - 'widget3': contact_widget(request), - 'wid3': "grid_4", - 'footer': footer(request)} - -@view_config(request_method='POST', route_name='login', renderer='brewman:templates/login.pt') -def login_submit(request): - username = request.POST['username'] - password = request.POST['password'] - - found, user = User.check_password(username, password) - if found == True: - headers = remember(request, user.id) - request.session.flash(u'Logged in successfully.') - return HTTPFound(location=request.route_url('home'), headers=headers) - else: - return Response('Login Failure') - -@view_config(request_method='GET', route_name='login', renderer='brewman:templates/login.pt') -def login(request): - return {'title':'Hops n Grains - Login', - 'pageclass': "page-gallery skin-7", - 'pagecontentclass': "page-content", - 'top_block': breadcrumb(request, "Login", "This is the place to login."), - 'widget1': tweets(request), - 'wid1': "grid_4", - 'widget2': recent_posts(request), - 'wid2': "grid_4", - 'widget3': contact_widget(request), - 'wid3': "grid_4", - 'footer': footer(request)} - -@view_config(route_name='logout') -def logout(request): - request.session.invalidate() - request.session.flash(u'Logged out successfully.') - headers = forget(request) - return HTTPFound(location=request.route_url('home'), headers=headers) - -@view_config(request_method='POST', route_name='json_test', renderer='json', http_cache=0, xhr=True) -def json_test(request): - rand = random.randrange(1, 400, 1) - return {'myid': rand} diff --git a/brewman/brewman/views/reports/ledger.py b/brewman/brewman/views/reports/ledger.py index 6f209bc7..643f83d0 100644 --- a/brewman/brewman/views/reports/ledger.py +++ b/brewman/brewman/views/reports/ledger.py @@ -114,7 +114,6 @@ def opening_balance(ledgerID, start_date): creditShow = "" runningTotal = opening running = "\u20B9 {0:,.2f}".format(abs(runningTotal)) + (' Dr' if runningTotal >= 0 else ' Cr') - voucher_type = VoucherType.by_name('Opening Balance') - return debit, credit, runningTotal, {'Date': start_date, 'Name': voucher_type.name, 'Type': voucher_type.name, + return debit, credit, runningTotal, {'Date': start_date, 'Name': 'Opening Balance', 'Type': 'Opening Balance', 'Narration': '', 'Debit': debitShow, 'Credit': creditShow, 'Running': running, 'Posted': True} diff --git a/brewman/brewman/views/reports/product_ledger.py b/brewman/brewman/views/reports/product_ledger.py index a8c339d7..e9064d22 100644 --- a/brewman/brewman/views/reports/product_ledger.py +++ b/brewman/brewman/views/reports/product_ledger.py @@ -10,31 +10,28 @@ from brewman.models import DBSession from brewman.models.master import Product, CostCenter from brewman.models.voucher import Voucher, Journal, VoucherType, Inventory +from brewman.views.services.session import services_session_period_start, services_session_period_finish from brewman.views.transactions import get_edit_url -@view_config(request_method='GET', route_name='product_ledger_id', - renderer='brewman:templates/reports/product_ledger.mako') -@view_config(request_method='GET', route_name='product_ledger', renderer='brewman:templates/reports/product_ledger.mako') +@view_config(request_method='GET', route_name='product_ledger_id', renderer='brewman:templates/angular_base.mako', + xhr=False) +@view_config(request_method='GET', route_name='product_ledger', renderer='brewman:templates/angular_base.mako', + xhr=False) +def ledger_display_get(request): + return {} + + def product_ledger_get(request): product_id = request.matchdict.get('id', None) - if product_id is None: - body = "" - footer = "" - product = "" - startDate = Literal( - "StartDate('#txtStartDate', '{0}');".format(request.route_url('services_session_period_start'))) - finishDate = Literal( - "FinishDate('#txtFinishDate', '{0}');".format(request.route_url('services_session_period_finish'))) - else: - product = Product.by_id(uuid.UUID(product_id)) - startDate = request.GET.get('startDate', None) - finishDate = request.GET.get('finishDate', None) - report = build_report(request, product, startDate, finishDate) - body = Literal(report['body']) - footer = Literal(report['footer']) - startDate = Literal("$('#txtStartDate').val('{0}');".format(startDate)) - finishDate = Literal("$('#txtFinishDate').val('{0}');".format(finishDate)) - product = Literal("$('#txtProduct').val('{0}');".format(product.full_name)) + product = Product.by_id(uuid.UUID(product_id)) + startDate = request.GET.get('startDate', None) + finishDate = request.GET.get('finishDate', None) + report = build_report(request, product, startDate, finishDate) + body = Literal(report['body']) + footer = Literal(report['footer']) + startDate = Literal("$('#txtStartDate').val('{0}');".format(startDate)) + finishDate = Literal("$('#txtFinishDate').val('{0}');".format(finishDate)) + product = Literal("$('#txtProduct').val('{0}');".format(product.full_name)) return {'title': 'Display Ledger - Hops n Grains', 'pageclass': "page-blogpost page-sidebar-right", @@ -47,6 +44,24 @@ def product_ledger_get(request): 'product': product} +@view_config(request_method='GET', route_name='product_ledger_id', renderer='json', xhr=True) +@view_config(request_method='GET', route_name='product_ledger', renderer='json', xhr=True) +def ledger_display_post(request): + id = request.matchdict.get('id', None) + if id is None: + return {'StartDate': services_session_period_start(request), + 'FinishDate': services_session_period_finish(request), 'Product': {}, 'Body': [], 'Footer': {}} + else: + product = Product.by_id(uuid.UUID(id)) + start_date = request.GET.get('StartDate', services_session_period_start(request)) + finish_date = request.GET.get('FinishDate', services_session_period_finish(request)) + info = {'StartDate': start_date, 'FinishDate': finish_date, + 'Product': {'ProductID': product.id, 'Name': product.name}, + 'Body': [], 'Footer': {}} + build_report(request, info) + return info + + @view_config(request_method='POST', route_name='product_ledger', renderer='json', xhr=True) def product_ledger_post(request): productID = request.json_body['productID'] @@ -61,113 +76,81 @@ def product_ledger_post(request): return build_report(request, product, startDate, finishDate) -def build_report(request, product, startDate, finishDate): - body = '' - totalDebitQuantity, totalDebitAmount, totalCreditQuantity, totalCreditAmount, runningTotalQuantity, runningTotalAmount, opening = opening_balance( - product.id, startDate) - body += opening +def build_report(request, info): + product_id = info['Product']['ProductID'] + start_date = info['StartDate'] + finish_date = info['FinishDate'] + + runningTotalQ, runningTotalA, opening = opening_balance(product_id, start_date) + totalDebitQ = runningTotalQ + totalDebitA = runningTotalA + totalCreditQ = 0 + totalCreditA = 0 + + info['Body'].append(opening) query = DBSession.query(Voucher, Inventory, Journal).options( joinedload(Journal.ledger, innerjoin=True), joinedload(Journal.costcenter, innerjoin=True))\ .filter(Voucher.id == Inventory.voucher_id)\ .filter(Voucher.id == Journal.voucher_id)\ - .filter(Inventory.product_id == product.id)\ + .filter(Inventory.product_id == product_id)\ .filter(Journal.cost_center_id != CostCenter.cost_center_purchase())\ - .filter(Voucher.date >= datetime.datetime.strptime(startDate, '%d-%b-%Y'))\ - .filter(Voucher.date <= datetime.datetime.strptime(finishDate, '%d-%b-%Y'))\ + .filter(Voucher.date >= datetime.datetime.strptime(start_date, '%d-%b-%Y'))\ + .filter(Voucher.date <= datetime.datetime.strptime(finish_date, '%d-%b-%Y'))\ .order_by(Voucher.date).order_by(Voucher.last_edit_date).all() for row in query: journalDebit = row.Journal.debit * -1 name = row.Journal.costcenter.name if row.Voucher.type == VoucherType.by_name( 'Issue').id else row.Journal.ledger.name - debitQuantity = "{0:.2f}".format(row.Inventory.quantity) if journalDebit == 1 else "" - debitAmount = "\u20B9 {0:.2f}".format(row.Inventory.amount) if journalDebit == 1 else "" - creditQuantity = "{0:.2f}".format(row.Inventory.quantity) if journalDebit != 1 else "" - creditAmount = "\u20B9 {0:.2f}".format(row.Inventory.amount) if journalDebit != 1 else "" + debitQ = "{0:.2f}".format(row.Inventory.quantity) if journalDebit == 1 else "" + debitA = "\u20B9 {0:.2f}".format(row.Inventory.amount) if journalDebit == 1 else "" + creditQ = "{0:.2f}".format(row.Inventory.quantity) if journalDebit != 1 else "" + creditA = "\u20B9 {0:.2f}".format(row.Inventory.amount) if journalDebit != 1 else "" - runningTotalQuantity += (row.Inventory.quantity * journalDebit) - runningTotalAmount += (row.Inventory.amount * journalDebit) + runningTotalQ += (row.Inventory.quantity * journalDebit) + runningTotalA += (row.Inventory.amount * journalDebit) if journalDebit == 1: - totalDebitQuantity += row.Inventory.quantity - totalDebitAmount += row.Inventory.amount + totalDebitQ += row.Inventory.quantity + totalDebitA += row.Inventory.amount else: - totalCreditQuantity += row.Inventory.quantity - totalCreditAmount += row.Inventory.amount + totalCreditQ += row.Inventory.quantity + totalCreditA += row.Inventory.amount - name = '' + name + '' - body += '{1}{2}'\ - '{3}{4}{5}'\ - '{6}{7}{8}'\ - '{9:.2f}\u20B9 {10:.2f}'\ - .format(str(row.Voucher.id), row.Voucher.date.strftime('%d-%b-%Y'), name, - VoucherType.by_id(row.Voucher.type).name, row.Voucher.narration, debitQuantity, debitAmount, - creditQuantity, creditAmount, runningTotalQuantity, runningTotalAmount) + info['Body'].append( + {'Date': row.Voucher.date.strftime('%d-%b-%Y'), 'Name': name, 'Url': get_edit_url(request, row.Voucher), + 'Type': VoucherType.by_id(row.Voucher.type).name, 'Narration': row.Voucher.narration, 'DebitQ': debitQ, + 'DebitA': debitA, + 'CreditQ': creditQ, 'CreditA': creditA, 'RunningQ': "{0:.2f}".format(runningTotalQ), + 'RunningA': "\u20B9 {0:.2f}".format(runningTotalA)}) - voucher_type = VoucherType.by_name('Closing Balance') - footer = '{0}{1}'\ - '{1}{2:.2f}'\ - '\u20B9 {3:.2f}{4:.2f}'\ - '\u20B9 {5:.2f}{6:.2f}'\ - '\u20B9 {7:.2f}'\ - .format(finishDate, voucher_type.name, totalDebitQuantity, totalDebitAmount, - totalCreditQuantity, totalCreditAmount, runningTotalQuantity, runningTotalAmount) - - return {'body': body, 'footer': footer, 'start_date': startDate, 'finish_date': finishDate, 'id': str(product.id), - 'name': product.full_name, 'url': request.route_url('product_ledger_id', id=str(product.id), - _query={'startDate': startDate, 'finishDate': finishDate})} + info['Footer'] = {'Date': finish_date, 'Name': 'Closing Balance', 'Type': 'Closing Balance', 'Narration': '', + 'DebitQ': "{0:,.2f}".format(totalDebitQ), 'DebitA': "\u20B9 {0:,.2f}".format(totalDebitA), + 'CreditQ': "{0:,.2f}".format(totalCreditQ), 'CreditA': "\u20B9 {0:,.2f}".format(totalCreditA), + 'RunningQ': "{0:,.2f}".format(runningTotalQ), 'RunningA': "\u20B9 {0:,.2f}".format(runningTotalA)} -def opening_balance(productID, startDate): - runningTotalQuantity = 0 - runningTotalAmount = 0 - totalDebitQuantity = 0 - totalDebitAmount = 0 - totalCreditQuantity = 0 - totalCreditAmount = 0 - +def opening_balance(product_id, start_date): quantity, amount = DBSession.query(func.sum(Inventory.quantity * Journal.debit), func.sum(Inventory.amount * Journal.debit))\ .join(Voucher)\ .filter(Voucher.id == Inventory.voucher_id)\ .filter(Voucher.id == Journal.voucher_id)\ - .filter(Inventory.product_id == productID)\ + .filter(Inventory.product_id == product_id)\ .filter(Journal.cost_center_id == CostCenter.cost_center_purchase())\ - .filter(Voucher.date < datetime.datetime.strptime(startDate, '%d-%b-%Y'))\ + .filter(Voucher.date < datetime.datetime.strptime(start_date, '%d-%b-%Y'))\ .one() - if quantity is None or quantity == 0: - debitQuantity = "" - debitAmount = "" - creditQuantity = "" - creditAmount = "" - else: - debitQuantity = "{0:.2f}".format(quantity) if quantity > 0 else "" - debitAmount = "\u20B9 {0:.2f}".format(amount) if quantity > 0 else "" - creditQuantity = "{0:.2f}".format(quantity) if quantity < 0 else "" - creditAmount = "\u20B9 {0:.2f}".format(amount) if quantity < 0 else "" + if quantity and quantity > 0: + debitQuantity = "{0:.2f}".format(quantity) + debitAmount = "\u20B9 {0:.2f}".format(amount) if quantity is None: quantity = 0 amount = 0 - runningTotalQuantity = quantity - runningTotalAmount = amount - if quantity < 0: - totalCreditQuantity = quantity * -1 - totalCreditAmount = amount * -1 - else: - totalDebitQuantity = quantity - totalDebitAmount = amount - voucher_type = VoucherType.by_name('Opening Balance') - return totalDebitQuantity, totalDebitAmount, totalCreditQuantity, totalCreditAmount, runningTotalQuantity,\ - runningTotalAmount,\ - '{0}{1}'\ - '{1}{2}'\ - '{3}{4}'\ - '{5}{6:.2f}'\ - '\u20B9 {7:.2f}'\ - .format(startDate, voucher_type.name, debitQuantity, debitAmount, - creditQuantity, creditAmount, runningTotalQuantity, runningTotalAmount) \ No newline at end of file + return quantity, amount, {'Date': start_date, 'Name': 'Opening Balance', 'Type': 'Opening Balance', 'Narration': '', + 'DebitQ': debitQuantity, 'DebitA': debitAmount, 'RunningQ': quantity, 'RunningA': amount} + diff --git a/brewman/brewman/views/widgets.py b/brewman/brewman/views/widgets.py deleted file mode 100644 index 7c16517d..00000000 --- a/brewman/brewman/views/widgets.py +++ /dev/null @@ -1,31 +0,0 @@ -from pyramid.renderers import render - -def footer(request): - return render('brewman:templates/widgets/footer.pt', {'request': request}) - -def widget_gallery(request): - return render('brewman:templates/widgets/gallery.pt', {'request': request}) - -def tweets(request): - return render('brewman:templates/widgets/tweets.pt', {'request': request}) - -def contact_widget(request): - return render('brewman:templates/widgets/contact.pt', {'request': request}) - -def archive(request): - return render('brewman:templates/widgets/archive.pt', {'request': request}) - -def categories(request): - return render('brewman:templates/widgets/categories.pt', {'request': request}) - -def recent_posts(request): - return render('brewman:templates/widgets/recent_posts.pt', {'request': request}) - -def comments(request): - return render('brewman:templates/widgets/comments.pt', {'request': request}) - -def blog_roll(request): - return render('brewman:templates/widgets/blog_roll.pt', {'request': request}) - -def events(request): - return render('brewman:templates/widgets/events.pt', {'request': request})