diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py index 9d54dc2c..75c6cc13 100644 --- a/brewman/brewman/__init__.py +++ b/brewman/brewman/__init__.py @@ -137,15 +137,11 @@ def main(global_config, **settings): config.add_route('services_products', '/Services/Products') config.add_route('services_product_rate', '/Services/ProductRate') config.add_route('services_product_add_inventory', '/Services/AddInventory') + config.add_route('services_batch_list', '/Services/Batches') config.add_route('user_permissions', '/Permissions') config.add_route('account_type_list', '/AccountTypes') - config.add_route('services_batch_list', '/Services/Batches') - config.add_route('services_batch_add_inventory', '/Services/AddBatch') - - config.add_route('services_user_list', '/Services/Users') - config.add_route('voucher', '/Voucher/{id}') config.add_route('voucher_new', '/Voucher') diff --git a/brewman/brewman/static/partial/issue.html b/brewman/brewman/static/partial/issue.html new file mode 100644 index 00000000..4fbddf73 --- /dev/null +++ b/brewman/brewman/static/partial/issue.html @@ -0,0 +1,139 @@ +

Issue Edit / New

+
+
+ + +
+ + + + + + + + + + + + + +
CodeAmountLoad
{{item.Code}}{{item.Amount}} + +
+
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+ +
+
+ + + +
+ + +
+
+
+
+
+ + + +
+ + +
+ + +
+
+
+
+
+ + +
+ + + +
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
ProductQuantityRateAmountDelete
{{inventory.Product.Name + ' (' + inventory.Product.Units + ')'}}{{inventory.Quantity}}{{inventory.Rate}}{{inventory.Amount}} + +
+
+
+
+ + +
+ +
+
+
+ + + + +
+
+ Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. Posted + by {{voucher.Poster}} +
+
\ No newline at end of file diff --git a/brewman/brewman/static/partial/purchase.html b/brewman/brewman/static/partial/purchase.html new file mode 100644 index 00000000..7188afdb --- /dev/null +++ b/brewman/brewman/static/partial/purchase.html @@ -0,0 +1,116 @@ +

Purchase Edit / New

+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + + +
+ + +
+ +
+
+
+
+ + +
+ + + + + + + +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ProductQuantityRateTaxDiscountAmountDelete
{{inventory.Product.Name}}{{inventory.Quantity}}{{inventory.Rate}}{{inventory.Tax}}{{inventory.Discount}}{{inventory.Amount}} + +
+
+
+
+ + +
+ +
+
+
+ + + + +
+
+ Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. + Posted + by {{voucher.Poster}} +
+
\ No newline at end of file diff --git a/brewman/brewman/static/scripts/autocomplete.js b/brewman/brewman/static/scripts/autocomplete.js index f1a9bd6a..33e32f1d 100644 --- a/brewman/brewman/static/scripts/autocomplete.js +++ b/brewman/brewman/static/scripts/autocomplete.js @@ -10,6 +10,12 @@ 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}). diff --git a/brewman/brewman/static/scripts/issue.js b/brewman/brewman/static/scripts/issue.js index 11aeb6cc..cf409d53 100644 --- a/brewman/brewman/static/scripts/issue.js +++ b/brewman/brewman/static/scripts/issue.js @@ -1,6 +1,10 @@ -function IssueCtrl($scope, Voucher, issue_grid) { - $scope.voucher = new Voucher(voucher); - $scope.cost_centers = cost_centers; +function IssueCtrl($scope, $routeParams, $location, Voucher, CostCenter, issue_grid) { + if (typeof $routeParams.id === 'undefined') { + $scope.voucher = Voucher.get({type:'Issue'}); + } else { + $scope.voucher = Voucher.get({id:$routeParams.id}); + } + $scope.cost_centers = CostCenter.query(); $scope.addInventory = function () { for (var i = 0, l = this.voucher.Inventories.length; i < l; i++) { @@ -102,14 +106,16 @@ }, true); $scope.resetVoucher = function (voucherid) { - $scope.voucher = Voucher.get({id:voucherid, type:'Issue'}, function () { + $scope.voucher = Voucher.get({id:voucherid, type:'Issue'}, function (u, putResponseHeaders) { + $location.path('/Issue') }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); }; $scope.get = function (voucherid) { - $scope.voucher = Voucher.get({id:voucherid}, function () { + $scope.voucher = Voucher.get({id:voucherid}, function (u, putResponseHeaders) { + $location.path('/Issue/' + u.VoucherID) }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); @@ -117,6 +123,7 @@ $scope.save = function () { $scope.voucher.$save(function (u, putResponseHeaders) { + $location.path('/Issue/' + u.VoucherID) $scope.toasts.push({Type:'Success', Message:u.Code}); $scope.updateGrid(); }, function (data, status) { @@ -126,6 +133,7 @@ $scope.delete = function () { $scope.voucher.$delete(function (u, putResponseHeaders) { + $location.path('/Issue') $scope.toasts.push({Type:'Success', Message:''}); $scope.updateGrid(); }, function (data, status) { diff --git a/brewman/brewman/static/scripts/purchase.js b/brewman/brewman/static/scripts/purchase.js index a247fafe..cb02dc64 100644 --- a/brewman/brewman/static/scripts/purchase.js +++ b/brewman/brewman/static/scripts/purchase.js @@ -1,5 +1,9 @@ -function PurchaseCtrl($scope, Voucher) { - $scope.voucher = new Voucher(voucher); +function PurchaseCtrl($scope, $routeParams, $location, Voucher) { + if (typeof $routeParams.id === 'undefined') { + $scope.voucher = Voucher.get({type:'Purchase'}); + } else { + $scope.voucher = Voucher.get({id:$routeParams.id}); + } $scope.rate = 0; $scope.addInventory = function () { @@ -43,13 +47,17 @@ $scope.$watch('voucher.Inventories', function (inventories, oldValue) { var amount = 0; - for (var i = 0, l = inventories.length; i < l; i++) { - amount += Number(inventories[i].Amount); + if (typeof inventories !== 'undefined') { + for (var i = 0, l = inventories.length; i < l; i++) { + amount += Number(inventories[i].Amount); + } } - for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) { - if ($scope.voucher.Journals[i].Debit === -1) { - $scope.voucher.Journals[i].Amount = amount; - break; + if (typeof $scope.voucher.Journals !== 'undefined') { + for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) { + if ($scope.voucher.Journals[i].Debit === -1) { + $scope.voucher.Journals[i].Amount = amount; + break; + } } } }, true); @@ -65,6 +73,7 @@ $scope.save = function () { $scope.voucher.$save(function (u, putResponseHeaders) { $scope.toasts.push({Type:'Success', Message:u.Code}); + $location.path('/Purchase/' + u.VoucherID) }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); @@ -73,6 +82,7 @@ $scope.delete = function () { $scope.voucher.$delete(function (u, putResponseHeaders) { $scope.toasts.push({Type:'Success', Message:''}); + $location.path('/Purchase') }, function (data, status) { $scope.toasts.push({Type:'Error', Message:data.data}); }); diff --git a/brewman/brewman/templates/angular_base.mako b/brewman/brewman/templates/angular_base.mako index b4eaa543..11c9eabf 100644 --- a/brewman/brewman/templates/angular_base.mako +++ b/brewman/brewman/templates/angular_base.mako @@ -40,6 +40,8 @@ ${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')} diff --git a/brewman/brewman/templates/base.mako b/brewman/brewman/templates/base.mako index 05f6344f..2b84378c 100644 --- a/brewman/brewman/templates/base.mako +++ b/brewman/brewman/templates/base.mako @@ -39,6 +39,8 @@ ${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')} diff --git a/brewman/brewman/templates/transaction/issue.mako b/brewman/brewman/templates/transaction/issue.mako deleted file mode 100644 index 2890e923..00000000 --- a/brewman/brewman/templates/transaction/issue.mako +++ /dev/null @@ -1,157 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="../base.mako"/> -<%block name="header"> - ${h.ScriptLink(request, 'issue.js')} - - - -<%block name="content"> -

Issue Edit / New

-
-
- - -
- - - - - - - - - - - - - -
CodeAmountLoad
{{item.Code}}{{item.Amount}} - -
-
-
- ${h.CsrfToken(request.session)} -
- - -
- -
-
-
- - -
- -
-
- -
-
- - - -
- - -
-
-
-
-
- - - -
- - -
- - -
-
-
-
-
- - -
- - - -
-
-
- - -
- - - - - - - - - - - - - - - - - - - - - -
ProductQuantityRateAmountDelete
{{inventory.Product.Name + ' (' + inventory.Product.Units + ')'}}{{inventory.Quantity}}{{inventory.Rate}}{{inventory.Amount}} - -
-
-
-
- - -
- -
-
-
- - - - -
-
- Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. Posted - by {{voucher.Poster}} -
-
- \ No newline at end of file diff --git a/brewman/brewman/templates/transaction/issue_table.mako b/brewman/brewman/templates/transaction/issue_table.mako deleted file mode 100644 index 5dd7b4a2..00000000 --- a/brewman/brewman/templates/transaction/issue_table.mako +++ /dev/null @@ -1,10 +0,0 @@ - - ${item.inventory_id} - ${item.product_id} - ${item.name} - ${item.quantity} - ${item.rate} - ${item.amount} - ${item.batch_id} - - diff --git a/brewman/brewman/templates/transaction/purchase.mako b/brewman/brewman/templates/transaction/purchase.mako deleted file mode 100644 index e7cf2639..00000000 --- a/brewman/brewman/templates/transaction/purchase.mako +++ /dev/null @@ -1,131 +0,0 @@ -# -*- coding: utf-8 -*- -<%inherit file="../base.mako"/> -<%block name="header"> - ${h.ScriptLink(request, 'purchase.js')} - - - -<%block name="content"> -

Purchase Edit / New

-
- ${h.CsrfToken(request.session)} -
- - -
- -
-
-
- - -
- -
-
-
- - - -
- - -
- -
-
-
-
- - -
- - - - - - - -
-
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
ProductQuantityRateTaxDiscountAmountDelete
{{inventory.Product.Name}}{{inventory.Quantity}}{{inventory.Rate}}{{inventory.Tax}}{{inventory.Discount}}{{inventory.Amount}}
-
-
-
- - -
- -
-
-
- - - - -
-
- Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. - Posted - by {{voucher.Poster}} -
-
- \ No newline at end of file diff --git a/brewman/brewman/views/services/product.py b/brewman/brewman/views/services/product.py index d593e1b1..439a1b2b 100644 --- a/brewman/brewman/views/services/product.py +++ b/brewman/brewman/views/services/product.py @@ -10,7 +10,7 @@ def autocomplete_list(request): filter = request.json_body['prefixText'] list = [] for item in Product.list(filter): - list.append({'id': item.id, 'label': item.name + ' (' + item.units + ')', 'price': item.purchase_price}) + list.append({'id': item.id, 'label': item.name + ' (' + item.units + ')', 'price': item.price}) return list diff --git a/brewman/brewman/views/services/user.py b/brewman/brewman/views/services/user.py deleted file mode 100644 index 251c28ba..00000000 --- a/brewman/brewman/views/services/user.py +++ /dev/null @@ -1,17 +0,0 @@ -from pyramid.view import view_config - -from brewman.models.auth import User - - -@view_config(request_method='POST', route_name='services_user_list', renderer='json', xhr=True) -def list(request): - list = [] - filter = request.json_body['prefixText'] - if filter is None: - for item in User.list(): - list.append({'id': str(item.id), 'Name': item.name}) - else: - for item in User.filtered_list()(filter): - list.append(item.name) - - return list diff --git a/brewman/brewman/views/services/voucher/purchase.py b/brewman/brewman/views/services/voucher/purchase.py index 54fb041d..5b6a1797 100644 --- a/brewman/brewman/views/services/voucher/purchase.py +++ b/brewman/brewman/views/services/voucher/purchase.py @@ -39,7 +39,7 @@ def purchase_create_journals(inventories, ledgerID): journals = dict() amount = 0 for item in inventories: - ledger = Product.by_id(item.product_id).purchase_ledger + ledger = Product.by_id(item.product_id).ledger amount += item.amount if ledger.id in journals: journals[ledger.id].amount += item.amount diff --git a/brewman/brewman/views/transactions/__init__.py b/brewman/brewman/views/transactions/__init__.py index ce1b9562..bc7bae5d 100644 --- a/brewman/brewman/views/transactions/__init__.py +++ b/brewman/brewman/views/transactions/__init__.py @@ -3,10 +3,6 @@ from pyramid.view import view_config from brewman.helpers import Literal -@view_config(request_method='GET', route_name='receipt_id', renderer='brewman:templates/angular_base.mako', - permission='Receipt Update') -@view_config(request_method='GET', route_name='receipt', renderer='brewman:templates/angular_base.mako', - permission='Receipt Create') @view_config(request_method='GET', route_name='journal_id', renderer='brewman:templates/angular_base.mako', permission='Journal Update') @view_config(request_method='GET', route_name='journal', renderer='brewman:templates/angular_base.mako', @@ -15,6 +11,18 @@ from brewman.helpers import Literal permission='Journal Update') @view_config(request_method='GET', route_name='payment', renderer='brewman:templates/angular_base.mako', permission='Journal Create') +@view_config(request_method='GET', route_name='receipt_id', renderer='brewman:templates/angular_base.mako', + permission='Receipt Update') +@view_config(request_method='GET', route_name='receipt', renderer='brewman:templates/angular_base.mako', + permission='Receipt Create') +@view_config(request_method='GET', route_name='purchase_id', renderer='brewman:templates/angular_base.mako', + permission='Purchase Update') +@view_config(request_method='GET', route_name='purchase', renderer='brewman:templates/angular_base.mako', + permission='Purchase Create') +@view_config(request_method='GET', route_name='issue_id', renderer='brewman:templates/angular_base.mako', + permission='Issue Update') +@view_config(request_method='GET', route_name='issue', renderer='brewman:templates/angular_base.mako', + permission='Issue Create') def journal_get(request): return {} diff --git a/brewman/brewman/views/transactions/issue.py b/brewman/brewman/views/transactions/issue.py deleted file mode 100644 index 3a1c90d5..00000000 --- a/brewman/brewman/views/transactions/issue.py +++ /dev/null @@ -1,36 +0,0 @@ -import json -import uuid - -from pyramid.view import view_config -from brewman.helpers import Literal -from brewman.models.master import CostCenter - -from brewman.models.voucher import Voucher - -from brewman.views import DecimalEncoder -from brewman.views.services.voucher import voucher_info, blank_voucher -from brewman.views.transactions import session_current_date - -@view_config(request_method='GET', route_name='issue_id', renderer='brewman:templates/transaction/issue.mako', - permission='Issue Update') -@view_config(request_method='GET', route_name='issue', renderer='brewman:templates/transaction/issue.mako', - permission='Issue Create') -def issue_get(request): - id = request.matchdict.get('id', None) - perms = Literal(json.dumps(request.session['perms'])) - cost_centers = [] - for item in CostCenter.list(): - cost_centers.append({'CostCenterID': item.id, 'Name': item.name}) - - cost_centers = Literal(json.dumps(cost_centers, cls=DecimalEncoder)) - if id is None: - json_voucher = Literal(json.dumps(blank_voucher('Issue', session_current_date(request)), cls=DecimalEncoder)) - else: - voucher = Voucher.by_id(uuid.UUID(id)) - json_voucher = Literal(json.dumps(voucher_info(voucher), cls=DecimalEncoder)) - - return {'title': 'Hops n Grains - Issue Entry', - 'id': id, - 'perms': perms, - 'cost_centers': cost_centers, - 'json_voucher': json_voucher} diff --git a/brewman/brewman/views/transactions/purchase.py b/brewman/brewman/views/transactions/purchase.py deleted file mode 100644 index 1289d8e1..00000000 --- a/brewman/brewman/views/transactions/purchase.py +++ /dev/null @@ -1,30 +0,0 @@ -import json -import uuid - -from pyramid.view import view_config - -from brewman.helpers import Literal - -from brewman.models.voucher import Voucher -from brewman.views import DecimalEncoder -from brewman.views.services.voucher import voucher_info, blank_voucher -from brewman.views.transactions import session_current_date - - -@view_config(request_method='GET', route_name='purchase_id', renderer='brewman:templates/transaction/purchase.mako', - permission='Purchase Update') -@view_config(request_method='GET', route_name='purchase', renderer='brewman:templates/transaction/purchase.mako', - permission='Purchase Create') -def purchase_get(request): - id = request.matchdict.get('id', None) - perms = Literal(json.dumps(request.session['perms'])) - if id is None: - json_voucher = Literal(json.dumps(blank_voucher('Purchase', session_current_date(request)), cls=DecimalEncoder)) - else: - voucher = Voucher.by_id(uuid.UUID(id)) - json_voucher = Literal(json.dumps(voucher_info(voucher), cls=DecimalEncoder)) - - return {'title': 'Hops n Grains - Purchase Entry', - 'id': id, - 'perms': perms, - 'json_voucher': json_voucher}