diff --git a/Conversion/SqliteDB.txt b/Conversion/SqliteDB.txt
index 8bcdc0bf..4ac792ab 100644
--- a/Conversion/SqliteDB.txt
+++ b/Conversion/SqliteDB.txt
@@ -1,11 +1,18 @@
UPDATE entities_vouchers SET date = date || ".000000", lasteditdate = lasteditdate || ".000000", creationdate = creationdate || ".000000";
UPDATE entities_attendances SET date = date || ".000000", creationdate = creationdate || ".000000";
UPDATE entities_fingerprints SET date = date || ".000000";
-ALTER TABLE "Entities_Ledgers" ADD COLUMN "ledger_type" nvarchar(50) NOT NULL DEFAULT "";
+
+
+ALTER TABLE "Entities_Batches" RENAME TO "Entities_Batches_old";
+CREATE TABLE "Entities_Batches" ("BatchID" guid NOT NULL ,"Name" nvarchar(50) NOT NULL ,"ProductID" guid,"QuantityRemaining" numeric NOT NULL ,"Rate" numeric NOT NULL ,"Tax" numeric NOT NULL ,"Discount" numeric NOT NULL, PRIMARY KEY ([BatchID]));
+INSERT INTO "Entities_Batches" SELECT "BatchID","Name","ProductID","QuantityRemaining","Rate","Tax","Discount" FROM "Entities_Batches_old";
+DROP TABLE "Entities_Batches_old";
+
+ALTER TABLE "Entities_Ledgers" RENAME TO "Entities_Ledgers_old";
+CREATE TABLE "Entities_Ledgers" ("LedgerID" guid NOT NULL, "Code" integer NOT NULL, "Name" nvarchar(255) NOT NULL COLLATE NOCASE, "Type" integer NOT NULL, "ledger_type" nvarchar(50) NOT NULL, "IsActive" bit NOT NULL, "CostCenterID" guid,
+ PRIMARY KEY ([LedgerID]),
+ FOREIGN KEY ([CostCenterID]) REFERENCES [Entities_CostCenters]([CostCenterID])
+);
+INSERT INTO "Entities_Ledgers" SELECT "LedgerID", "Code", "Name", "Type", '', "IsActive", "CostCenterID" FROM "Entities_Ledgers_old";
UPDATE "Entities_Ledgers" SET ledger_type = 'employees' where type = 10;
-
-
-ALTER TABLE "main"."Entities_Batches" RENAME TO "Entities_Batches_old";
-CREATE TABLE "main"."Entities_Batches" ("BatchID" guid NOT NULL ,"Name" nvarchar(50) NOT NULL ,"ProductID" guid,"QuantityRemaining" numeric NOT NULL ,"Rate" numeric NOT NULL ,"Tax" numeric NOT NULL ,"Discount" numeric NOT NULL );
-INSERT INTO "main"."Entities_Batches" SELECT "BatchID","Name","ProductID","QuantityRemaining","Rate","Tax","Discount" FROM "main"."Entities_Batches_old";
-DROP TABLE "main"."Entities_Batches_old";
\ No newline at end of file
+DROP TABLE "Entities_Ledgers_old";
diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py
index ab0b1468..fd936d63 100644
--- a/brewman/brewman/__init__.py
+++ b/brewman/brewman/__init__.py
@@ -39,6 +39,7 @@ def main(global_config, **settings):
config.add_static_view('script', 'brewman:static/scripts')
config.add_static_view('css', 'brewman:static/css')
config.add_static_view('pictures', 'brewman:static/pictures')
+ config.add_static_view('partial', 'brewman:static/partial')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
@@ -56,9 +57,9 @@ def main(global_config, **settings):
config.add_route('cost_center', '/CostCenter')
config.add_route('cost_center_list', '/CostCenters')
- config.add_route('ledger_id', '/Ledger/{id}')
- config.add_route('ledger', '/Ledger')
- config.add_route('ledger_list', '/Ledgers')
+ config.add_route('account_id', '/Account/{id}')
+ config.add_route('account', '/Account')
+ config.add_route('account_list', '/Accounts')
config.add_route('product_id', '/Product/{id}')
config.add_route('product', '/Product')
@@ -97,6 +98,8 @@ def main(global_config, **settings):
config.add_route('display_ledger_id', '/Reports/DisplayLedger/{id}')
config.add_route('display_ledger', '/Reports/DisplayLedger')
+ config.add_route('json_display_ledger', '/json/Ledger/{id}')
+
config.add_route('product_ledger_id', '/Reports/ProductLedger/{id}')
config.add_route('product_ledger', '/Reports/ProductLedger')
@@ -130,6 +133,9 @@ def main(global_config, **settings):
config.add_route('services_product_rate', '/Services/ProductRate')
config.add_route('services_product_add_inventory', '/Services/AddInventory')
+ 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')
@@ -137,8 +143,6 @@ def main(global_config, **settings):
config.add_route('voucher', '/Voucher/{id}')
config.add_route('voucher_new', '/Voucher')
- config.add_route('post_voucher', '/Services/Post/{id}')
- config.add_route('delete_voucher', '/Services/Delete/{id}')
config.add_route('is_user_in_role', '/Services/IsUserInRole/{id}')
config.add_route('is_user_in_roles', '/Services/IsUserInRoles')
diff --git a/brewman/brewman/helpers.py b/brewman/brewman/helpers.py
index a3a739aa..2cc48566 100644
--- a/brewman/brewman/helpers.py
+++ b/brewman/brewman/helpers.py
@@ -1,6 +1,6 @@
import string
-from brewman.views.nav_bar import login_menu, report_menu, voucher_menu, entry_menu, employee_menu, ledger_menu, product_menu
+from brewman.views.nav_bar import login_menu, report_menu, voucher_menu, entry_menu, employee_menu, account_menu, product_menu
class Form(object):
"""Make absolute URL from the relative one.
diff --git a/brewman/brewman/models/__init__.py b/brewman/brewman/models/__init__.py
index a740f081..c7bf3ee6 100644
--- a/brewman/brewman/models/__init__.py
+++ b/brewman/brewman/models/__init__.py
@@ -11,3 +11,29 @@ Base = declarative_base()
def initialize_sql(engine):
DBSession.configure(bind=engine)
Base.metadata.bind = engine
+
+def populate():
+ """ Populate initial data and table structure
+ """
+ pass
+# try:
+# Base.metadata.create_all(engine)
+# session = DBSession()
+#
+# home = Sitmap('Home','/', 1)
+# session.add(home)
+# login = Sitmap('Login','/Login', 2)
+# session.add(login)
+# logout = Sitmap('Logout','/Logout', 3)
+# session.add(logout)
+#
+# session.add(Sitemap('Sub1',/Sub1',1,home.id))
+# session.add(Sitemap('Sub2',/Sub2',2,home.id))
+# session.add(Sitemap('Sub3',/Sub3',1,login.id))
+# session.add(Sitemap('Sub4',/Sub4',1,login.id))
+#
+# session.flush()
+# transaction.commit()
+# except IntegrityError:
+# transaction.abort()
+#
diff --git a/brewman/brewman/models/master.py b/brewman/brewman/models/master.py
index f096767b..c51d76f2 100644
--- a/brewman/brewman/models/master.py
+++ b/brewman/brewman/models/master.py
@@ -138,6 +138,14 @@ class CostCenter(Base):
def cost_center_kitchen(cls):
return uuid.UUID('b2d398ce-e3cc-c542-9feb-5d7783e899df')
+ @classmethod
+ def cost_center_overall(cls):
+ return uuid.UUID('36f59436-522a-0746-ae94-e0f746bf6c0d')
+
+ @classmethod
+ def overall(cls):
+ return {'CostCenterID': uuid.UUID('36f59436-522a-0746-ae94-e0f746bf6c0d'), 'Name': 'Overall'}
+
class LedgerBase(Base):
__tablename__ = 'entities_ledgers'
@@ -147,7 +155,6 @@ class LedgerBase(Base):
name = Column('Name', Unicode(255), unique=True)
type = Column('Type', Integer, nullable=False)
ledger_type = Column('ledger_type', Unicode(50), nullable=False)
- parent_ledger_id = Column('ParentLedgerID', GUID())
is_active = Column('IsActive', Boolean)
costcenter_id = Column('CostCenterID', GUID(), ForeignKey('entities_costcenters.CostCenterID'))
@@ -163,11 +170,10 @@ class LedgerBase(Base):
def type_object(self):
return LedgerType.by_id(self.type)
- def __init__(self, code=None, name=None, type=None, parent_ledger_id=None, is_active=None, costcenter_id=None):
+ def __init__(self, code=None, name=None, type=None, is_active=None, costcenter_id=None):
self.code = code
self.name = name
self.type = type
- self.parent_ledger_id = parent_ledger_id
self.is_active = is_active
self.costcenter_id = costcenter_id
@@ -202,6 +208,12 @@ class LedgerBase(Base):
DBSession.add(self)
return self
+ @classmethod
+ def get_code(cls, type):
+ code = DBSession.query(func.max(LedgerBase.code)).filter(LedgerBase.type == type).one()[0]
+ return 1 if code is None else code + 1
+
+
@classmethod
def all_purchases(cls):
return uuid.UUID('240dd899-c413-854c-a7eb-67a29d154490')
@@ -251,6 +263,10 @@ class Employee(LedgerBase):
class Ledger(LedgerBase):
__mapper_args__ = {'polymorphic_identity': ''}
+ @classmethod
+ def list(cls):
+ return DBSession.query(Ledger).order_by(Ledger.type).order_by(Ledger.name).order_by(Ledger.code).all()
+
class AttendanceType:
def __init__(self, id, name, value=None):
diff --git a/brewman/brewman/models/other.py.exclude b/brewman/brewman/models/other.py.exclude
deleted file mode 100644
index d57ce9c6..00000000
--- a/brewman/brewman/models/other.py.exclude
+++ /dev/null
@@ -1,56 +0,0 @@
-from brewman.models.user import User
-from brewman.models.sitemap import Sitemap
-
-import transaction
-# import cryptacular.bcrypt
-
-from datetime import datetime, date
-from sqlalchemy import Column
-from sqlalchemy import Integer
-from sqlalchemy import Unicode
-from sqlalchemy import Date
-from sqlalchemy import DateTime
-
-from sqlalchemy.exc import IntegrityError
-from sqlalchemy.ext.declarative import declarative_base
-
-from sqlalchemy.orm import relationship
-from sqlalchemy.orm import scoped_session
-from sqlalchemy.orm import sessionmaker
-from sqlalchemy.orm import synonym
-
-from sqlalchemy.schema import ForeignKey
-
-from zope.sqlalchemy import ZopeTransactionExtension
-
-# crypt = cryptacular.bcrypt.BCRYPTPasswordManager()
-
-DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
-Base = declarative_base()
-
-def populate():
- session = DBSession()
-
- home = Sitmap('Home','/', 1)
- session.add(home)
- login = Sitmap('Login','/Login', 2)
- session.add(login)
- logout = Sitmap('Logout','/Logout', 3)
- session.add(logout)
-
- session.add(Sitemap('Sub1',/Sub1',1,home.id))
- session.add(Sitemap('Sub2',/Sub2',2,home.id))
- session.add(Sitemap('Sub3',/Sub3',1,login.id))
- session.add(Sitemap('Sub4',/Sub4',1,login.id))
-
- session.flush()
- transaction.commit()
-
-def initialize_sql(engine):
- DBSession.configure(bind=engine)
- Base.metadata.bind = engine
- # Base.metadata.create_all(engine)
- try:
- populate()
- except IntegrityError:
- transaction.abort()
diff --git a/brewman/brewman/static/partial/account-detail.html b/brewman/brewman/static/partial/account-detail.html
new file mode 100644
index 00000000..e45cd9db
--- /dev/null
+++ b/brewman/brewman/static/partial/account-detail.html
@@ -0,0 +1,52 @@
+
diff --git a/brewman/brewman/static/partial/account-list.html b/brewman/brewman/static/partial/account-list.html
new file mode 100644
index 00000000..60dd286f
--- /dev/null
+++ b/brewman/brewman/static/partial/account-list.html
@@ -0,0 +1,19 @@
+Accounts
+
+
+
+ Name
+ Type
+ Is Active?
+ Cost Center
+
+
+
+
+ {{item.Name}}
+ {{item.Type}}
+ {{item.IsActive}}
+ {{item.CostCenter}}
+
+
+
diff --git a/brewman/brewman/static/scripts/account.js b/brewman/brewman/static/scripts/account.js
new file mode 100644
index 00000000..d6008b3c
--- /dev/null
+++ b/brewman/brewman/static/scripts/account.js
@@ -0,0 +1,28 @@
+function AccountListCtrl($scope, Account) {
+ $scope.info = Account.query();
+}
+
+function AccountCtrl($scope, $routeParams, Account, AccountType, CostCenter) {
+ $scope.account = Account.get({id: $routeParams.id});
+
+ $scope.account_types = AccountType.query();
+ $scope.cost_centers = CostCenter.query();
+
+ $scope.save = function () {
+ $scope.account.$save(function (u, putResponseHeaders) {
+ $scope.toasts.push({Type:'Success', Message:u.Code});
+ }, function (data, status) {
+ $scope.toasts.push({Type:'Error', Message:data.data});
+ });
+ };
+
+ $scope.delete = function () {
+ $scope.account.$delete(function (u, putResponseHeaders) {
+ $scope.toasts.push({Type:'Success', Message:''});
+ }, function (data, status) {
+ $scope.toasts.push({Type:'Error', Message:data.data});
+ });
+ };
+ $('#txtLedger').focus();
+
+}
diff --git a/brewman/brewman/static/scripts/angular_directive.js b/brewman/brewman/static/scripts/angular_directive.js
index 7e4a165b..f5015920 100644
--- a/brewman/brewman/static/scripts/angular_directive.js
+++ b/brewman/brewman/static/scripts/angular_directive.js
@@ -33,7 +33,7 @@ overlord_directive.directive('autocomplete', function () {
scope.selname = ui.item.label;
scope.selid = ui.item.id;
- if (typeof ui.item.price !== 'undefined'){
+ if (typeof ui.item.price !== 'undefined') {
scope.selprice = ui.item.price;
}
scope.$apply();
@@ -94,8 +94,10 @@ overlord_directive.directive('datepicker', function () {
element.datepicker({
dateFormat:'dd-M-yy',
onSelect:function (dateText, inst) {
- scope[attrs.model][attrs.prop] = dateText;
- scope.$apply();
+ if (typeof attrs.model !== 'undefined') {
+ scope[attrs.model][attrs.prop] = dateText;
+ scope.$apply();
+ }
}
});
}
@@ -112,8 +114,8 @@ overlord_directive.directive('fadey', function () {
element.hide();
element.fadeIn(duration)
- scope.destroy = function(complete) {
- element.fadeOut(duration, function() {
+ scope.destroy = function (complete) {
+ element.fadeOut(duration, function () {
if (complete) {
complete.apply(scope);
}
diff --git a/brewman/brewman/static/scripts/angular_service.js b/brewman/brewman/static/scripts/angular_service.js
index 3d84669c..84aaf022 100644
--- a/brewman/brewman/static/scripts/angular_service.js
+++ b/brewman/brewman/static/scripts/angular_service.js
@@ -76,7 +76,35 @@ overlord_service.factory('issue_grid', ['$resource', function ($resource) {
overlord_service.factory('Voucher', ['$resource', function ($resource) {
return $resource('/Voucher/:id',
{id:'@VoucherID'}, {
- post: {method:'POST', params:{post:true}}
+ post:{method:'POST', params:{post:true}}
});
}]);
+// TODO: Replace hardcoded url with route_url
+overlord_service.factory('Account', ['$resource', function ($resource) {
+ return $resource('/Account/:id',
+ {id:'@LedgerID'}, {
+ query:{method:'GET', params:{list:true}, isArray:true}
+ });
+}]);
+
+// TODO: Replace hardcoded url with route_url
+overlord_service.factory('Ledger', ['$resource', function ($resource) {
+ return $resource('/json/Ledger/:id');
+}]);
+
+// TODO: Replace hardcoded url with route_url
+overlord_service.factory('Permission', ['$resource', function ($resource) {
+ return $resource('/Permissions');
+}]);
+
+// TODO: Replace hardcoded url with route_url
+overlord_service.factory('CostCenter', ['$resource', function ($resource) {
+ return $resource('/CostCenters');
+}]);
+
+// TODO: Replace hardcoded url with route_url
+overlord_service.factory('AccountType', ['$resource', function ($resource) {
+ return $resource('/AccountTypes');
+}]);
+
diff --git a/brewman/brewman/static/scripts/autocomplete.js b/brewman/brewman/static/scripts/autocomplete.js
index 0a386d50..3b715de4 100644
--- a/brewman/brewman/static/scripts/autocomplete.js
+++ b/brewman/brewman/static/scripts/autocomplete.js
@@ -1,5 +1,11 @@
-var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service']);
-
+var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filter', 'overlord.service']).
+ config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
+ $routeProvider.
+ when('/Accounts', {templateUrl: '/partial/account-list.html', controller: AccountListCtrl}).
+ when('/Account/:id', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl});
+// .otherwise({redirectTo: '/phones'});
+ $locationProvider.html5Mode(true);
+}]);
function AutoComplete(matchFieldName, lookupURL) {
$(matchFieldName).autocomplete({
source:function (request, response) {
@@ -25,9 +31,9 @@ function AutoComplete(matchFieldName, lookupURL) {
-function BaseCtrl($scope) {
+function BaseCtrl($scope, Permission) {
$scope.auth = {
- perms:perms,
+ perms:Permission.query(),
isUserInRole:function (role) {
return $scope.auth.perms.indexOf(role) !== -1;
}
diff --git a/brewman/brewman/static/scripts/displayledger.js b/brewman/brewman/static/scripts/displayledger.js
index 05da7dd3..7b9a0090 100644
--- a/brewman/brewman/static/scripts/displayledger.js
+++ b/brewman/brewman/static/scripts/displayledger.js
@@ -1,28 +1,10 @@
-function Populate(vouchers) {
- 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);
- $('#txtLedger').val(vouchers.name);
- $('#tbodyMain').html(vouchers.body);
- $('#tfootMain').html(vouchers.footer);
- }
+function LedgerCtrl($scope, Ledger) {
+ $scope.info = new Ledger(info);
+ $scope.show = function () {
+ $scope.info = Ledger.get({id:$scope.info.Ledger.LedgerID, StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate}, function () {
+ }, function (data, status) {
+ $scope.toasts.push({Type:'Error', Message:data.data});
+ });
+ $('#txtLedger').focus();
+ };
}
-
-function Show(ledgerString, ledgerID, startDate, finishDate) {
- $.ajax({
- type:"POST",
- contentType:"application/json; charset=utf-8",
- url:show_url,
- data:JSON.stringify({ ledgerString:ledgerString, ledgerID:ledgerID, 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;
-}
\ No newline at end of file
diff --git a/brewman/brewman/static/scripts/journal.js b/brewman/brewman/static/scripts/journal.js
index 9477c9c3..4d6df122 100644
--- a/brewman/brewman/static/scripts/journal.js
+++ b/brewman/brewman/static/scripts/journal.js
@@ -39,7 +39,7 @@
}, true);
$scope.get = function (voucherid) {
- $scope.voucher = Voucher.$get({VoucherID:voucherid}, function (u, putResponseHeaders) {
+ $scope.voucher = Voucher.get({VoucherID:voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type:'Success', Message:u.Code});
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
diff --git a/brewman/brewman/static/scripts/payment.js b/brewman/brewman/static/scripts/payment.js
index fca3eeef..9df58336 100644
--- a/brewman/brewman/static/scripts/payment.js
+++ b/brewman/brewman/static/scripts/payment.js
@@ -45,7 +45,7 @@
}, true);
$scope.get = function (voucherid) {
- $scope.voucher = Voucher.$get({VoucherID:voucherid}, function (u, putResponseHeaders) {
+ $scope.voucher = Voucher.get({VoucherID:voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type:'Success', Message:u.Code});
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
diff --git a/brewman/brewman/static/scripts/purchase.js b/brewman/brewman/static/scripts/purchase.js
index dd247ee2..a247fafe 100644
--- a/brewman/brewman/static/scripts/purchase.js
+++ b/brewman/brewman/static/scripts/purchase.js
@@ -55,7 +55,7 @@
}, true);
$scope.get = function (voucherid) {
- $scope.voucher = Voucher.$get({VoucherID:voucherid}, function (u, putResponseHeaders) {
+ $scope.voucher = Voucher.get({VoucherID:voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type:'Success', Message:u.Code});
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
diff --git a/brewman/brewman/static/scripts/receipt.js b/brewman/brewman/static/scripts/receipt.js
index f400e155..ec2a6eb2 100644
--- a/brewman/brewman/static/scripts/receipt.js
+++ b/brewman/brewman/static/scripts/receipt.js
@@ -44,7 +44,7 @@
}, true);
$scope.get = function (voucherid) {
- $scope.voucher = Voucher.$get({VoucherID:voucherid}, function (u, putResponseHeaders) {
+ $scope.voucher = Voucher.get({VoucherID:voucherid}, function (u, putResponseHeaders) {
$scope.toasts.push({Type:'Success', Message:u.Code});
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
diff --git a/brewman/brewman/templates/accounts/account_detail.mako b/brewman/brewman/templates/accounts/account_detail.mako
new file mode 100644
index 00000000..7cf2915c
--- /dev/null
+++ b/brewman/brewman/templates/accounts/account_detail.mako
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+<%inherit file="../base.mako"/>
+<%block name="header">
+
+ ${h.ScriptLink(request, 'account.js')}
+
+%block>
+<%block name="content">
+
+%block>
\ No newline at end of file
diff --git a/brewman/brewman/templates/accounts/account_list.mako b/brewman/brewman/templates/accounts/account_list.mako
new file mode 100644
index 00000000..1e9f1933
--- /dev/null
+++ b/brewman/brewman/templates/accounts/account_list.mako
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+<%inherit file="../base.mako"/>
+<%block name="header">
+
+ ${h.ScriptLink(request, 'account.js')}
+%block>
+<%block name="content">
+
+
+
+
+ Name
+ Type
+ Is Active?
+ Cost Center
+
+
+
+
+ {{item.Name}}
+ {{item.Type}}
+ {{item.IsActive}}
+ {{item.CostCenter}}
+
+
+
+%block>
\ No newline at end of file
diff --git a/brewman/brewman/templates/ledgers/cost_center_edit.mako b/brewman/brewman/templates/accounts/cost_center_edit.mako
similarity index 100%
rename from brewman/brewman/templates/ledgers/cost_center_edit.mako
rename to brewman/brewman/templates/accounts/cost_center_edit.mako
diff --git a/brewman/brewman/templates/ledgers/cost_center_list.mako b/brewman/brewman/templates/accounts/cost_center_list.mako
similarity index 100%
rename from brewman/brewman/templates/ledgers/cost_center_list.mako
rename to brewman/brewman/templates/accounts/cost_center_list.mako
diff --git a/brewman/brewman/templates/angular_base.mako b/brewman/brewman/templates/angular_base.mako
new file mode 100644
index 00000000..f44aa5ee
--- /dev/null
+++ b/brewman/brewman/templates/angular_base.mako
@@ -0,0 +1,106 @@
+
+
+
+
+ Hops n Grains
+
+
+
+
+
+ ${h.CssLink(request, 'style.css')}
+
+ ${h.CssLink(request, 'bootstrap-responsive.css')}
+
+ ${h.CssLink(request, 'jquery-ui-1.8.16.custom.css')}
+
+ ${h.JsLink(request, 'jquery-1.7.1.min.js')}
+ ${h.JsLink(request, 'jquery-ui-1.8.17.custom.min.js')}
+ ${h.JsLink(request, 'bootstrap.js')}
+
+ ${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, 'angular_directive.js')}
+ ${h.ScriptLink(request, 'angular_filter.js')}
+ ${h.ScriptLink(request, 'angular_service.js')}
+ ${h.ScriptLink(request, 'session.js')}
+ ${h.ScriptLink(request, 'account.js')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Hops n Grains
+
+
+
+ ${h.voucher_menu(request) | n }
+ ${h.report_menu(request) | n }
+ ${h.entry_menu(request) | n }
+ ${h.employee_menu(request) | n }
+ ${h.account_menu(request) | n }
+ ${h.product_menu(request) | n }
+ ${h.login_menu(request) | n }
+
+
+
+
+
+
+
+
+
+
+ ×
+ {{toast.Type}}! {{toast.Message}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/brewman/brewman/templates/base.html b/brewman/brewman/templates/base.html
deleted file mode 100644
index 864dd2eb..00000000
--- a/brewman/brewman/templates/base.html
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
-
-
- ${title}
-
- ${h.CssLink(request, 'style.css')}
- ${h.CssLink(request, 'meta.css')}
- ${h.CssLink(request, 'jquery/jquery-ui-1.8.16.custom.css')}
- ${h.CssLink(request, '960/960.css')}
- ${h.CssLink(request, '960/reset.css')}
- ${h.CssLink(request, '960/text.css')}
- ${h.CssLink(request, 'normalize.css')}
- ${h.CssLink(request, 'form.css')}
- ${h.CssLink(request, 'header.css')}
- ${h.CssLink(request, 'table.css')}
- ${h.CssLink(request, 'button.css')}
-
- ${h.JsLink(request, 'jquery/jquery-1.7.1.min.js')}
- ${h.JsLink(request, 'jquery/jquery-ui-1.8.17.custom.min.js')}
- ${h.JsLink(request, 'autocomplete.js')}
- ${h.JsLink(request, 'session.js')}
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/base.mako b/brewman/brewman/templates/base.mako
index 076e1ce1..009f6de6 100644
--- a/brewman/brewman/templates/base.mako
+++ b/brewman/brewman/templates/base.mako
@@ -1,6 +1,6 @@
-
+
${title}
@@ -10,10 +10,10 @@
${h.CssLink(request, 'style.css')}
${h.CssLink(request, 'bootstrap-responsive.css')}
@@ -25,75 +25,83 @@
${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, 'angular_directive.js')}
- ${h.ScriptLink(request, 'angular_filter.js')}
- ${h.ScriptLink(request, 'angular_service.js')}
- ${h.ScriptLink(request, 'session.js')}
+ ${h.ScriptLink(request, 'angular_directive.js')}
+ ${h.ScriptLink(request, 'angular_filter.js')}
+ ${h.ScriptLink(request, 'angular_service.js')}
+ ${h.ScriptLink(request, 'session.js')}
- <%block name="header" />
+ <%block name="header" />
-
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
Hops n Grains
-
-
- ${h.voucher_menu(request) | n }
- ${h.report_menu(request) | n }
- ${h.entry_menu(request) | n }
- ${h.employee_menu(request) | n }
- ${h.ledger_menu(request) | n }
- ${h.product_menu(request) | n }
- ${h.login_menu(request) | n }
-
-
-
-
+
+
+
+
+
+
Hops n Grains
-
-
+
+
+ ${h.voucher_menu(request) | n }
+ ${h.report_menu(request) | n }
+ ${h.entry_menu(request) | n }
+ ${h.employee_menu(request) | n }
+ ${h.account_menu(request) | n }
+ ${h.product_menu(request) | n }
+ ${h.login_menu(request) | n }
+
+
+
+
+
+
+
+
- × {{toast.Type}}! {{toast.Message}}
+ ×
+ {{toast.Type}}! {{toast.Message}}
-
+
- <%block name="content"/>
- ${self.body()}
-
+ <%block name="content"/>
+ ${self.body()}
+
-
-
+
+
-
-
-
+
+
+
diff --git a/brewman/brewman/templates/base.pt b/brewman/brewman/templates/base.pt
deleted file mode 100644
index 20a259ce..00000000
--- a/brewman/brewman/templates/base.pt
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
- Bootstrap, from Twitter
-
-
-
-
-
- ${h.CssLink(request, 'style.css')}
-
- ${h.CssLink(request, 'bootstrap-responsive.css')}
-
- ${h.CssLink(request, 'jquery-ui-1.8.16.custom.css')}
-
- ${h.JsLink(request, 'jquery-1.7.1.min.js')}
- ${h.JsLink(request, 'jquery-ui-1.8.17.custom.min.js')}
- ${h.JsLink(request, 'bootstrap.js')}
-
-
-
- ${h.ScriptLink(request, 'autocomplete.js')}
- ${h.ScriptLink(request, 'session.js')}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/brewman/brewman/templates/base.pt.old b/brewman/brewman/templates/base.pt.old
deleted file mode 100644
index 1c93b3a4..00000000
--- a/brewman/brewman/templates/base.pt.old
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
- ${title} -
-
-
-
- ${h.JsLink(request, 'jquery-ui-1.8.17.custom.min.js')}
- ${h.JsLink(request, 'jquery.dataTables-1.9.0.min.js')}
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/blog.pt b/brewman/brewman/templates/blog.pt
deleted file mode 100644
index 5fe49d26..00000000
--- a/brewman/brewman/templates/blog.pt
+++ /dev/null
@@ -1,214 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In hac habitasse platea dictumst. Aliquam lobortis sodales pretium. Vivamus urna ligula, luctus sit amet cursus at, viverra sit amet odio. In mauris neque, semper non tincidunt quis, blandit ut lorem. Donec neque eros, rutrum in viverra nec, tristique id enim. Mauris vulputate ligula in dui elementum iaculis. Mauris bibendum dictum lectus vitae ultrices. Curabitur …
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In hac habitasse platea dictumst. Aliquam lobortis sodales pretium. Vivamus urna ligula, luctus sit amet cursus at, viverra sit amet odio. In mauris neque, semper non tincidunt quis, blandit ut lorem. Donec neque eros, rutrum in viverra nec, tristique id enim. Mauris vulputate ligula in dui elementum iaculis. Mauris bibendum dictum lectus vitae ultrices. Curabitur …
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In hac habitasse platea dictumst. Aliquam lobortis sodales pretium. Vivamus urna ligula, luctus sit amet cursus at, viverra sit amet odio. In mauris neque, semper non tincidunt quis, blandit ut lorem. Donec neque eros, rutrum in viverra nec, tristique id enim. Mauris vulputate ligula in dui elementum iaculis. Mauris bibendum dictum lectus vitae ultrices. Curabitur …
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In hac habitasse platea dictumst. Aliquam lobortis sodales pretium. Vivamus urna ligula, luctus sit amet cursus at, viverra sit amet odio. In mauris neque, semper non tincidunt quis, blandit ut lorem. Donec neque eros, rutrum in viverra nec, tristique id enim. Mauris vulputate ligula in dui elementum iaculis. Mauris bibendum dictum lectus vitae ultrices. Curabitur …
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- In hac habitasse platea dictumst. Aliquam lobortis sodales pretium. Vivamus urna ligula, luctus sit amet cursus at, viverra sit amet odio. In mauris neque, semper non tincidunt quis, blandit ut lorem. Donec neque eros, rutrum in viverra nec, tristique id enim. Mauris vulputate ligula in dui elementum iaculis. Mauris bibendum dictum lectus vitae ultrices. Curabitur …
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/blog_post.pt b/brewman/brewman/templates/blog_post.pt
deleted file mode 100644
index 2e30192e..00000000
--- a/brewman/brewman/templates/blog_post.pt
+++ /dev/null
@@ -1,578 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Centered image with caption without zoom
-
-
- This post has all the text elements and also includes the slider shortcode example. This is also a sticky post set when you write this post in the WP admin area.
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
-
-
-
- Section heading text
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
-
-
-
-
-
-
-
- Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
-
- Lorem ipsum dolor sit amet, consectetuer adipiscing,
- Duis autem vel eum iriure dolor in hendrerit in vulputate,
- Ut wisi enim ad minim veniam, quis nostrud exerci tation,
- Praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
-
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/contact.pt b/brewman/brewman/templates/contact.pt
deleted file mode 100644
index 5059dcc3..00000000
--- a/brewman/brewman/templates/contact.pt
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent felis nulla, lacinia sodales placerat quis, aliquam et metus. Cras tincidunt gravida massa, ac tincidunt quam convallis a. Vivamus mattis ipsum urna, et volutpat enim. Nunc nisi mi, tincidunt ac tempus porta, pharetra eu dolor. Etiam sed odio non felis vulputate pellentesque.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/gallery.pt b/brewman/brewman/templates/gallery.pt
deleted file mode 100644
index 9972f855..00000000
--- a/brewman/brewman/templates/gallery.pt
+++ /dev/null
@@ -1,214 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/ledgers/ledger_edit.mako b/brewman/brewman/templates/ledgers/ledger_edit.mako
deleted file mode 100644
index 3ea58df0..00000000
--- a/brewman/brewman/templates/ledgers/ledger_edit.mako
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-<%inherit file="../base.mako"/>
-<%block name="content">
-
-
- ${h.CsrfToken(request.session)}
-
- ${h.Label('Code: ' + str(h.Span('(Required *)', 'required')), 'code')}
- ${h.TextInput('code', value = item.code, css_class = 'required', required = 'required')}
-
-
-
- ${h.Label('Name: ' + str(h.Span('(Required *)', 'required')), 'name')}
- ${h.TextInput('name', value = item.name, css_class = 'required', required = 'required')}
-
-
-
- ${h.Label('Type: ' + str(h.Span('(Required *)', 'required')), 'type')}
- ${h.SelectInput('type', list = types, displayField = 'name', valueField = 'id', defaultValue = item.type)}
-
-
-
- ${h.Label('Is Active: ' + str(h.Span('(Required *)', 'required')), 'is_active')}
- ${h.CheckBoxInput('is_active', value = item.is_active, css_class = 'required')}
-
-
-
- ${h.Label('CostCenterID: ' + str(h.Span('(Required *)', 'required')), 'cost_center_id')}
- ${h.SelectInput('cost_center_id', list = cost_centers, displayField = 'name', valueField = 'id', defaultValue = item.costcenter_id)}
-
-
-
- ${h.SubmitButton('submit', 'Submit')}
-
-
-%block>
\ No newline at end of file
diff --git a/brewman/brewman/templates/ledgers/ledger_list.mako b/brewman/brewman/templates/ledgers/ledger_list.mako
deleted file mode 100644
index 9621f7f2..00000000
--- a/brewman/brewman/templates/ledgers/ledger_list.mako
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- coding: utf-8 -*-
-<%inherit file="../base.mako"/>
-<%block name="content">
-
-
-
-
- LedgerID
- Code
- Name
- Type
- Is Active?
- CostCenterID
- Cost Center
-
-
-
- % for item in list:
-
- ${item.id}
- ${item.code}
- ${item.name}
- ${item.type_object.name}
- ${item.is_active}
- ${item.costcenter_id}
- ${item.costcenter.name}
-
- % endfor
-
-
-
-
-%block>
\ No newline at end of file
diff --git a/brewman/brewman/templates/mytemplate.pt b/brewman/brewman/templates/mytemplate.pt
deleted file mode 100644
index bb8b94be..00000000
--- a/brewman/brewman/templates/mytemplate.pt
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
- The Pyramid Web Application Development Framework
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Welcome to ${project} , an application generated by
- the Pyramid web application development framework.
-
-
-
-
-
-
-
-
diff --git a/brewman/brewman/templates/nav_bar/ledger.pt b/brewman/brewman/templates/nav_bar/account.mako
similarity index 59%
rename from brewman/brewman/templates/nav_bar/ledger.pt
rename to brewman/brewman/templates/nav_bar/account.mako
index 0940d456..b6e7ac03 100644
--- a/brewman/brewman/templates/nav_bar/ledger.pt
+++ b/brewman/brewman/templates/nav_bar/account.mako
@@ -1,8 +1,8 @@
- Ledgers
+ Accounts
diff --git a/brewman/brewman/templates/nav_bar/login.pt b/brewman/brewman/templates/nav_bar/login.pt
index 7e4f93b2..31648a1b 100644
--- a/brewman/brewman/templates/nav_bar/login.pt
+++ b/brewman/brewman/templates/nav_bar/login.pt
@@ -1,5 +1,5 @@
- ${user.name}
+ ${user.name}
- User
+ User
+
${h.CsrfToken(request.session)}
-
- ${h.Label('Start Date:', 'txtStartDate')}
- ${h.TextInput('txtStartDate', css_class = 'non-search-box', autocomplete='off')}
-
+
+
Date
-
- ${h.Label('Finish Date:', 'txtFinishDate')}
- ${h.TextInput('txtFinishDate', css_class = 'non-search-box', autocomplete='off')}
-
+
+
+
+
+
+
+
Ledger
-
- ${h.Label('Ledger:', 'txtLedger')}
- ${h.TextInput('txtLedger', css_class = 'search-box', autocomplete='off', placeholder='Ledger')}
- ${h.SubmitButton('btnSubmit', 'Submit')}
-
+
+
+
+
-
-
-
-
- Date
- Particulars
- Type
- Narration
- Debit
- Credit
- Running
-
-
-
- ${body}
-
-
- ${footer}
-
-
-
+
+
+
+
+ Date
+ Particulars
+ Type
+ Narration
+ Debit
+ Credit
+ 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}}
+
+
+
+
+
%block>
\ No newline at end of file
diff --git a/brewman/brewman/templates/test.html b/brewman/brewman/templates/test.html
deleted file mode 100644
index e122280f..00000000
--- a/brewman/brewman/templates/test.html
+++ /dev/null
@@ -1,157 +0,0 @@
-
\ No newline at end of file
diff --git a/brewman/brewman/templates/transaction/journal.mako b/brewman/brewman/templates/transaction/journal.mako
index 417fd01d..f53dbed3 100644
--- a/brewman/brewman/templates/transaction/journal.mako
+++ b/brewman/brewman/templates/transaction/journal.mako
@@ -60,7 +60,7 @@
-
+
{{journal.Debit | debit}}
{{journal.Ledger.Name}}
{{journal.Amount}}
diff --git a/brewman/brewman/templates/upload_picture.pt b/brewman/brewman/templates/upload_picture.pt
deleted file mode 100644
index 02f93692..00000000
--- a/brewman/brewman/templates/upload_picture.pt
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
- Picture
-
-
-
- Comment (Required *)
-
-
-
- Size (Required *)
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/brewman/brewman/views/account.py b/brewman/brewman/views/account.py
new file mode 100644
index 00000000..fd0495f0
--- /dev/null
+++ b/brewman/brewman/views/account.py
@@ -0,0 +1,98 @@
+import json
+import uuid
+from pyramid.response import Response
+
+from pyramid.view import view_config
+import transaction
+from brewman.helpers import Literal
+
+from brewman.models.master import CostCenter, Ledger, LedgerType
+from brewman.models.validation_exception import ValidationError
+from brewman.views import DecimalEncoder
+
+@view_config(route_name='account_list', renderer='brewman:templates/angular_base.mako')
+@view_config(request_method='GET', route_name='account_id', renderer='brewman:templates/angular_base.mako',
+ xhr=False)
+@view_config(request_method='GET', route_name='account', renderer='brewman:templates/angular_base.mako',
+ xhr=False)
+def html(request):
+ return {}
+
+
+@view_config(request_method='POST', route_name='account_id', renderer='json', xhr=True)
+@view_config(request_method='POST', route_name='account', renderer='json', xhr=True)
+def save_update(request):
+ try:
+ id = request.matchdict.get('id', None)
+ if id is None:
+ Ledger(0, request.json_body['Name'], int(request.json_body['Type']), request.json_body['IsActive'],
+ uuid.UUID(request.json_body['CostCenter']['CostCenterID'])).create()
+ else:
+ new_type = int(request.json_body['Type'])
+ item = Ledger.by_id(uuid.UUID(id))
+ if not item.type == new_type:
+ item.code = Ledger.get_code(new_type)
+ item.type = new_type
+ item.name = request.json_body['Name']
+ item.is_active = request.json_body['IsActive']
+ item.costcenter_id = uuid.UUID(request.json_body['CostCenter']['CostCenterID'])
+ transaction.commit()
+ return account_info(item.id)
+ # url = request.route_url('account_list')
+ # return HTTPFound(location=url)
+ except ValidationError as ex:
+ transaction.abort()
+ response = Response("Failed validation: {0}".format(ex.message))
+ response.status_int = 500
+ return response
+
+
+@view_config(request_method='DELETE', route_name='account_id', renderer='json', xhr=True)
+def delete(request):
+ id = request.matchdict.get('id', None)
+ if id is None:
+ response = Response("Account is Null")
+ response.status_int = 500
+ return response
+ else:
+ response = Response("Account deletion not implemented")
+ response.status_int = 500
+ return response
+
+@view_config(request_method='GET', route_name='account_id', renderer='json', xhr=True)
+@view_config(request_method='GET', route_name='account', renderer='json', xhr=True)
+def show(request):
+ list = request.GET.get('list', None)
+
+ if list:
+ list = Ledger.list()
+ ledgers = []
+ for item in list:
+ ledgers.append({'Name': item.name, 'Type': item.type_object.name, 'IsActive': item.is_active,
+ 'CostCenter': item.costcenter.name, 'Url': request.route_url('account_id', id=item.id)})
+ return ledgers
+ else:
+ id = request.matchdict.get('id', None)
+ id = None if id is None else uuid.UUID(id)
+ return account_info(id)
+
+
+@view_config(request_method='GET', route_name='account_type_list', renderer='json', xhr=True)
+def account_type_list(request):
+ account_types = []
+ for item in LedgerType.list():
+ account_types.append({'AccountTypeID': item.id, 'Name': item.name})
+ return account_types
+
+def account_info(id):
+ if id is None:
+ account = {'Code': '(Auto)', 'Type': LedgerType.by_name('Creditors').id, 'IsActive': True,
+ 'CostCenter': CostCenter.overall()}
+ else:
+ account = Ledger.by_id(id)
+ account = {'LedgerID': account.id, 'Code': account.code, 'Name': account.name, 'Type': account.type,
+ 'IsActive': account.is_active,
+ 'CostCenter': {'CostCenterID': account.costcenter_id, 'Name': account.costcenter.name}}
+ return account
+
+
diff --git a/brewman/brewman/views/cost_center.py b/brewman/brewman/views/cost_center.py
index b2ae8533..a27deab0 100644
--- a/brewman/brewman/views/cost_center.py
+++ b/brewman/brewman/views/cost_center.py
@@ -43,7 +43,7 @@ def cost_center_submit(request):
# request.session.flash(ex.message)
return request
-@view_config(route_name='cost_center_list', renderer='brewman:templates/ledgers/cost_center_list.mako')
+@view_config(route_name='cost_center_list', renderer='brewman:templates/ledgers/cost_center_list.mako', xhr=False)
def cost_center_list(request):
dbsession = DBSession()
cost_centers = dbsession.query(CostCenter).all()
@@ -52,4 +52,14 @@ def cost_center_list(request):
'pageclass': "page-blogpost page-sidebar-right",
'pagecontentclass': "page-content grid_12",
'page_header': '',
- 'list': cost_centers}
\ No newline at end of file
+ 'list': cost_centers}
+
+
+@view_config(request_method='GET', route_name='cost_center_list', renderer='json', xhr=True)
+def get(request):
+ cost_centers = []
+ for item in CostCenter.list():
+ cost_centers.append({'CostCenterID': item.id, 'Name': item.name})
+ return cost_centers
+
+
diff --git a/brewman/brewman/views/ledger.py b/brewman/brewman/views/ledger.py
deleted file mode 100644
index c17d7066..00000000
--- a/brewman/brewman/views/ledger.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import uuid
-
-from pyramid.httpexceptions import HTTPFound
-from pyramid.view import view_config
-import transaction
-
-from brewman.models import DBSession
-from brewman.models.master import CostCenter, Ledger, LedgerType
-from brewman.models.validation_exception import ValidationError
-
-@view_config(request_method='GET', route_name='ledger_id', renderer='brewman:templates/ledgers/ledger_edit.mako')
-@view_config(request_method='GET', route_name='ledger', renderer='brewman:templates/ledgers/ledger_edit.mako')
-def ledger_edit(request):
- id = request.matchdict.get('id', None)
- if id is None:
- item = Ledger('(Auto)','')
- else:
- item = Ledger.by_id(uuid.UUID(id))
- return {'title':'Hops n Grains - Blog',
- 'pageclass': "page-blogpost page-sidebar-right",
- 'pagecontentclass': "page-content grid_12",
- 'page_header': '',
- 'item': item,
- 'types': LedgerType.list(),
- 'cost_centers': CostCenter.list()}
-
-@view_config(request_method='POST', route_name='ledger_id')
-@view_config(request_method='POST', route_name='ledger')
-def ledger_submit(request):
- try:
- id = request.matchdict.get('id', None)
- if id is None:
- Ledger(0,request.POST['name'], int(request.POST['type']), None, True if request.POST.has_key('is_active') else False, uuid.UUID(request.POST['cost_center_id'])).create()
- else:
- item = Ledger.by_id(uuid.UUID(id))
- item.name = request.POST['name']
- item.type = int(request.POST['type'])
- item.is_active = True if request.POST.has_key('is_active') else False
- item.costcenter_id = uuid.UUID(request.POST['cost_center_id'])
- transaction.commit()
- url = request.route_url('ledger_list')
- return HTTPFound(location=url)
- except ValidationError as ex:
-# request.session.flash(ex)
- transaction.abort()
-# request.session.flash(ex.message)
- return request
-
-@view_config(route_name='ledger_list', renderer='brewman:templates/ledgers/ledger_list.mako')
-def ledger_list_view(request):
- dbsession = DBSession()
- list = dbsession.query(Ledger).all()
-
- return {'title':'Hops n Grains - Blog',
- 'pageclass': "page-blogpost page-sidebar-right",
- 'pagecontentclass': "page-content grid_12",
- 'page_header': '',
- 'list': list}
diff --git a/brewman/brewman/views/nav_bar.py b/brewman/brewman/views/nav_bar.py
index 2f8635ac..e8c8b8fe 100644
--- a/brewman/brewman/views/nav_bar.py
+++ b/brewman/brewman/views/nav_bar.py
@@ -18,8 +18,8 @@ def entry_menu(request):
def employee_menu(request):
return render('brewman:templates/nav_bar/employee.pt', {'request': request})
-def ledger_menu(request):
- return render('brewman:templates/nav_bar/ledger.pt', {'request': request})
+def account_menu(request):
+ return render('brewman:templates/nav_bar/account.mako', {'request': request})
def product_menu(request):
return render('brewman:templates/nav_bar/product.pt', {'request': request})
diff --git a/brewman/brewman/views/reports/display_ledger.py b/brewman/brewman/views/reports/display_ledger.py
index b9e90176..69ae292b 100644
--- a/brewman/brewman/views/reports/display_ledger.py
+++ b/brewman/brewman/views/reports/display_ledger.py
@@ -1,4 +1,6 @@
import datetime
+import json
+from pyramid.response import Response
from sqlalchemy.orm import joinedload_all
from sqlalchemy.sql.expression import func
import uuid
@@ -10,67 +12,68 @@ from brewman.models import DBSession
from brewman.models.master import Ledger
from brewman.models.voucher import Voucher, Journal, VoucherType
+from brewman.views import DecimalEncoder
+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='display_ledger_id',
renderer='brewman:templates/reports/display_ledger.mako')
-@view_config(request_method='GET', route_name='display_ledger', renderer='brewman:templates/reports/display_ledger.mako')
+@view_config(request_method='GET', route_name='display_ledger',
+ renderer='brewman:templates/reports/display_ledger.mako')
def ledger_display_get(request):
- ledger_id = request.matchdict.get('id', None)
-
- if ledger_id is None:
- body = ""
- footer = ""
- ledger = ""
- 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')))
+ id = request.matchdict.get('id', None)
+ perms = Literal(json.dumps([]))
+ if id is None:
+ info = {'StartDate': services_session_period_start(request),
+ 'FinishDate': services_session_period_finish(request), 'Ledger': {}, 'Body': [],
+ 'Footer': {}}
else:
- ledger = Ledger.by_id(uuid.UUID(ledger_id))
- startDate = request.GET.get('startDate', None)
- finishDate = request.GET.get('finishDate', None)
- report = build_report(request, ledger, startDate, finishDate)
- body = Literal(report['body'])
- footer = Literal(report['footer'])
- startDate = Literal("$('#txtStartDate').val('{0}');".format(startDate))
- finishDate = Literal("$('#txtFinishDate').val('{0}');".format(finishDate))
- ledger = Literal("$('#txtLedger').val('{0}');".format(ledger.name))
+ start_date = request.GET.get('StartDate', services_session_period_start(request))
+ finish_date = request.GET.get('FinishDate', services_session_period_finish(request))
+ ledger = Ledger.by_id(uuid.UUID(id))
+ info = {'StartDate': start_date, 'FinishDate': finish_date,
+ 'Ledger': {'LedgerID': ledger.id, 'Name': ledger.name},
+ 'Body': [], 'Footer': {}}
- return {'title': 'Display Ledger - Hops n Grains',
- 'pageclass': "page-blogpost page-sidebar-right",
- 'pagecontentclass': "page-content grid_12",
- 'page_header': '',
- 'body': body,
- 'footer': footer,
- 'startDate': startDate,
- 'finishDate': finishDate,
- 'ledger':ledger}
+ build_report(request, info)
+ info = Literal(json.dumps(info, cls=DecimalEncoder))
+ return {'title': 'Journal Entry',
+ 'id': id,
+ 'perms': perms,
+ 'info': info}
-@view_config(request_method='POST', route_name='display_ledger', renderer='json', xhr=True)
+@view_config(request_method='GET', route_name='json_display_ledger', renderer='json', xhr=True)
def ledger_display_post(request):
- ledgerID = request.json_body['ledgerID']
- if ledgerID == '':
- ledgerString = request.json_body['ledgerString']
- ledger = Ledger.by_name(ledgerString)
+ id = request.matchdict.get('id', None)
+ if id is None:
+ response = Response("Ledger is Null")
+ response.status_int = 500
+ return response
else:
- ledgerID = uuid.UUID(ledgerID)
- ledger = Ledger.by_id(ledgerID)
- startDate = request.json_body['startDate']
- finishDate = request.json_body['finishDate']
- return build_report(request, ledger, startDate, finishDate)
+ ledger = Ledger.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,
+ 'Ledger': {'LedgerID': ledger.id, 'Name': ledger.name},
+ 'Body': [], 'Footer': {}}
+
+ build_report(request, info)
+
+ return info
-def build_report(request, ledger, startDate, finishDate):
- body = ''
- totalDebit, totalCredit, runningTotal, opening = opening_balance(ledger.id, startDate)
- body += opening
+def build_report(request, info):
+ ledger_id = info['Ledger']['LedgerID']
+ start_date = info['StartDate']
+ finish_date = info['FinishDate']
+ totalDebit, totalCredit, runningTotal, opening = opening_balance(ledger_id, start_date)
+ info['Body'].append(opening)
query = Voucher.query().options(joinedload_all(Voucher.journals, Journal.ledger, innerjoin=True))\
- .filter(Voucher.journals.any(Journal.ledger_id == ledger.id))\
- .filter(Voucher.date >= datetime.datetime.strptime(startDate, '%d-%b-%Y'))\
- .filter(Voucher.date <= datetime.datetime.strptime(finishDate, '%d-%b-%Y'))\
+ .filter(Voucher.journals.any(Journal.ledger_id == ledger_id))\
+ .filter(Voucher.date >= datetime.datetime.strptime(start_date, '%d-%b-%Y'))\
+ .filter(Voucher.date <= datetime.datetime.strptime(finish_date, '%d-%b-%Y'))\
.filter(Voucher.type != VoucherType.by_name('Issue').id)\
.order_by(Voucher.date).order_by(Voucher.last_edit_date).all()
@@ -80,7 +83,7 @@ def build_report(request, ledger, startDate, finishDate):
journalDebit = 0
name = ""
for journal in voucher.journals:
- if journal.ledger_id == ledger.id:
+ if journal.ledger_id == ledger_id:
if voucher.posted:
runningTotal += (journal.amount * journal.debit)
journalDebit = journal.debit
@@ -97,28 +100,17 @@ def build_report(request, ledger, startDate, finishDate):
name += "{0} / ".format(journal.ledger.name)
name = name[:-3]
running = "\u20B9 {0:,.2f}".format(abs(runningTotal)) + (' Dr' if runningTotal >= 0 else ' Cr')
- name = '' + name + ' '
- body += ' {2} {3} '\
- '{4} {5} <'\
- 'td class="Debit right">{6}\u20B9 {7} '\
- '{8} '.format(
- ('' if voucher.posted else ' unposted'), str(voucher.id), voucher.date.strftime('%d-%b-%Y'), name,
- VoucherType.by_id(voucher.type).name, voucher.narration, debit, credit, running)
+ info['Body'].append(
+ {'Date': voucher.date.strftime('%d-%b-%Y'), 'Name': name, 'Url': get_edit_url(request, voucher),
+ 'Type': VoucherType.by_id(voucher.type).name, 'Narration': voucher.narration, 'Debit': debit,
+ 'Credit': credit, 'Running': running, 'Posted': ('' if voucher.posted else 'unposted')})
- totalDebit = "\u20B9 {0:,.2f}".format(totalDebit)
- totalCredit = "\u20B9 {0:,.2f}".format(totalCredit)
- runningTotal = "\u20B9 {0:,.2f}".format(abs(runningTotal)) + (' Dr' if runningTotal >= 0 else ' Cr')
- voucher_type = VoucherType.by_name('Closing Balance')
- footer = '{0} {1} '\
- '{2} '\
- '{3} '\
- '{4} '\
- '{5} '.format(
- finishDate, voucher_type, voucher_type.name, totalDebit, totalCredit, runningTotal)
-
- return {'body': body, 'footer': footer, 'start_date': startDate, 'finish_date': finishDate, 'id': str(ledger.id),
- 'name': ledger.name, 'url': request.route_url('display_ledger_id', id=str(ledger.id),
- _query={'startDate': startDate, 'finishDate': finishDate})}
+ info['Footer'] = {'Date': finish_date, 'Name': 'Closing Balance', 'Type': 'Closing Balance',
+ 'Narration': '', 'Debit': "\u20B9 {0:,.2f}".format(totalDebit),
+ 'Credit': "\u20B9 {0:,.2f}".format(totalCredit),
+ 'Running': "\u20B9 {0:,.2f}".format(abs(runningTotal)) + (
+ ' Dr' if runningTotal >= 0 else ' Cr'),
+ 'Posted': ''}
def opening_balance(ledgerID, startDate):
@@ -148,9 +140,6 @@ def opening_balance(ledgerID, startDate):
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, '{0} {1} '\
- '{2} '\
- '{3} '\
- '{4} '\
- '{5} '.format(
- startDate, voucher_type.name, voucher_type.name, debitShow, creditShow, running)
+ return debit, credit, runningTotal, {'Date': startDate, 'Name': voucher_type.name, 'Type': voucher_type.name,
+ 'Narration': '', 'Debit': debitShow, 'Credit': creditShow,
+ 'Running': running, 'Posted': ''}
diff --git a/brewman/brewman/views/services/session.py b/brewman/brewman/views/services/session.py
index cdc91f8e..a0fd9c86 100644
--- a/brewman/brewman/views/services/session.py
+++ b/brewman/brewman/views/services/session.py
@@ -1,4 +1,5 @@
from datetime import date, timedelta
+import json
from pyramid.view import view_config
from brewman.views.transactions import session_current_date
@@ -44,6 +45,12 @@ def is_user_in_roles(request):
return roles
+@view_config(route_name='user_permissions', renderer='json', xhr=True)
+def user_permission(request):
+ print(json.dumps(request.session['perms']))
+ return request.session['perms']
+
+
def get_first_day(dt, d_years=0, d_months=0):
# d_years, d_months are "deltas" to apply to dt
y, m = dt.year + d_years, dt.month + d_months
diff --git a/brewman/brewman/views/services/voucher/__init__.py b/brewman/brewman/views/services/voucher/__init__.py
index cfad0561..5d9b4454 100644
--- a/brewman/brewman/views/services/voucher/__init__.py
+++ b/brewman/brewman/views/services/voucher/__init__.py
@@ -47,8 +47,6 @@ def voucher_post(request):
transaction.commit()
return voucher_info(Voucher.by_id(voucher.id))
except ValidationError as ex:
- print('error')
- print(ex.message)
transaction.abort()
response = Response("Failed validation: {0}".format(ex.message))
response.status_int = 500
diff --git a/brewman/development.ini b/brewman/development.ini
index 72454c5d..dedbcd20 100644
--- a/brewman/development.ini
+++ b/brewman/development.ini
@@ -6,8 +6,8 @@ pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
-pyramid.includes =
- pyramid_debugtoolbar
+# pyramid.includes =
+# pyramid_debugtoolbar
sqlalchemy.url = sqlite:///%(here)s/brewman/database/brewman.db
[server:main]