Added: Net Transactions report. Need to add roles in the Roles table in db.
Fixed: Single Client page gave 404 when opened directly Add role query: insert into auth_roles ("RoleID", "Name") VALUES ('2c40f7cf-67fc-4efa-a670-8d16a2e7884d', 'Net Transactions');
This commit is contained in:
parent
d187c1ee2f
commit
b3ece30300
@ -104,6 +104,8 @@ def main(global_config, **settings):
|
||||
add_route(config, 'product_ledger', '/ProductLedger', has_list=False)
|
||||
|
||||
add_route(config, 'trial_balance', '/TrialBalance', has_list=False, variable='date')
|
||||
config.add_route('api_net_transactions', '/api/NetTransactions')
|
||||
config.add_route('net_transactions', '/NetTransactions')
|
||||
add_route(config, 'closing_stock', '/ClosingStock', has_list=False, variable='date')
|
||||
|
||||
add_route(config, 'cash_flow', '/CashFlow', has_list=False)
|
||||
|
36
brewman/brewman/static/partial/net-transactions.html
Normal file
36
brewman/brewman/static/partial/net-transactions.html
Normal file
@ -0,0 +1,36 @@
|
||||
<form method="post" autocomplete="off" class="form-horizontal">
|
||||
<legend>Net Transactions</legend>
|
||||
<div class="control-group">
|
||||
<label for="txtStartDate" class="control-label">Date</label>
|
||||
|
||||
<div class="controls">
|
||||
<datepicker id="txtStartDate" model="info.StartDate" ng-model="info.StartDate"></datepicker>
|
||||
<datepicker id="txtFinishDate" model="info.FinishDate" ng-model="info.FinishDate"></datepicker>
|
||||
<button class="btn btn-info" ng-click="show()">Show <i class="icon-eye-open icon-white"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="gvGridProfitLoss" class="control-label"></label>
|
||||
|
||||
<div class="controls">
|
||||
<table id="gvGridProfitLoss" class="table table-condensed table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Name</th>
|
||||
<th>Debit</th>
|
||||
<th>Credit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in info.Body">
|
||||
<td>{{item.Type}}</td>
|
||||
<td>{{item.Name}}</td>
|
||||
<td class="right">{{item.Debit}}</td>
|
||||
<td class="right">{{item.Credit}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -122,6 +122,10 @@ overlord_service.factory('ProfitLoss', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProfitLoss');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('NetTransactions', ['$resource', function ($resource) {
|
||||
return $resource('/api/NetTransactions');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('PurchaseEntries', ['$resource', function ($resource) {
|
||||
return $resource('/api/PurchaseEntries');
|
||||
}]);
|
||||
|
29
brewman/brewman/static/scripts/net-transactions.js
Normal file
29
brewman/brewman/static/scripts/net-transactions.js
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
function NetTransactionsCtrl($scope, $location, net_transactions) {
|
||||
$scope.info = net_transactions;
|
||||
$scope.show = function () {
|
||||
$location.path('/NetTransactions').search({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}
|
||||
|
||||
NetTransactionsCtrl.resolve = {
|
||||
net_transactions:function ($q, $route, NetTransactions) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var start_date = $route.current.params.StartDate;
|
||||
var finish_date = $route.current.params.FinishDate;
|
||||
|
||||
var successCb = function(result){
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
if (typeof start_date === 'undefined' || typeof finish_date === 'undefined') {
|
||||
NetTransactions.get({}, successCb);
|
||||
} else {
|
||||
NetTransactions.get({StartDate:start_date, FinishDate:finish_date}, successCb);
|
||||
}
|
||||
return deferred.promise;
|
||||
}
|
||||
};
|
@ -49,6 +49,7 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
|
||||
when('/Daybook', {templateUrl: '/partial/daybook.html', controller: DaybookCtrl, resolve: DaybookCtrl.resolve}).
|
||||
when('/Unposted', {templateUrl: '/partial/unposted.html', controller: UnpostedCtrl, resolve: UnpostedCtrl.resolve}).
|
||||
when('/ProfitLoss', {templateUrl: '/partial/profit-loss.html', controller: ProfitLossCtrl, resolve: ProfitLossCtrl.resolve}).
|
||||
when('/NetTransactions', {templateUrl: '/partial/net-transactions.html', controller: NetTransactionsCtrl, resolve: NetTransactionsCtrl.resolve}).
|
||||
when('/PurchaseEntries', {templateUrl: '/partial/purchase-entries.html', controller: PurchaseEntriesCtrl, resolve: PurchaseEntriesCtrl.resolve}).
|
||||
when('/EmployeeFunctions', {templateUrl: '/partial/employee-functions.html', controller: EmployeeFunctionsCtrl}).
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
<script src="/script/ledger.js"></script>
|
||||
<script src="/script/product-ledger.js"></script>
|
||||
<script src="/script/trial-balance.js"></script>
|
||||
<script src="/script/net-transactions.js"></script>
|
||||
<script src="/script/closing-stock.js"></script>
|
||||
<script src="/script/profit-loss.js"></script>
|
||||
<script src="/script/purchase-entries.js"></script>
|
||||
@ -130,6 +131,7 @@
|
||||
<ul>
|
||||
<li><a href="/TrialBalance">Trail Balance</a></li>
|
||||
<li><a href="/ProfitLoss">Profit and Loss</a></li>
|
||||
<li><a href="/NetTransactions">Net Transactions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -11,6 +11,8 @@ from brewman.models.validation_exception import TryCatchFunction
|
||||
|
||||
@view_config(request_method='GET', route_name='client_list', renderer='brewman:templates/angular_base.mako',
|
||||
permission='Clients')
|
||||
@view_config(request_method='GET', route_name='client_id', renderer='brewman:templates/angular_base.mako',
|
||||
permission='Clients')
|
||||
def html(request):
|
||||
return {}
|
||||
|
||||
|
50
brewman/brewman/views/reports/net_transactions.py
Normal file
50
brewman/brewman/views/reports/net_transactions.py
Normal file
@ -0,0 +1,50 @@
|
||||
import datetime
|
||||
from sqlalchemy.sql.expression import func, desc
|
||||
|
||||
from pyramid.view import view_config
|
||||
|
||||
from brewman.models import DBSession
|
||||
from brewman.models.master import LedgerBase
|
||||
|
||||
from brewman.models.voucher import Voucher, Journal, VoucherType
|
||||
from brewman.views.services.session import session_period_finish, session_period_start
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='net_transactions', renderer='brewman:templates/angular_base.mako',
|
||||
permission='Net Transactions')
|
||||
def html(request):
|
||||
return {}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='api_net_transactions', renderer='json', permission='Net Transactions')
|
||||
def report(request):
|
||||
start_date = request.GET.get('StartDate', None)
|
||||
finish_date = request.GET.get('FinishDate', None)
|
||||
if start_date and finish_date:
|
||||
return {'StartDate': start_date, 'FinishDate': finish_date, 'Body': build_report(start_date, finish_date)}
|
||||
else:
|
||||
return {'StartDate': session_period_start(request),
|
||||
'FinishDate': session_period_finish(request), 'Body': []}
|
||||
|
||||
|
||||
def build_report(start_date, finish_date):
|
||||
if not isinstance(start_date, datetime.datetime):
|
||||
start_date = datetime.datetime.strptime(start_date, '%d-%b-%Y')
|
||||
if not isinstance(finish_date, datetime.datetime):
|
||||
finish_date = datetime.datetime.strptime(finish_date, '%d-%b-%Y')
|
||||
|
||||
amount_sum = func.sum(Journal.amount * Journal.debit).label('Amount')
|
||||
query = DBSession.query(LedgerBase, amount_sum) \
|
||||
.join(Journal.voucher).join(Journal.ledger) \
|
||||
.filter(Voucher.date >= start_date) \
|
||||
.filter(Voucher.date <= finish_date) \
|
||||
.filter(Voucher.type != VoucherType.by_name('Issue').id) \
|
||||
.group_by(LedgerBase).order_by(LedgerBase.type).order_by(desc(func.abs(amount_sum))).all()
|
||||
|
||||
body = []
|
||||
for ledger, amount in query:
|
||||
if amount != 0:
|
||||
tag = 'Debit' if amount > 0 else 'Credit'
|
||||
val = "\u20B9 {0:,.2f} Dr".format(amount) if amount > 0 else "\u20B9 {0:,.2f} Cr".format(amount * -1)
|
||||
body.append({'Type': ledger.type_object.name, 'Name': ledger.name, tag: val})
|
||||
return body
|
@ -13,7 +13,7 @@ from brewman.views.services.session import session_period_finish
|
||||
permission='Trial Balance')
|
||||
@view_config(request_method='GET', route_name='trial_balance_date', renderer='brewman:templates/angular_base.mako',
|
||||
permission='Trial Balance')
|
||||
def ledger_display_get(request):
|
||||
def html(request):
|
||||
return {}
|
||||
|
||||
@view_config(request_method='GET', route_name='api_trial_balance', renderer='json', permission='Trial Balance')
|
||||
|
Loading…
Reference in New Issue
Block a user