Drop Tax table.
Closing Stock and Raw Material Cost Reports working. Added spinner for long ajax operations with interceptor.
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
--update entities_ledgers set code = code + 60 where type = 13; -- to prevent duplicate code when converting
|
||||
UPDATE entities_ledgers SET type = 11 WHERE type = 13;
|
||||
DROP TABLE Entities_Taxes;
|
||||
UPDATE entities_vouchers SET date = date || ".000000", lasteditdate = lasteditdate || ".000000", creationdate = creationdate || ".000000";
|
||||
|
||||
@ -103,9 +103,15 @@ def main(global_config, **settings):
|
||||
config.add_route('trial_balance_date', '/TrialBalance/{date}')
|
||||
config.add_route('trial_balance', '/TrialBalance')
|
||||
|
||||
config.add_route('closing_stock_date', '/ClosingStock/{date}')
|
||||
config.add_route('closing_stock', '/ClosingStock')
|
||||
|
||||
config.add_route('cash_flow_id', '/CashFlow/{id}')
|
||||
config.add_route('cash_flow', '/CashFlow')
|
||||
|
||||
config.add_route('raw_material_cost_id', '/RawMaterialCost/{id}')
|
||||
config.add_route('raw_material_cost', '/RawMaterialCost')
|
||||
|
||||
config.add_route('daybook', '/Daybook')
|
||||
config.add_route('unposted', '/Unposted')
|
||||
config.add_route('profit_loss', '/ProfitLoss')
|
||||
|
||||
@ -346,7 +346,7 @@ class LedgerType:
|
||||
list.append(LedgerType(10, 'Salary', True, True, True, 40, False))
|
||||
list.append(LedgerType(11, 'Liabilities', True, False, True, 50, True))
|
||||
list.append(LedgerType(12, 'Revenue', False, False, True, 30, True))
|
||||
list.append(LedgerType(13, 'Tax', True, False, True, 80, True))
|
||||
# list.append(LedgerType(13, 'Tax', True, False, True, 80, True))
|
||||
# list.append(LedgerType(14, 'Total', False, False, False, 900, False))
|
||||
# list.append(LedgerType(15, 'Net', False, False, False, 1000, False))
|
||||
return list
|
||||
@ -365,16 +365,4 @@ class LedgerType:
|
||||
list = cls.list()
|
||||
for item in list:
|
||||
if item.id == id:
|
||||
return item
|
||||
|
||||
|
||||
class Tax(Base):
|
||||
__tablename__ = 'entities_taxes'
|
||||
|
||||
id = Column('TaxID', GUID(), primary_key=True, default=uuid.uuid4)
|
||||
name = Column('Name', Unicode(255), unique=True)
|
||||
rate = Column('Rate', Numeric)
|
||||
|
||||
def __init__(self, name=None, rate=None):
|
||||
self.name = name
|
||||
self.rate = rate
|
||||
return item
|
||||
118
brewman/brewman/static/css/spinner.css
Normal file
118
brewman/brewman/static/css/spinner.css
Normal file
@ -0,0 +1,118 @@
|
||||
#spinner {
|
||||
position: fixed;
|
||||
/*top: 0;*/
|
||||
/*left: 0;*/
|
||||
/*width: 128px;*/
|
||||
/*height: 128px;*/
|
||||
/*! important !*/
|
||||
display: none;
|
||||
/* last attribute set darkness on scale: 0...1.0 */
|
||||
/*background-color: rgba(0, 0, 0, 0.8);*/
|
||||
text-align: center;
|
||||
z-index: 101;
|
||||
}
|
||||
|
||||
#circleG{
|
||||
width:112px;
|
||||
}
|
||||
|
||||
.circleG{
|
||||
background-color:#FFFFFF;
|
||||
float:left;
|
||||
height:24px;
|
||||
margin-left:13px;
|
||||
width:24px;
|
||||
-webkit-animation-name:bounce_circleG;
|
||||
-webkit-border-radius:16px;
|
||||
-webkit-animation-duration:1.9500000000000002s;
|
||||
-webkit-animation-iteration-count:infinite;
|
||||
-webkit-animation-direction:linear;
|
||||
-moz-animation-name:bounce_circleG;
|
||||
-moz-border-radius:16px;
|
||||
-moz-animation-duration:1.9500000000000002s;
|
||||
-moz-animation-iteration-count:infinite;
|
||||
-moz-animation-direction:linear;
|
||||
opacity:0.3;
|
||||
-o-animation-name:bounce_circleG;
|
||||
border-radius:16px;
|
||||
-o-animation-duration:1.9500000000000002s;
|
||||
-o-animation-iteration-count:infinite;
|
||||
-o-animation-direction:linear;
|
||||
-ms-animation-name:bounce_circleG;
|
||||
-ms-animation-duration:1.9500000000000002s;
|
||||
-ms-animation-iteration-count:infinite;
|
||||
-ms-animation-direction:linear;
|
||||
opacity:0.3}
|
||||
|
||||
#circleG_1{
|
||||
-webkit-animation-delay:0.39s;
|
||||
-moz-animation-delay:0.39s;
|
||||
-o-animation-delay:0.39s;
|
||||
-ms-animation-delay:0.39s;
|
||||
}
|
||||
|
||||
#circleG_2{
|
||||
-webkit-animation-delay:0.91s;
|
||||
-moz-animation-delay:0.91s;
|
||||
-o-animation-delay:0.91s;
|
||||
-ms-animation-delay:0.91s;
|
||||
}
|
||||
|
||||
#circleG_3{
|
||||
-webkit-animation-delay:1.17s;
|
||||
-moz-animation-delay:1.17s;
|
||||
-o-animation-delay:1.17s;
|
||||
-ms-animation-delay:1.17s;
|
||||
}
|
||||
|
||||
@-webkit-keyframes bounce_circleG{
|
||||
0%{
|
||||
opacity:0.3}
|
||||
|
||||
50%{
|
||||
opacity:1;
|
||||
background-color:#000000}
|
||||
|
||||
100%{
|
||||
opacity:0.3}
|
||||
|
||||
}
|
||||
|
||||
@-moz-keyframes bounce_circleG{
|
||||
0%{
|
||||
opacity:0.3}
|
||||
|
||||
50%{
|
||||
opacity:1;
|
||||
background-color:#000000}
|
||||
|
||||
100%{
|
||||
opacity:0.3}
|
||||
|
||||
}
|
||||
|
||||
@-o-keyframes bounce_circleG{
|
||||
0%{
|
||||
opacity:0.3}
|
||||
|
||||
50%{
|
||||
opacity:1;
|
||||
background-color:#000000}
|
||||
|
||||
100%{
|
||||
opacity:0.3}
|
||||
|
||||
}
|
||||
|
||||
@-ms-keyframes bounce_circleG{
|
||||
0%{
|
||||
opacity:0.3}
|
||||
|
||||
50%{
|
||||
opacity:1;
|
||||
background-color:#000000}
|
||||
|
||||
100%{
|
||||
opacity:0.3}
|
||||
|
||||
}
|
||||
35
brewman/brewman/static/partial/closing-stock.html
Normal file
35
brewman/brewman/static/partial/closing-stock.html
Normal file
@ -0,0 +1,35 @@
|
||||
<form method="post" autocomplete="off" class="horizontal-form" ng-controller="ClosingStockCtrl">
|
||||
<legend>Closing Stock</legend>
|
||||
<div class="control-group">
|
||||
<label for="txtDate" class="control-label">Date</label>
|
||||
|
||||
<div class="controls">
|
||||
<datepicker id="txtDate" model="info" prop="FinishDate" ng-model="info.Date"></datepicker>
|
||||
<button ng-click="show()">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="gvGrid" class="control-label"></label>
|
||||
|
||||
<div class="controls">
|
||||
<table id="gvGrid" class="clean-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th>Group</th>
|
||||
<th>Quantity</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in info.Body">
|
||||
<th><a href="{{item.Url}}">{{item.Product}}</a></th>
|
||||
<th>{{item.Group}}</th>
|
||||
<th class="right">{{item.Quantity}}</th>
|
||||
<th class="right">{{item.Amount}}</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
38
brewman/brewman/static/partial/raw-material-cost-detail.html
Normal file
38
brewman/brewman/static/partial/raw-material-cost-detail.html
Normal file
@ -0,0 +1,38 @@
|
||||
<form method="post" autocomplete="off" class="horizontal-form" ng-controller="RawMaterialCostCtrl">
|
||||
<legend>Raw Material Cost Detail</legend>
|
||||
<div class="control-group">
|
||||
<label for="txtStartDate" class="control-label">Date</label>
|
||||
|
||||
<div class="controls">
|
||||
<datepicker id="txtStartDate" model="info" prop="StartDate" ng-model="info.StartDate"></datepicker>
|
||||
<datepicker id="txtFinishDate" model="info" prop="FinishDate" ng-model="info.FinishDate"></datepicker>
|
||||
<button ng-click="show()">Show</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="gvGrid" class="control-label"></label>
|
||||
|
||||
<div class="controls">
|
||||
<table id="gvGrid" class="clean-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th>Group</th>
|
||||
<th class="right">Quantity</th>
|
||||
<th class="right">Net</th>
|
||||
<th class="right">Gross</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in info.Body" ng-class="{true:'unposted', false:''}[item.Heading]">
|
||||
<td><a href="{{item.Url}}">{{item.Name}}</a></td>
|
||||
<td>{{item.Group}}</td>
|
||||
<td class="right">{{item.Quantity}}</td>
|
||||
<td class="right">{{item.Net}}</td>
|
||||
<td class="right">{{item.Gross}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
44
brewman/brewman/static/partial/raw-material-cost.html
Normal file
44
brewman/brewman/static/partial/raw-material-cost.html
Normal file
@ -0,0 +1,44 @@
|
||||
<form method="post" autocomplete="off" class="horizontal-form" ng-controller="RawMaterialCostCtrl">
|
||||
<legend>Raw Material Cost</legend>
|
||||
<div class="control-group">
|
||||
<label for="txtStartDate" class="control-label">Date</label>
|
||||
|
||||
<div class="controls">
|
||||
<datepicker id="txtStartDate" model="info" prop="StartDate" ng-model="info.StartDate"></datepicker>
|
||||
<datepicker id="txtFinishDate" model="info" prop="FinishDate" ng-model="info.FinishDate"></datepicker>
|
||||
<button ng-click="show()">Show</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="gvGrid" class="control-label"></label>
|
||||
|
||||
<div class="controls">
|
||||
<table id="gvGrid" class="clean-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Cost Center</th>
|
||||
<th>Issue</th>
|
||||
<th>Sale</th>
|
||||
<th>Rmc</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in info.Body">
|
||||
<td><a href="{{item.Url}}">{{item.Name}}</a></td>
|
||||
<td class="right">{{item.Issue}}</td>
|
||||
<td class="right">{{item.Sale}}</td>
|
||||
<td class="right">{{item.Rmc}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr ng-repeat="item in info.Footer">
|
||||
<td>{{item.Name}}</td>
|
||||
<td class="right">{{item.Issue}}</td>
|
||||
<td class="right">{{item.Sale}}</td>
|
||||
<td class="right">{{item.Rmc}}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -95,6 +95,11 @@ overlord_service.factory('TrialBalance', ['$resource', function ($resource) {
|
||||
return $resource('/TrialBalance/:date');
|
||||
}]);
|
||||
|
||||
// TODO: Replace hardcoded url with route_url
|
||||
overlord_service.factory('ClosingStock', ['$resource', function ($resource) {
|
||||
return $resource('/ClosingStock/:date');
|
||||
}]);
|
||||
|
||||
// TODO: Replace hardcoded url with route_url
|
||||
overlord_service.factory('CashFlow', ['$resource', function ($resource) {
|
||||
return $resource('/CashFlow/:id');
|
||||
@ -115,6 +120,11 @@ overlord_service.factory('ProfitLoss', ['$resource', function ($resource) {
|
||||
return $resource('/ProfitLoss');
|
||||
}]);
|
||||
|
||||
// TODO: Replace hardcoded url with route_url
|
||||
overlord_service.factory('RawMaterialCost', ['$resource', function ($resource) {
|
||||
return $resource('/RawMaterialCost/:id');
|
||||
}]);
|
||||
|
||||
// TODO: Replace hardcoded url with route_url
|
||||
overlord_service.factory('LedgerService', ['$resource', function ($resource) {
|
||||
return $resource('/Services/Accounts/:type');
|
||||
|
||||
17
brewman/brewman/static/scripts/closing-stock.js
Normal file
17
brewman/brewman/static/scripts/closing-stock.js
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
function ClosingStockCtrl($scope, $routeParams, $location, ClosingStock) {
|
||||
if (typeof $routeParams.date === 'undefined') {
|
||||
$scope.info = ClosingStock.get({});
|
||||
} else {
|
||||
$scope.info = ClosingStock.get({date:$routeParams.date});
|
||||
|
||||
}
|
||||
$scope.show = function () {
|
||||
$scope.info = ClosingStock.get({id:$scope.info.Date}, function (u, putResponseHeaders) {
|
||||
$location.path('/ClosingStock/' + u.Date);
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type:'Error', Message:data.data});
|
||||
});
|
||||
};
|
||||
$('#txtDate').focus();
|
||||
}
|
||||
@ -1,70 +1,97 @@
|
||||
'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'}).
|
||||
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('/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('/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('/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('/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('/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('/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('/ProductLedger', {templateUrl:'/partial/product-ledger.html', controller:ProductLedgerCtrl}).
|
||||
when('/ProductLedger/:id', {templateUrl:'/partial/product-ledger.html', controller:ProductLedgerCtrl}).
|
||||
|
||||
when('/CashFlow', {templateUrl:'/partial/cash-flow.html', controller:CashFlowCtrl}).
|
||||
when('/CashFlow/:id', {templateUrl:'/partial/cash-flow.html', controller:CashFlowCtrl}).
|
||||
when('/CashFlow', {templateUrl:'/partial/cash-flow.html', controller:CashFlowCtrl}).
|
||||
when('/CashFlow/:id', {templateUrl:'/partial/cash-flow.html', controller:CashFlowCtrl}).
|
||||
|
||||
when('/RawMaterialCost', {templateUrl:'/partial/raw-material-cost.html', controller:RawMaterialCostCtrl}).
|
||||
when('/RawMaterialCost/:id', {templateUrl:'/partial/raw-material-cost-detail.html', controller:RawMaterialCostCtrl}).
|
||||
|
||||
// when('/Ledger', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl, resolve: LedgerCtrl.resolve}).
|
||||
// when('/Ledger/:id', {templateUrl:'/partial/ledger.html', controller:LedgerCtrl, resolve: LedgerCtrl.resolve}).
|
||||
|
||||
when('/Daybook', {templateUrl:'/partial/daybook.html', controller:DaybookCtrl}).
|
||||
when('/Unposted', {templateUrl:'/partial/unposted.html', controller:UnpostedCtrl}).
|
||||
when('/ProfitLoss', {templateUrl:'/partial/profit-loss.html', controller:ProfitLossCtrl}).
|
||||
when('/Daybook', {templateUrl:'/partial/daybook.html', controller:DaybookCtrl}).
|
||||
when('/Unposted', {templateUrl:'/partial/unposted.html', controller:UnpostedCtrl}).
|
||||
when('/ProfitLoss', {templateUrl:'/partial/profit-loss.html', controller:ProfitLossCtrl}).
|
||||
|
||||
when('/TrialBalance', {templateUrl:'/partial/trial-balance.html', controller:TrialBalanceCtrl}).
|
||||
when('/TrialBalance/:date', {templateUrl:'/partial/trial-balance.html', controller:TrialBalanceCtrl}).
|
||||
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('/ClosingStock', {templateUrl:'/partial/closing-stock.html', controller:ClosingStockCtrl}).
|
||||
when('/ClosingStock/:date', {templateUrl:'/partial/closing-stock.html', controller:ClosingStockCtrl}).
|
||||
|
||||
when('/Employees', {templateUrl:'/partial/employee-list.html', controller:EmployeeListCtrl}).
|
||||
when('/Employee', {templateUrl:'/partial/employee-detail.html', controller:EmployeeCtrl}).
|
||||
when('/Employee/:id', {templateUrl:'/partial/employee-detail.html', controller:EmployeeCtrl}).
|
||||
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('/Employees', {templateUrl:'/partial/employee-list.html', controller:EmployeeListCtrl}).
|
||||
when('/Employee', {templateUrl:'/partial/employee-detail.html', controller:EmployeeCtrl}).
|
||||
when('/Employee/:id', {templateUrl:'/partial/employee-detail.html', controller:EmployeeCtrl}).
|
||||
|
||||
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('/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('/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('/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('/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});
|
||||
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);
|
||||
}]);
|
||||
$locationProvider.html5Mode(true);
|
||||
}])
|
||||
.config(function ($httpProvider) {
|
||||
$httpProvider.responseInterceptors.push('spinnerInterceptor');
|
||||
var spinnerFunction = function (data, headersGetter) {
|
||||
$('#spinner').show();
|
||||
return data;
|
||||
};
|
||||
$httpProvider.defaults.transformRequest.push(spinnerFunction);
|
||||
})
|
||||
.factory('spinnerInterceptor', function ($q, $window) {
|
||||
return function (promise) {
|
||||
return promise.then(function (response) {
|
||||
$('#spinner').hide();
|
||||
return response;
|
||||
|
||||
}, function (response) {
|
||||
$('#spinner').hide();
|
||||
return $q.reject(response);
|
||||
});
|
||||
};
|
||||
})
|
||||
;
|
||||
|
||||
function BaseCtrl($scope, Permission) {
|
||||
$scope.perms = Permission.get();
|
||||
|
||||
17
brewman/brewman/static/scripts/raw-material-cost.js
Normal file
17
brewman/brewman/static/scripts/raw-material-cost.js
Normal file
@ -0,0 +1,17 @@
|
||||
function RawMaterialCostCtrl($scope, $routeParams, $location, RawMaterialCost) {
|
||||
if (typeof $routeParams.StartDate === 'undefined') {
|
||||
$scope.info = RawMaterialCost.get({});
|
||||
} else if (typeof $routeParams.id === 'undefined') {
|
||||
$scope.info = RawMaterialCost.get({StartDate:$routeParams.StartDate, FinishDate:$routeParams.FinishDate});
|
||||
} else {
|
||||
$scope.info = RawMaterialCost.get({id:$routeParams.id, StartDate:$routeParams.StartDate, FinishDate:$routeParams.FinishDate});
|
||||
}
|
||||
$scope.show = function () {
|
||||
$scope.info = RawMaterialCost.get({StartDate:$scope.info.StartDate, FinishDate:$scope.info.FinishDate}, function (u, putResponseHeaders) {
|
||||
$location.path('/RawMaterialCost').search({StartDate:u.StartDate, FinishDate:u.FinishDate});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type:'Error', Message:data.data});
|
||||
});
|
||||
};
|
||||
$('#txtStartDate').focus();
|
||||
}
|
||||
@ -19,6 +19,8 @@
|
||||
|
||||
${h.CssLink(request, 'jquery-ui-1.8.16.custom.css')}
|
||||
|
||||
${h.CssLink(request, 'spinner.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')}
|
||||
@ -41,8 +43,10 @@
|
||||
${h.ScriptLink(request, 'ledger.js')}
|
||||
${h.ScriptLink(request, 'product-ledger.js')}
|
||||
${h.ScriptLink(request, 'trial-balance.js')}
|
||||
${h.ScriptLink(request, 'closing-stock.js')}
|
||||
${h.ScriptLink(request, 'profit-loss.js')}
|
||||
${h.ScriptLink(request, 'cash-flow.js')}
|
||||
${h.ScriptLink(request, 'raw-material-cost.js')}
|
||||
${h.ScriptLink(request, 'daybook.js')}
|
||||
${h.ScriptLink(request, 'unposted.js')}
|
||||
|
||||
@ -102,7 +106,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="spinner" class="row span4 offset4">
|
||||
|
||||
<div id="circleG">
|
||||
<div id="circleG_1" class="circleG">
|
||||
</div>
|
||||
<div id="circleG_2" class="circleG">
|
||||
</div>
|
||||
<div id="circleG_3" class="circleG">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ng-view></ng-view>
|
||||
<hr>
|
||||
|
||||
|
||||
@ -3,15 +3,15 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="${request.route_url('ledger')}">Display Ledger</a></li>
|
||||
<li><a href="${request.route_url('product_ledger')}">Product Ledger</a></li>
|
||||
## <li><a href="/AccountsTesting/Reports/RawMaterialCost.aspx">Raw Material Cost</a></li>
|
||||
<li><a href="${request.route_url('cash_flow')}">Cash Flow</a></li>
|
||||
<li><a href="${request.route_url('daybook')}">Day Book</a></li>
|
||||
<li><a href="">Purchases</a>
|
||||
<ul>
|
||||
<li><a href="${request.route_url('raw_material_cost')}">Raw Material Cost</a></li>
|
||||
<li><a href="/AccountsTesting/Reports/PurchaseEntry.aspx">Purchase Entry</a></li>
|
||||
## <li><a href="/AccountsTesting/Reports/Purchases/Purchases.aspx">Purchases</a></li>
|
||||
## <li><a href="/AccountsTesting/Reports/Purchases/PurchaseLedger.aspx">Purchase Ledger</a></li>
|
||||
<li><a href="/AccountsTesting/Reports/ClosingStock.aspx">Closing Stock</a></li>
|
||||
<li><a href="${request.route_url('closing_stock')}">Closing Stock</a></li>
|
||||
## <li><a href="/AccountsTesting/Reports/Inventory/Main.aspx">Inventory Report</a></li>
|
||||
<li><a href="/AccountsTesting/Reports/Issue/Issue_All.aspx">Issue</a></li>
|
||||
</ul>
|
||||
|
||||
@ -54,22 +54,25 @@ def delete(request):
|
||||
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_id', renderer='json', xhr=True)
|
||||
def show_id(request):
|
||||
return account_info(uuid.UUID(request.matchdict.get('id', None)))
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='account', renderer='json', xhr=True)
|
||||
def show_blank(request):
|
||||
return account_info(None)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='account', renderer='json', request_param='list', xhr=True)
|
||||
def show_list(request):
|
||||
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
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='account_type_list', renderer='json', xhr=True)
|
||||
@ -79,6 +82,7 @@ def account_type_list(request):
|
||||
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,
|
||||
|
||||
@ -49,20 +49,22 @@ def delete(request):
|
||||
return response
|
||||
|
||||
@view_config(request_method='GET', route_name='cost_center_id', renderer='json', xhr=True)
|
||||
@view_config(request_method='GET', route_name='cost_center', renderer='json', xhr=True)
|
||||
def show(request):
|
||||
list = request.GET.get('list', None)
|
||||
def show_id(request):
|
||||
return cost_center_info(uuid.UUID(request.matchdict.get('id', None)))
|
||||
|
||||
if list:
|
||||
list = CostCenter.list()
|
||||
cost_centers = []
|
||||
for item in list:
|
||||
cost_centers.append({'CostCenterID': item.id, 'Name': item.name, 'Url': request.route_url('cost_center_id', id=item.id)})
|
||||
return cost_centers
|
||||
else:
|
||||
id = request.matchdict.get('id', None)
|
||||
id = None if id is None else uuid.UUID(id)
|
||||
return cost_center_info(id)
|
||||
|
||||
@view_config(request_method='GET', route_name='cost_center', renderer='json', xhr=True)
|
||||
def show_blank(request):
|
||||
return cost_center_info(None)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='cost_center', request_param='list', renderer='json', xhr=True)
|
||||
def show_list(request):
|
||||
list = CostCenter.list()
|
||||
cost_centers = []
|
||||
for item in list:
|
||||
cost_centers.append({'CostCenterID': item.id, 'Name': item.name, 'Url': request.route_url('cost_center_id', id=item.id)})
|
||||
return cost_centers
|
||||
|
||||
|
||||
def cost_center_info(id):
|
||||
|
||||
@ -70,25 +70,27 @@ def delete(request):
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='employee_id', renderer='json', xhr=True)
|
||||
@view_config(request_method='GET', route_name='employee', renderer='json', xhr=True)
|
||||
def show(request):
|
||||
list = request.GET.get('list', None)
|
||||
def show_id(request):
|
||||
return employee_info(uuid.UUID(request.matchdict.get('id', None)))
|
||||
|
||||
if list:
|
||||
list = Employee.list()
|
||||
ledgers = []
|
||||
for item in list:
|
||||
ledgers.append(
|
||||
{'Code': item.code, 'Name': item.name, 'Designation': item.designation, 'Salary': item.salary,
|
||||
'ServicePoints': item.service_points, 'IsActive': item.is_active,
|
||||
'CostCenter': item.costcenter.name, 'Url': request.route_url('employee_id', id=item.id),
|
||||
'JoiningDate': item.joining_date.strftime('%d-%b-%Y'),
|
||||
'LeavingDate': '' if item.is_active else item.leaving_date.strftime('%d-%b-%Y')})
|
||||
return ledgers
|
||||
else:
|
||||
id = request.matchdict.get('id', None)
|
||||
id = None if id is None else uuid.UUID(id)
|
||||
return employee_info(id)
|
||||
|
||||
@view_config(request_method='GET', route_name='employee', renderer='json', xhr=True)
|
||||
def show_blank(request):
|
||||
return employee_info(None)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='employee', request_param='list', renderer='json', xhr=True)
|
||||
def show_list(request):
|
||||
list = Employee.list()
|
||||
ledgers = []
|
||||
for item in list:
|
||||
ledgers.append(
|
||||
{'Code': item.code, 'Name': item.name, 'Designation': item.designation, 'Salary': item.salary,
|
||||
'ServicePoints': item.service_points, 'IsActive': item.is_active,
|
||||
'CostCenter': item.costcenter.name, 'Url': request.route_url('employee_id', id=item.id),
|
||||
'JoiningDate': item.joining_date.strftime('%d-%b-%Y'),
|
||||
'LeavingDate': '' if item.is_active else item.leaving_date.strftime('%d-%b-%Y')})
|
||||
return ledgers
|
||||
|
||||
|
||||
def employee_info(id):
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
import time
|
||||
from pyramid.response import Response
|
||||
from pyramid.view import view_config
|
||||
from brewman import current_table
|
||||
import random
|
||||
|
||||
def produce():
|
||||
i = 0
|
||||
global current_table
|
||||
current_table += 1
|
||||
while i < 10:
|
||||
time.sleep(1)
|
||||
i += 1
|
||||
data = 'data: table{0} i{1} {2}\n\n'.format(current_table, i, time.time())
|
||||
print (data)
|
||||
yield bytearray(data, 'utf-8')
|
||||
# yield data
|
||||
# yield bytearray('data: 11 22\n\n', 'utf-8')
|
||||
|
||||
@view_config(route_name='sse', renderer='string')
|
||||
def stream(request):
|
||||
response = Response()
|
||||
response.headers.update({'Access-Control-Allow-Origin': '*'})
|
||||
response.content_type = 'text/event-stream'
|
||||
response.cache_expires(0)
|
||||
response.app_iter = produce()
|
||||
return response
|
||||
@ -35,10 +35,7 @@ def login_submit(request):
|
||||
found, user = User.auth(username, password)
|
||||
if found:
|
||||
headers = remember(request, str(user.id))
|
||||
request.session.flash('Logged in successfully.')
|
||||
return HTTPFound(location=came_from, headers=headers)
|
||||
|
||||
request.session.flash('Login Failed')
|
||||
return {'title': 'Login',
|
||||
'pageclass': "page-gallery skin-7",
|
||||
'pagecontentclass': "page-content",
|
||||
|
||||
@ -62,23 +62,25 @@ def delete(request):
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='product_id', renderer='json', xhr=True)
|
||||
@view_config(request_method='GET', route_name='product', renderer='json', xhr=True)
|
||||
def show(request):
|
||||
list = request.GET.get('list', None)
|
||||
def show_id(request):
|
||||
return product_info(uuid.UUID(request.matchdict.get('id', None)))
|
||||
|
||||
if list:
|
||||
list = Product.query().order_by(Product.discontinued).order_by(Product.product_group_id).order_by(
|
||||
Product.name).all()
|
||||
products = []
|
||||
for item in list:
|
||||
products.append({'Code': item.code, 'Name': item.name, 'Units': item.units, 'Price': item.price,
|
||||
'ProductGroup': item.product_group.name, 'Discontinued': item.discontinued,
|
||||
'Url': request.route_url('product_id', id=item.id)})
|
||||
return products
|
||||
else:
|
||||
id = request.matchdict.get('id', None)
|
||||
id = None if id is None else uuid.UUID(id)
|
||||
return product_info(id)
|
||||
|
||||
@view_config(request_method='GET', route_name='product', renderer='json', xhr=True)
|
||||
def show_blank(request):
|
||||
return product_info(None)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='product', request_param='list', renderer='json', xhr=True)
|
||||
def show_list(request):
|
||||
list = Product.query().order_by(Product.discontinued).order_by(Product.product_group_id).order_by(
|
||||
Product.name).all()
|
||||
products = []
|
||||
for item in list:
|
||||
products.append({'Code': item.code, 'Name': item.name, 'Units': item.units, 'Price': item.price,
|
||||
'ProductGroup': item.product_group.name, 'Discontinued': item.discontinued,
|
||||
'Url': request.route_url('product_id', id=item.id)})
|
||||
return products
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='product_group_list', renderer='json', xhr=True)
|
||||
|
||||
@ -51,20 +51,22 @@ def delete(request):
|
||||
return response
|
||||
|
||||
@view_config(request_method='GET', route_name='product_group_id', renderer='json', xhr=True)
|
||||
@view_config(request_method='GET', route_name='product_group', renderer='json', xhr=True)
|
||||
def show(request):
|
||||
list = request.GET.get('list', None)
|
||||
def show_id(request):
|
||||
return product_group_info(uuid.UUID(request.matchdict.get('id', None)))
|
||||
|
||||
if list:
|
||||
list = ProductGroup.list()
|
||||
product_groups = []
|
||||
for item in list:
|
||||
product_groups.append({'ProductGroupID': item.id, 'Name': item.name, 'Url': request.route_url('product_group_id', id=item.id)})
|
||||
return product_groups
|
||||
else:
|
||||
id = request.matchdict.get('id', None)
|
||||
id = None if id is None else uuid.UUID(id)
|
||||
return product_group_info(id)
|
||||
|
||||
@view_config(request_method='GET', route_name='product_group', renderer='json', xhr=True)
|
||||
def show_blank(request):
|
||||
return product_group_info(None)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='product_group', request_param='list', renderer='json', xhr=True)
|
||||
def show_list(request):
|
||||
list = ProductGroup.list()
|
||||
product_groups = []
|
||||
for item in list:
|
||||
product_groups.append({'ProductGroupID': item.id, 'Name': item.name, 'Url': request.route_url('product_group_id', id=item.id)})
|
||||
return product_groups
|
||||
|
||||
|
||||
def product_group_info(id):
|
||||
|
||||
97
brewman/brewman/views/reports/closing_stock.py
Normal file
97
brewman/brewman/views/reports/closing_stock.py
Normal file
@ -0,0 +1,97 @@
|
||||
import datetime
|
||||
from sqlalchemy.sql.expression import func
|
||||
|
||||
from pyramid.view import view_config
|
||||
|
||||
from brewman.models import DBSession
|
||||
from brewman.models.master import Product, CostCenter
|
||||
|
||||
from brewman.models.voucher import Voucher, Journal, Inventory
|
||||
from brewman.views.services.session import services_session_period_finish
|
||||
|
||||
@view_config(request_method='GET', route_name='closing_stock', renderer='brewman:templates/angular_base.mako',
|
||||
xhr=False)
|
||||
@view_config(request_method='GET', route_name='closing_stock_date', renderer='brewman:templates/angular_base.mako',
|
||||
xhr=False)
|
||||
def get_html(request):
|
||||
return {}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='closing_stock', renderer='json', xhr=True)
|
||||
def report_blank(request):
|
||||
return {'Date': services_session_period_finish(request), 'Body': []}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='closing_stock_date', renderer='json', xhr=True)
|
||||
def report_data(request):
|
||||
date = request.matchdict.get('date', None)
|
||||
return {'Date': date, 'Body': build_report(date)}
|
||||
|
||||
|
||||
def build_report(date):
|
||||
date = datetime.datetime.strptime(date, '%d-%b-%Y')
|
||||
amount_sum = func.sum(Journal.debit * Inventory.quantity * Inventory.rate * (1 + Inventory.tax)).label('Amount')
|
||||
quantity_sum = func.sum(Journal.debit * Inventory.quantity).label('Quantity')
|
||||
query = DBSession.query(Product, quantity_sum, amount_sum)\
|
||||
.join(Product.inventories).join(Inventory.voucher).join(Voucher.journals)\
|
||||
.filter(Voucher.date <= date)\
|
||||
.filter(Journal.cost_center_id == CostCenter.cost_center_purchase())\
|
||||
.group_by(Product)\
|
||||
.order_by(amount_sum.desc()).all()
|
||||
|
||||
body = []
|
||||
for product, quantity, amount in query:
|
||||
if quantity != 0 and amount != 0:
|
||||
body.append({'Product': product.full_name, 'Group': product.product_group.name,
|
||||
'Quantity': "{0:,.2f}".format(quantity), 'Amount': "\u20B9 {0:,.2f}".format(amount)})
|
||||
return body
|
||||
|
||||
|
||||
#def build_report(start_date, finish_date):
|
||||
# start_date = datetime.datetime.strptime(start_date, '%d-%b-%Y')
|
||||
# finish_date = datetime.datetime.strptime(finish_date, '%d-%b-%Y')
|
||||
# opening_query = DBSession.query(Ledger, literal('O', Unicode(1)).label('Type'), func.sum(Journal.amount * Journal.debit).label('Opening'), literal(0, Numeric).label('Closing'))\
|
||||
# .join(Journal.voucher).join(Journal.ledger)\
|
||||
# .filter(Voucher.date < start_date)\
|
||||
# .filter(Voucher.type != VoucherType.by_name('Issue').id)\
|
||||
# .group_by(Ledger)
|
||||
#
|
||||
# closing_query = DBSession.query(Ledger, literal('C', Unicode(1)).label('Type'), literal(0, Numeric).label('Opening'), func.sum(Journal.amount * Journal.debit).label('Closing'))\
|
||||
# .join(Journal.voucher).join(Journal.ledger)\
|
||||
# .filter(Voucher.date <= finish_date)\
|
||||
# .filter(Voucher.type != VoucherType.by_name('Issue').id)\
|
||||
# .group_by(Ledger)
|
||||
#
|
||||
# query = opening_query.union(closing_query)\
|
||||
# .order_by(Ledger.type)\
|
||||
# .order_by(Ledger.name)\
|
||||
# .all()
|
||||
# report = dict()
|
||||
# body = []
|
||||
# for ledger, entry_type, opening, closing in query:
|
||||
# if ledger.id in report:
|
||||
# if entry_type == 'O' and opening != 0:
|
||||
# report[ledger.id]['Opening'] = opening
|
||||
# elif entry_type == 'C' and closing != 0:
|
||||
# report[ledger.id]['Closing'] = closing
|
||||
# else:
|
||||
# if opening != 0 or closing != 0:
|
||||
# report[ledger.id] = { 'Ledger': ledger, 'Opening':opening, 'Closing':closing }
|
||||
#
|
||||
## report = sorted(list(report.values()), key=lambda sorter: sorter['Ledger'].type)
|
||||
# for item in report:
|
||||
# ledger = item['Ledger']
|
||||
# ledger_type = LedgerType.by_id(ledger.type)
|
||||
# if item['Opening'] >= 0:
|
||||
# opening = "\u20B9 {0:,.2f} Dr".format(item['Opening'])
|
||||
# else:
|
||||
# opening = "\u20B9 {0:,.2f} Cr".format(item['Opening'] * -1)
|
||||
# if item['Closing'] >= 0:
|
||||
# closing = "\u20B9 {0:,.2f} Dr".format(item['Closing'])
|
||||
# else:
|
||||
# closing = "\u20B9 {0:,.2f} Cr".format(item['Closing'] * -1)
|
||||
# body.append({'Type':ledger_type.name, 'Name':ledger.name, 'Opening':opening, 'Closing': closing})
|
||||
#
|
||||
# return body
|
||||
#
|
||||
#
|
||||
114
brewman/brewman/views/reports/raw_material_cost.py
Normal file
114
brewman/brewman/views/reports/raw_material_cost.py
Normal file
@ -0,0 +1,114 @@
|
||||
import datetime
|
||||
import uuid
|
||||
from sqlalchemy.sql.expression import func, case
|
||||
|
||||
from pyramid.view import view_config
|
||||
from brewman.models import DBSession
|
||||
|
||||
from brewman.models.master import LedgerBase, CostCenter, Product, ProductGroup
|
||||
|
||||
from brewman.models.voucher import Voucher, Journal, Inventory
|
||||
from brewman.views.services.session import services_session_period_start, services_session_period_finish
|
||||
|
||||
@view_config(request_method='GET', route_name='raw_material_cost', renderer='brewman:templates/angular_base.mako',
|
||||
xhr=False)
|
||||
@view_config(request_method='GET', route_name='raw_material_cost_id', renderer='brewman:templates/angular_base.mako',
|
||||
xhr=False)
|
||||
def get_html(request):
|
||||
return {}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='raw_material_cost', renderer='json', xhr=True)
|
||||
def report_blank(request):
|
||||
return {'StartDate': services_session_period_start(request),
|
||||
'FinishDate': services_session_period_finish(request), 'Body': [], 'Footer': {}}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='raw_material_cost', request_param='StartDate', renderer='json', xhr=True)
|
||||
def report_data(request):
|
||||
start_date = request.GET.get('StartDate', None)
|
||||
finish_date = request.GET.get('FinishDate', None)
|
||||
return build_report(request, start_date, finish_date)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='raw_material_cost_id', request_param='StartDate', renderer='json',
|
||||
xhr=True)
|
||||
def report_id(request):
|
||||
id = request.matchdict.get('id', None)
|
||||
start_date = request.GET.get('StartDate', None)
|
||||
finish_date = request.GET.get('FinishDate', None)
|
||||
return build_report_id(request, uuid.UUID(id), start_date, finish_date)
|
||||
|
||||
|
||||
def build_report(request, start_date, finish_date):
|
||||
report = {'StartDate': start_date, 'FinishDate': finish_date, 'Body': [], 'Footer': []}
|
||||
|
||||
sum_issue = func.sum(case([(LedgerBase.type == 2, Journal.signed_amount)], else_=0)).label('Issue')
|
||||
sum_sale = (func.sum(case([(LedgerBase.type == 3, Journal.signed_amount)], else_=0)) * -1).label('Sale')
|
||||
|
||||
query = DBSession.query(CostCenter, sum_issue, sum_sale)\
|
||||
.join(CostCenter.journals).join(Journal.voucher).join(Journal.ledger)\
|
||||
.filter(Voucher.date >= datetime.datetime.strptime(start_date, '%d-%b-%Y'))\
|
||||
.filter(Voucher.date <= datetime.datetime.strptime(finish_date, '%d-%b-%Y'))\
|
||||
.filter(Journal.cost_center_id != CostCenter.cost_center_purchase())\
|
||||
.filter(LedgerBase.type.in_([2, 3]))\
|
||||
.group_by(CostCenter)\
|
||||
.order_by(sum_sale.desc()).all()
|
||||
|
||||
issues = 0
|
||||
sales = 0
|
||||
for cost_center, issue, sale in query:
|
||||
issues += issue
|
||||
sales += sale
|
||||
rmc = 0 if sale == 0 else issue / sale
|
||||
report['Body'].append(
|
||||
{'Name': cost_center.name, 'Url': request.route_url('raw_material_cost_id', id=str(cost_center.id),
|
||||
_query={'StartDate': start_date, 'FinishDate': finish_date}), 'Issue': "\u20B9 {0:.2f}".format(issue),
|
||||
'Sale': "\u20B9 {0:.2f}".format(sale), 'Rmc': "\u20B9 {0:.2%}".format(rmc)})
|
||||
|
||||
rmc = 0 if sales == 0 else issues / sales
|
||||
report['Footer'].append({'Name': 'Total', 'Issue': "\u20B9 {0:.2f}".format(issues),
|
||||
'Sale': "\u20B9 {0:.2f}".format(sales), 'Rmc': "\u20B9 {0:.2%}".format(rmc)})
|
||||
|
||||
return report
|
||||
|
||||
|
||||
def build_report_id(request, cost_center_id, start_date, finish_date):
|
||||
report = {'StartDate': start_date, 'FinishDate': finish_date, 'Body': []}
|
||||
|
||||
sum_quantity = func.sum(Inventory.quantity * Journal.debit).label('Quantity')
|
||||
sum_net = func.sum(Inventory.rate * Inventory.quantity * Journal.debit).label('Net')
|
||||
sum_gross = func.sum(Inventory.amount * Journal.debit).label('Gross')
|
||||
|
||||
query = DBSession.query(Product, sum_quantity, sum_net, sum_gross)\
|
||||
.join(Product.inventories).join(Inventory.voucher).join(Voucher.journals).join(Product.product_group)\
|
||||
.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 == 3)\
|
||||
.filter(Journal.cost_center_id == cost_center_id)\
|
||||
.group_by(Product).group_by(Journal.debit).group_by(ProductGroup.name)\
|
||||
.order_by(ProductGroup.name).order_by(sum_net.desc()).all()
|
||||
|
||||
|
||||
groups = {}
|
||||
counter = 0
|
||||
list = []
|
||||
for product, quantity, net, gross in query:
|
||||
if product.product_group_id in groups:
|
||||
group = groups[product.product_group_id]
|
||||
group['Net'] += net
|
||||
group['Gross'] += gross
|
||||
else:
|
||||
counter += 500
|
||||
group = {'Group': product.product_group.name, 'Net':net,'Gross':gross, 'Order':counter, 'Heading': True}
|
||||
groups[product.product_group_id] = group
|
||||
counter += 1
|
||||
list.append({'Name': product.full_name, 'Group': product.product_group.name, 'Quantity': "{0:.2f}".format(quantity), 'Net': "\u20B9 {0:,.2f}".format(net), 'Gross': "\u20B9 {0:,.2f}".format(gross), 'Order': counter, 'Heading': False})
|
||||
|
||||
for item in groups.values():
|
||||
item['Net'] = "\u20B9 {0:,.2f}".format(item['Net'])
|
||||
item['Gross'] = "\u20B9 {0:,.2f}".format(item['Gross'])
|
||||
list.append(item)
|
||||
|
||||
report['Body'] = sorted(list, key=lambda d: d['Order'])
|
||||
return report
|
||||
@ -16,16 +16,16 @@ from brewman.views.services.session import services_session_period_finish
|
||||
def ledger_display_get(request):
|
||||
return {}
|
||||
|
||||
@view_config(request_method='GET', route_name='trial_balance_date', renderer='json', xhr=True)
|
||||
@view_config(request_method='GET', route_name='trial_balance', renderer='json', xhr=True)
|
||||
def trial_balance(request):
|
||||
date = request.matchdict.get('date', None)
|
||||
if date:
|
||||
return {'Date': date, 'Body': build_report(date)}
|
||||
else:
|
||||
return {'Date': services_session_period_finish(request), 'Body': []}
|
||||
def report_blank(request):
|
||||
return {'Date': services_session_period_finish(request), 'Body': []}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='trial_balance_date', renderer='json', xhr=True)
|
||||
def report_data(request):
|
||||
date = request.matchdict.get('date', None)
|
||||
return {'Date': date, 'Body': build_report(date)}
|
||||
|
||||
|
||||
def build_report(date):
|
||||
date = datetime.datetime.strptime(date, '%d-%b-%Y')
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from datetime import date, timedelta
|
||||
import json
|
||||
from pyramid.security import authenticated_userid
|
||||
|
||||
from pyramid.view import view_config
|
||||
from brewman.models.auth import Role
|
||||
@ -48,12 +49,11 @@ def is_user_in_roles(request):
|
||||
|
||||
@view_config(route_name='user_permissions', renderer='json', xhr=True)
|
||||
def user_permission(request):
|
||||
session_perms = request.session['perms']
|
||||
user_id = authenticated_userid(request)
|
||||
session_perms = request.session['perms'] if user_id else []
|
||||
perms = {}
|
||||
|
||||
for item in Role.list():
|
||||
perms[item.name] = True if item.name in session_perms else False
|
||||
|
||||
return perms
|
||||
|
||||
|
||||
|
||||
@ -16,35 +16,55 @@ from brewman.views.transactions import session_current_date
|
||||
__author__ = 'tanshu'
|
||||
|
||||
|
||||
@view_config(request_method='POST', route_name='voucher_new', renderer='json', xhr=True)
|
||||
@view_config(request_method='POST', route_name='voucher', renderer='json', xhr=True)
|
||||
@view_config(request_method='POST', route_name='voucher', request_param='post', renderer='json', xhr=True)
|
||||
def voucher_post(request):
|
||||
user = User.get_by_id(uuid.UUID(authenticated_userid(request)))
|
||||
try:
|
||||
voucher = Voucher.by_id(uuid.UUID(id))
|
||||
voucher.posted = True
|
||||
voucher.poster_id = user.id
|
||||
transaction.commit()
|
||||
return voucher_info(Voucher.by_id(voucher.id))
|
||||
except ValidationError as ex:
|
||||
transaction.abort()
|
||||
response = Response("Failed validation: {0}".format(ex.message))
|
||||
response.status_int = 500
|
||||
return response
|
||||
|
||||
|
||||
@view_config(request_method='POST', route_name='voucher', renderer='json', xhr=True)
|
||||
def voucher_save(request):
|
||||
id = request.matchdict.get('id', None)
|
||||
is_post = request.GET.get('post', None)
|
||||
user = User.get_by_id(uuid.UUID(authenticated_userid(request)))
|
||||
|
||||
try:
|
||||
if id and is_post:
|
||||
voucher = Voucher.by_id(uuid.UUID(id))
|
||||
voucher.posted = True
|
||||
voucher.poster_id = user.id
|
||||
elif id:
|
||||
""" update voucher """
|
||||
id = uuid.UUID(id)
|
||||
if request.json_body['Type'] in ['Journal', 'Payment', 'Receipt']:
|
||||
voucher = journal_update_voucher(id, request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Purchase']:
|
||||
voucher = purchase_update_voucher(id, request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Issue']:
|
||||
voucher = issue_update_voucher(id, request.json_body, user)
|
||||
else:
|
||||
""" new voucher """
|
||||
if request.json_body['Type'] in ['Journal', 'Payment', 'Receipt']:
|
||||
voucher = journal_create_voucher(request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Purchase']:
|
||||
voucher = purchase_create_voucher(request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Issue']:
|
||||
voucher = issue_create_voucher(request.json_body, user)
|
||||
""" update voucher """
|
||||
id = uuid.UUID(id)
|
||||
if request.json_body['Type'] in ['Journal', 'Payment', 'Receipt']:
|
||||
voucher = journal_update_voucher(id, request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Purchase']:
|
||||
voucher = purchase_update_voucher(id, request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Issue']:
|
||||
voucher = issue_update_voucher(id, request.json_body, user)
|
||||
transaction.commit()
|
||||
return voucher_info(Voucher.by_id(voucher.id))
|
||||
except ValidationError as ex:
|
||||
transaction.abort()
|
||||
response = Response("Failed validation: {0}".format(ex.message))
|
||||
response.status_int = 500
|
||||
return response
|
||||
|
||||
@view_config(request_method='POST', route_name='voucher_new', renderer='json', xhr=True)
|
||||
def voucher_save(request):
|
||||
user = User.get_by_id(uuid.UUID(authenticated_userid(request)))
|
||||
try:
|
||||
""" new voucher """
|
||||
if request.json_body['Type'] in ['Journal', 'Payment', 'Receipt']:
|
||||
voucher = journal_create_voucher(request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Purchase']:
|
||||
voucher = purchase_create_voucher(request.json_body, user)
|
||||
elif request.json_body['Type'] in ['Issue']:
|
||||
voucher = issue_create_voucher(request.json_body, user)
|
||||
transaction.commit()
|
||||
return voucher_info(Voucher.by_id(voucher.id))
|
||||
except ValidationError as ex:
|
||||
@ -56,58 +76,65 @@ def voucher_post(request):
|
||||
@view_config(request_method='DELETE', route_name='voucher', renderer='json', xhr=True)
|
||||
def delete(request):
|
||||
id = request.matchdict.get('id', None)
|
||||
if id is None:
|
||||
response = Response("Voucher is Null")
|
||||
response.status_int = 500
|
||||
return response
|
||||
else:
|
||||
voucher = Voucher.by_id(uuid.UUID(id))
|
||||
json_voucher = voucher_info(voucher)
|
||||
if voucher.type == 'Issue':
|
||||
for item in voucher.journals:
|
||||
if item.debit == 1:
|
||||
destination = item.cost_center_id
|
||||
else:
|
||||
source = item.cost_center_id
|
||||
batch_consumed = True if source == CostCenter.cost_center_purchase() else False if destination == CostCenter.cost_center_purchase() else None
|
||||
if batch_consumed is None:
|
||||
pass
|
||||
elif batch_consumed:
|
||||
for item in voucher.inventories:
|
||||
item.batch.quantity_remaining += item.quantity
|
||||
voucher = Voucher.by_id(uuid.UUID(id))
|
||||
json_voucher = voucher_info(voucher)
|
||||
if voucher.type == 'Issue':
|
||||
for item in voucher.journals:
|
||||
if item.debit == 1:
|
||||
destination = item.cost_center_id
|
||||
else:
|
||||
for item in voucher.inventories:
|
||||
if item.batch.quantity_remaining < item.batch.quantity_remaining:
|
||||
raise ValueError(
|
||||
'Quantity remaining for {0} is less than issued, hence cannot be deleted'.format(
|
||||
item.product.name))
|
||||
item.batch.quantity_remaining -= item.quantity
|
||||
elif voucher.type == 'Purchase':
|
||||
source = item.cost_center_id
|
||||
batch_consumed = True if source == CostCenter.cost_center_purchase() else False if destination == CostCenter.cost_center_purchase() else None
|
||||
if batch_consumed is None:
|
||||
pass
|
||||
elif batch_consumed:
|
||||
for item in voucher.inventories:
|
||||
item.batch.quantity_remaining += item.quantity
|
||||
else:
|
||||
for item in voucher.inventories:
|
||||
if item.batch.quantity_remaining < item.batch.quantity_remaining:
|
||||
raise ValueError('Quantity remaining for {0} is less than issued, hence cannot be deleted'.format(
|
||||
item.product.name))
|
||||
raise ValueError(
|
||||
'Quantity remaining for {0} is less than issued, hence cannot be deleted'.format(
|
||||
item.product.name))
|
||||
item.batch.quantity_remaining -= item.quantity
|
||||
elif voucher.type == 'Purchase Return':
|
||||
pass
|
||||
DBSession.delete(voucher)
|
||||
transaction.commit()
|
||||
return blank_voucher(additionalInfo=json_voucher)
|
||||
elif voucher.type == 'Purchase':
|
||||
for item in voucher.inventories:
|
||||
if item.batch.quantity_remaining < item.batch.quantity_remaining:
|
||||
raise ValueError('Quantity remaining for {0} is less than issued, hence cannot be deleted'.format(
|
||||
item.product.name))
|
||||
item.batch.quantity_remaining -= item.quantity
|
||||
elif voucher.type == 'Purchase Return':
|
||||
pass
|
||||
DBSession.delete(voucher)
|
||||
transaction.commit()
|
||||
return blank_voucher(additionalInfo=json_voucher)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='voucher_new', renderer='json', xhr=True)
|
||||
@view_config(request_method='GET', route_name='voucher', renderer='json', xhr=True)
|
||||
def get(request):
|
||||
id = request.matchdict.get('id', None)
|
||||
@view_config(request_method='GET', route_name='voucher_new', request_param='type', renderer='json', xhr=True)
|
||||
def get_blank(request):
|
||||
voucher_type = request.GET.get('type', None)
|
||||
if id:
|
||||
return voucher_info(Voucher.by_id(uuid.UUID(id)))
|
||||
elif voucher_type:
|
||||
return blank_voucher(type=voucher_type, date=session_current_date(request))
|
||||
else:
|
||||
response = Response("Voucher ID and Type, both are Null")
|
||||
response.status_int = 500
|
||||
return response
|
||||
return blank_voucher(type=voucher_type, date=session_current_date(request))
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='voucher', renderer='json', xhr=True)
|
||||
def get_old(request):
|
||||
id = request.matchdict.get('id', None)
|
||||
return voucher_info(Voucher.by_id(uuid.UUID(id)))
|
||||
|
||||
|
||||
#@view_config(request_method='GET', route_name='voucher_new', renderer='json', xhr=True)
|
||||
#@view_config(request_method='GET', route_name='voucher', renderer='json', xhr=True)
|
||||
#def get_old(request):
|
||||
# id = request.matchdict.get('id', None)
|
||||
# voucher_type = request.GET.get('type', None)
|
||||
# if id:
|
||||
# return voucher_info(Voucher.by_id(uuid.UUID(id)))
|
||||
# elif voucher_type:
|
||||
# return blank_voucher(type=voucher_type, date=session_current_date(request))
|
||||
# else:
|
||||
# response = Response("Voucher ID and Type, both are Null")
|
||||
# response.status_int = 500
|
||||
# return response
|
||||
|
||||
|
||||
def voucher_info(voucher):
|
||||
|
||||
Reference in New Issue
Block a user