Purchase working

Issue sort of working, have to set the location for date and costcenters, but otherwise working mostly
updated product service to confirm with new db structure
This commit is contained in:
Tanshu
2012-10-14 04:36:34 +05:30
parent 89600d2cab
commit 9efcefe31e
17 changed files with 311 additions and 405 deletions

View File

@ -137,15 +137,11 @@ def main(global_config, **settings):
config.add_route('services_products', '/Services/Products')
config.add_route('services_product_rate', '/Services/ProductRate')
config.add_route('services_product_add_inventory', '/Services/AddInventory')
config.add_route('services_batch_list', '/Services/Batches')
config.add_route('user_permissions', '/Permissions')
config.add_route('account_type_list', '/AccountTypes')
config.add_route('services_batch_list', '/Services/Batches')
config.add_route('services_batch_add_inventory', '/Services/AddBatch')
config.add_route('services_user_list', '/Services/Users')
config.add_route('voucher', '/Voucher/{id}')
config.add_route('voucher_new', '/Voucher')

View File

@ -0,0 +1,139 @@
<h2 class="ribbon-header">Issue Edit / New</h2>
<form method="post" autocomplete="off" class="form-horizontal" ng-controller="IssueCtrl">
<div class="control-group">
<label for="gvSmall" class="control-label"></label>
<div class="controls">
<table id="gvSmall" class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>Code</th>
<th>Amount</th>
<th>Load</th>
</tr>
</thead>
<tr ng-repeat="item in smallGrid">
<td>{{item.Code}}</td>
<td>{{item.Amount}}</td>
<td>
<button ng-click="get(item.VoucherID)">Load</button>
</td>
</tr>
</table>
</div>
</div>
<div class="control-group">
<label for="txtCode" class="control-label">Code</label>
<div class="controls">
<input type="text" id="txtCode" class="non-search-box" disabled="disabled" ng-model="voucher.Code"/>
</div>
</div>
<div class="control-group">
<label for="txtDate" class="control-label">Date</label>
<div class="controls">
<datepicker id="txtDate" model="voucher" prop="Date" ng-model="voucher.Date"></datepicker>
</div>
</div>
<div class="control-group">
<div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:-1">
<label for="ddlSourceCostCenter" class="control-label">From</label>
<div class="controls">
<select id="ddlSourceCostCenter" class="select-box" ng-model="journal.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
</div>
</div>
</div>
<div class="control-group">
<div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:1">
<label for="ddlSourceCostCenter" class="control-label">From</label>
<div class="controls">
<select id="ddlDestinationCostCenter" class="select-box" ng-model="journal.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
<div class=" input-prepend">
<span class="add-on"></span>
<input type="text" id="txtAmount" class="span2" autocomplete="off"
placeholder="Amount" ng-model="journal.Amount"/>
</div>
</div>
</div>
</div>
<div class=" control-group" id="add">
<label for="txtBatch" class="control-label">Add</label>
<div class="controls">
<autobatch id="txtBatch" url="/Services/Batches" selname="name"
batch="batch" ng-model="name"></autobatch>
<input type="text" id="txtQuantity" class="span2" autocomplete="off"
placeholder="Quantity" ng-model="quantity"/>
<button class="btn btn-success" ng-click="addInventory()">Add <i class="icon-plus-sign icon-white"></i>
</button>
</div>
</div>
<div class="control-group">
<label for="gvGrid" class="control-label"></label>
<div class="controls">
<table id="gvGrid" class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Rate</th>
<th>Amount</th>
<th>Delete</th>
</tr>
</thead>
<tbody id="tbodyMain">
<tr ng-repeat="inventory in voucher.Inventories">
<th>{{inventory.Product.Name + ' (' + inventory.Product.Units + ')'}}</th>
<th>{{inventory.Quantity}}</th>
<th>{{inventory.Rate}}</th>
<th>{{inventory.Amount}}</th>
<td>
<button ng-click="removeInventory(inventory)">Delete</button>
</td>
</tr>
</tbody>
<tfoot id="tfootMain">
</tfoot>
</table>
</div>
</div>
<div class="control-group">
<label for="txtNarration" class="control-label">Narration</label>
<div class="controls">
<textarea rows="2" cols="20" id="txtNarration"
class="non-search-box" ng-model="voucher.Narration"></textarea>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code != '(Auto)'"
ng-disabled="!perms['Issue Create']">Save
</button>
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Issue Update']">
Update
</button>
<button class="btn btn-danger" ng-click="resetVoucher(voucher.VoucherID)" ng-hide="voucher.Code == '(Auto)'">
New Entry
</button>
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Issue Delete']">
Delete
</button>
</div>
<div class="row-fluid">
Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. Posted
by {{voucher.Poster}}
</div>
</form>

View File

@ -0,0 +1,116 @@
<h2 class="ribbon-header">Purchase Edit / New</h2>
<form method="post" autocomplete="off" class="form-horizontal" ng-controller="PurchaseCtrl">
<div class="control-group">
<label for="txtCode" class="control-label">Code</label>
<div class="controls">
<input type="text" id="txtCode" class="non-search-box" disabled="disabled" ng-model="voucher.Code"/>
</div>
</div>
<div class="control-group">
<label for="txtDate" class="control-label">Date</label>
<div class="controls">
<datepicker id="txtDate" model="voucher" prop="Date" ng-model="voucher.Date"></datepicker>
</div>
</div>
<div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:-1">
<label for="txtLedger" class="control-label">Ledger</label>
<div class="controls">
<autocomplete id="txtLedger" url="/Services/Accounts"
selname="journal.Ledger.Name" selid="journal.Ledger.LedgerID"></autocomplete>
<div class="input-prepend">
<span class="add-on"></span><input type="text" id="txtLedgerAmount" class="span2"
autocomplete="off" readonly="readonly"
placeholder="Amount" ng-model="journal.Amount"/>
</div>
</div>
</div>
<div class="control-group" id="add">
<label for="txtProduct" class="control-label">Product</label>
<div class="controls">
<autocomplete id="txtProduct" class="search-box" url="/Services/ProductsList"
selname="name" selid="id" selprice="rate"></autocomplete>
<input type="text" id="txtQuantity" autocomplete="off" class="non-search-box inline"
placeholder="Quantity" ng-model="quantity"/>
<input type="text" id="txtRate" autocomplete="off" class="non-search-box inline"
placeholder="Rate" ng-model="rate"/>
<input type="text" id="txtTax" autocomplete="off" class="non-search-box inline"
placeholder="Tax" ng-model="tax"/>
<input type="text" id="txtDiscount" autocomplete="off" class="non-search-box inline"
placeholder="Discount" ng-model="discount"/>
<button class="btn btn-success" ng-click="addInventory()">Add <i class="icon-plus-sign icon-white"></i>
</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>Quantity</th>
<th>Rate</th>
<th>Tax</th>
<th>Discount</th>
<th>Amount</th>
<th>Delete</th>
</tr>
</thead>
<tbody id="tbodyMain">
<tr ng-repeat="inventory in voucher.Inventories">
<td>{{inventory.Product.Name}}</td>
<td>{{inventory.Quantity}}</td>
<td>{{inventory.Rate}}</td>
<td>{{inventory.Tax}}</td>
<td>{{inventory.Discount}}</td>
<td>{{inventory.Amount}}</td>
<td>
<button ng-click="removeInventory(inventory)">Delete</button>
</td>
</tr>
</tbody>
<tfoot id="tfootMain">
</tfoot>
</table>
</div>
</div>
<div class="control-group">
<label for="txtNarration" class="control-label">Narration</label>
<div class="controls">
<textarea rows="2" cols="20" id="txtNarration"
class="non-search-box" ng-model="voucher.Narration"></textarea>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code != '(Auto)'"
ng-disabled="!perms['Purchase Create']">Save
</button>
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Purchase Update'] || (voucher.Posted && !perms['EditPosted'])">
Update
</button>
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="voucher.Posted || !perms['PostTransactions']">{{voucher.Posted |
posted}}
</button>
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Purchase Delete'] || (voucher.Posted && !perms['EditPosted'])">
Delete
</button>
</div>
<div class="row-fluid">
Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}.
Posted
by {{voucher.Poster}}
</div>
</form>

View File

@ -10,6 +10,12 @@
when('/Receipt', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}).
when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}).
when('/Purchase', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl}).
when('/Purchase/:id', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl}).
when('/Issue', {templateUrl: '/partial/issue.html', controller: IssueCtrl}).
when('/Issue/:id', {templateUrl: '/partial/issue.html', controller: IssueCtrl}).
when('/Ledger', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}).
when('/Ledger/:id', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}).

View File

@ -1,6 +1,10 @@
function IssueCtrl($scope, Voucher, issue_grid) {
$scope.voucher = new Voucher(voucher);
$scope.cost_centers = cost_centers;
function IssueCtrl($scope, $routeParams, $location, Voucher, CostCenter, issue_grid) {
if (typeof $routeParams.id === 'undefined') {
$scope.voucher = Voucher.get({type:'Issue'});
} else {
$scope.voucher = Voucher.get({id:$routeParams.id});
}
$scope.cost_centers = CostCenter.query();
$scope.addInventory = function () {
for (var i = 0, l = this.voucher.Inventories.length; i < l; i++) {
@ -102,14 +106,16 @@
}, true);
$scope.resetVoucher = function (voucherid) {
$scope.voucher = Voucher.get({id:voucherid, type:'Issue'}, function () {
$scope.voucher = Voucher.get({id:voucherid, type:'Issue'}, function (u, putResponseHeaders) {
$location.path('/Issue')
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
});
};
$scope.get = function (voucherid) {
$scope.voucher = Voucher.get({id:voucherid}, function () {
$scope.voucher = Voucher.get({id:voucherid}, function (u, putResponseHeaders) {
$location.path('/Issue/' + u.VoucherID)
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
});
@ -117,6 +123,7 @@
$scope.save = function () {
$scope.voucher.$save(function (u, putResponseHeaders) {
$location.path('/Issue/' + u.VoucherID)
$scope.toasts.push({Type:'Success', Message:u.Code});
$scope.updateGrid();
}, function (data, status) {
@ -126,6 +133,7 @@
$scope.delete = function () {
$scope.voucher.$delete(function (u, putResponseHeaders) {
$location.path('/Issue')
$scope.toasts.push({Type:'Success', Message:''});
$scope.updateGrid();
}, function (data, status) {

View File

@ -1,5 +1,9 @@
function PurchaseCtrl($scope, Voucher) {
$scope.voucher = new Voucher(voucher);
function PurchaseCtrl($scope, $routeParams, $location, Voucher) {
if (typeof $routeParams.id === 'undefined') {
$scope.voucher = Voucher.get({type:'Purchase'});
} else {
$scope.voucher = Voucher.get({id:$routeParams.id});
}
$scope.rate = 0;
$scope.addInventory = function () {
@ -43,13 +47,17 @@
$scope.$watch('voucher.Inventories', function (inventories, oldValue) {
var amount = 0;
for (var i = 0, l = inventories.length; i < l; i++) {
amount += Number(inventories[i].Amount);
if (typeof inventories !== 'undefined') {
for (var i = 0, l = inventories.length; i < l; i++) {
amount += Number(inventories[i].Amount);
}
}
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
if ($scope.voucher.Journals[i].Debit === -1) {
$scope.voucher.Journals[i].Amount = amount;
break;
if (typeof $scope.voucher.Journals !== 'undefined') {
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
if ($scope.voucher.Journals[i].Debit === -1) {
$scope.voucher.Journals[i].Amount = amount;
break;
}
}
}
}, true);
@ -65,6 +73,7 @@
$scope.save = function () {
$scope.voucher.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type:'Success', Message:u.Code});
$location.path('/Purchase/' + u.VoucherID)
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
});
@ -73,6 +82,7 @@
$scope.delete = function () {
$scope.voucher.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type:'Success', Message:''});
$location.path('/Purchase')
}, function (data, status) {
$scope.toasts.push({Type:'Error', Message:data.data});
});

View File

@ -40,6 +40,8 @@
${h.ScriptLink(request, 'journal.js')}
${h.ScriptLink(request, 'payment.js')}
${h.ScriptLink(request, 'receipt.js')}
${h.ScriptLink(request, 'purchase.js')}
${h.ScriptLink(request, 'issue.js')}
${h.ScriptLink(request, 'ledger.js')}
${h.ScriptLink(request, 'trial_balance.js')}

View File

@ -39,6 +39,8 @@
${h.ScriptLink(request, 'journal.js')}
${h.ScriptLink(request, 'payment.js')}
${h.ScriptLink(request, 'receipt.js')}
${h.ScriptLink(request, 'purchase.js')}
${h.ScriptLink(request, 'issue.js')}
${h.ScriptLink(request, 'ledger.js')}
${h.ScriptLink(request, 'trial_balance.js')}

View File

@ -1,157 +0,0 @@
# -*- coding: utf-8 -*-
<%inherit file="../base.mako"/>
<%block name="header">
${h.ScriptLink(request, 'issue.js')}
<script type="text/javascript">
const perms = ${perms};
const voucher = ${json_voucher};
const cost_centers = ${cost_centers};
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#txtBatch").focus();
});
</script>
</%block>
<%block name="content">
<h2 class="ribbon-header">Issue Edit / New</h2>
<form method="post" autocomplete="off" class="form-horizontal" ng-controller="IssueCtrl">
<div class="control-group">
<label for="gvSmall" class="control-label"></label>
<div class="controls">
<table id="gvSmall" class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>Code</th>
<th>Amount</th>
<th>Load</th>
</tr>
</thead>
<tr ng-repeat="item in smallGrid">
<td>{{item.Code}}</td>
<td>{{item.Amount}}</td>
<td>
<button ng-click="get(item.VoucherID)">Load</button>
</td>
</tr>
</table>
</div>
</div>
${h.CsrfToken(request.session)}
<div class="control-group">
<label for="txtCode" class="control-label">Code</label>
<div class="controls">
<input type="text" id="txtCode" class="non-search-box" disabled="disabled" ng-model="voucher.Code"/>
</div>
</div>
<div class="control-group">
<label for="txtDate" class="control-label">Date</label>
<div class="controls">
<datepicker id="txtDate" model="voucher" prop="Date" ng-model="voucher.Date"></datepicker>
</div>
</div>
<div class="control-group">
<div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:-1">
<label for="ddlSourceCostCenter" class="control-label">From</label>
<div class="controls">
<select id="ddlSourceCostCenter" class="select-box" ng-model="journal.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
</div>
</div>
</div>
<div class="control-group">
<div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:1">
<label for="ddlSourceCostCenter" class="control-label">From</label>
<div class="controls">
<select id="ddlDestinationCostCenter" class="select-box" ng-model="journal.CostCenter.CostCenterID"
ng-options="l.CostCenterID as l.Name for l in cost_centers"> </select>
<div class=" input-prepend">
<span class="add-on">₹</span>
<input type="text" id="txtAmount" class="span2" autocomplete="off"
placeholder="Amount" ng-model="journal.Amount"/>
</div>
</div>
</div>
</div>
<div class=" control-group" id="add">
<label for="txtBatch" class="control-label">Add</label>
<div class="controls">
<autobatch id="txtBatch" url="${request.route_url('services_batch_list')}" selname="name"
batch="batch" ng-model="name"></autobatch>
<input type="text" id="txtQuantity" class="span2" autocomplete="off"
placeholder="Quantity" ng-model="quantity"/>
<button class="btn btn-success" ng-click="addInventory()">Add <i class="icon-plus-sign icon-white"></i>
</button>
</div>
</div>
<div class="control-group">
<label for="gvGrid" class="control-label"></label>
<div class="controls">
<table id="gvGrid" class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Rate</th>
<th>Amount</th>
<th>Delete</th>
</tr>
</thead>
<tbody id="tbodyMain">
<tr ng-repeat="inventory in voucher.Inventories">
<th>{{inventory.Product.Name + ' (' + inventory.Product.Units + ')'}}</th>
<th>{{inventory.Quantity}}</th>
<th>{{inventory.Rate}}</th>
<th>{{inventory.Amount}}</th>
<td>
<button ng-click="removeInventory(inventory)">Delete</button>
</td>
</tr>
</tbody>
<tfoot id="tfootMain">
</tfoot>
</table>
</div>
</div>
<div class="control-group">
<label for="txtNarration" class="control-label">Narration</label>
<div class="controls">
<textarea rows="2" cols="20" id="txtNarration"
class="non-search-box" ng-model="voucher.Narration"></textarea>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code != '(Auto)'"
ng-disabled="!perms['Issue Create']">Save
</button>
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Issue Update']">
Update
</button>
<button class="btn btn-danger" ng-click="resetVoucher(voucher.VoucherID)" ng-hide="voucher.Code == '(Auto)'">
New Entry
</button>
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Issue Delete']">
Delete
</button>
</div>
<div class="row-fluid">
Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}. Posted
by {{voucher.Poster}}
</div>
</form>
</%block>

View File

@ -1,10 +0,0 @@
<tr tal:repeat="item list" class="Inventory">
<td class="InventoryID hide">${item.inventory_id}</td>
<td class="ProductID hide">${item.product_id}</td>
<td class="Product">${item.name}</td>
<td class="Quantity">${item.quantity}</td>
<td class="Rate">${item.rate}</td>
<td class="Amount">${item.amount}</td>
<td class="BatchID hide">${item.batch_id}</td>
<td class="Delete"><input type="submit" class="subtract" onClick="return DeleteRow('${item.product_id}');" value="Delete"/></td>
</tr>

View File

@ -1,131 +0,0 @@
# -*- coding: utf-8 -*-
<%inherit file="../base.mako"/>
<%block name="header">
${h.ScriptLink(request, 'purchase.js')}
<script type="text/javascript">
const perms = ${perms};
const voucher = ${json_voucher};
</script>
<script type="text/javascript">
$(document).ready(function () {
$('#txtLedger').focus();
});
</script>
</%block>
<%block name="content">
<h2 class="ribbon-header">Purchase Edit / New</h2>
<form method="post" autocomplete="off" class="form-horizontal" ng-controller="PurchaseCtrl">
${h.CsrfToken(request.session)}
<div class="control-group">
<label for="txtCode" class="control-label">Code</label>
<div class="controls">
<input type="text" id="txtCode" class="non-search-box" disabled="disabled" ng-model="voucher.Code"/>
</div>
</div>
<div class="control-group">
<label for="txtDate" class="control-label">Date</label>
<div class="controls">
<datepicker id="txtDate" model="voucher" prop="Date" ng-model="voucher.Date"></datepicker>
</div>
</div>
<div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:-1">
<label for="txtLedger" class="control-label">Ledger</label>
<div class="controls">
<autocomplete id="txtLedger" url="${request.route_url('services_account_list')}"
selname="journal.Ledger.Name" selid="journal.Ledger.LedgerID"></autocomplete>
<div class="input-prepend">
<span class="add-on">₹</span><input type="text" id="txtLedgerAmount" class="span2"
autocomplete="off" readonly="readonly"
placeholder="Amount" ng-model="journal.Amount"/>
</div>
</div>
</div>
<div class="control-group" id="add">
<label for="txtProduct" class="control-label">Product</label>
<div class="controls">
<autocomplete id="txtProduct" class="search-box" url="${request.route_url('services_product_list')}"
selname="name" selid="id" selprice="rate"></autocomplete>
<input type="text" id="txtQuantity" autocomplete="off" class="non-search-box inline"
placeholder="Quantity" ng-model="quantity"/>
<input type="text" id="txtRate" autocomplete="off" class="non-search-box inline"
placeholder="Rate" ng-model="rate"/>
<input type="text" id="txtTax" autocomplete="off" class="non-search-box inline"
placeholder="Tax" ng-model="tax"/>
<input type="text" id="txtDiscount" autocomplete="off" class="non-search-box inline"
placeholder="Discount" ng-model="discount"/>
<button class="btn btn-success" ng-click="addInventory()">Add <i class="icon-plus-sign icon-white"></i>
</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>Quantity</th>
<th>Rate</th>
<th>Tax</th>
<th>Discount</th>
<th>Amount</th>
<th>Delete</th>
</tr>
</thead>
<tbody id="tbodyMain">
<tr ng-repeat="inventory in voucher.Inventories">
<td>{{inventory.Product.Name}}</td>
<td>{{inventory.Quantity}}</td>
<td>{{inventory.Rate}}</td>
<td>{{inventory.Tax}}</td>
<td>{{inventory.Discount}}</td>
<td>{{inventory.Amount}}</td>
<td><button ng-click="removeInventory(inventory)">Delete</button></td>
</tr>
</tbody>
<tfoot id="tfootMain">
</tfoot>
</table>
</div>
</div>
<div class="control-group">
<label for="txtNarration" class="control-label">Narration</label>
<div class="controls">
<textarea rows="2" cols="20" id="txtNarration"
class="non-search-box" ng-model="voucher.Narration"></textarea>
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code != '(Auto)'"
ng-disabled="!perms['Purchase Create']">Save
</button>
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Purchase Update'] || (voucher.Posted && !perms['EditPosted'])">
Update
</button>
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="voucher.Posted || !perms['PostTransactions']">{{voucher.Posted |
posted}}
</button>
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
ng-disabled="!perms['Purchase Delete'] || (voucher.Posted && !perms['EditPosted'])">
Delete
</button>
</div>
<div class="row-fluid">
Created on {{voucher.CreationDate}} and Last Edited on {{voucher.LastEditDate}} by {{voucher.User}}.
Posted
by {{voucher.Poster}}
</div>
</form>
</%block>

View File

@ -10,7 +10,7 @@ def autocomplete_list(request):
filter = request.json_body['prefixText']
list = []
for item in Product.list(filter):
list.append({'id': item.id, 'label': item.name + ' (' + item.units + ')', 'price': item.purchase_price})
list.append({'id': item.id, 'label': item.name + ' (' + item.units + ')', 'price': item.price})
return list

View File

@ -1,17 +0,0 @@
from pyramid.view import view_config
from brewman.models.auth import User
@view_config(request_method='POST', route_name='services_user_list', renderer='json', xhr=True)
def list(request):
list = []
filter = request.json_body['prefixText']
if filter is None:
for item in User.list():
list.append({'id': str(item.id), 'Name': item.name})
else:
for item in User.filtered_list()(filter):
list.append(item.name)
return list

View File

@ -39,7 +39,7 @@ def purchase_create_journals(inventories, ledgerID):
journals = dict()
amount = 0
for item in inventories:
ledger = Product.by_id(item.product_id).purchase_ledger
ledger = Product.by_id(item.product_id).ledger
amount += item.amount
if ledger.id in journals:
journals[ledger.id].amount += item.amount

View File

@ -3,10 +3,6 @@ from pyramid.view import view_config
from brewman.helpers import Literal
@view_config(request_method='GET', route_name='receipt_id', renderer='brewman:templates/angular_base.mako',
permission='Receipt Update')
@view_config(request_method='GET', route_name='receipt', renderer='brewman:templates/angular_base.mako',
permission='Receipt Create')
@view_config(request_method='GET', route_name='journal_id', renderer='brewman:templates/angular_base.mako',
permission='Journal Update')
@view_config(request_method='GET', route_name='journal', renderer='brewman:templates/angular_base.mako',
@ -15,6 +11,18 @@ from brewman.helpers import Literal
permission='Journal Update')
@view_config(request_method='GET', route_name='payment', renderer='brewman:templates/angular_base.mako',
permission='Journal Create')
@view_config(request_method='GET', route_name='receipt_id', renderer='brewman:templates/angular_base.mako',
permission='Receipt Update')
@view_config(request_method='GET', route_name='receipt', renderer='brewman:templates/angular_base.mako',
permission='Receipt Create')
@view_config(request_method='GET', route_name='purchase_id', renderer='brewman:templates/angular_base.mako',
permission='Purchase Update')
@view_config(request_method='GET', route_name='purchase', renderer='brewman:templates/angular_base.mako',
permission='Purchase Create')
@view_config(request_method='GET', route_name='issue_id', renderer='brewman:templates/angular_base.mako',
permission='Issue Update')
@view_config(request_method='GET', route_name='issue', renderer='brewman:templates/angular_base.mako',
permission='Issue Create')
def journal_get(request):
return {}

View File

@ -1,36 +0,0 @@
import json
import uuid
from pyramid.view import view_config
from brewman.helpers import Literal
from brewman.models.master import CostCenter
from brewman.models.voucher import Voucher
from brewman.views import DecimalEncoder
from brewman.views.services.voucher import voucher_info, blank_voucher
from brewman.views.transactions import session_current_date
@view_config(request_method='GET', route_name='issue_id', renderer='brewman:templates/transaction/issue.mako',
permission='Issue Update')
@view_config(request_method='GET', route_name='issue', renderer='brewman:templates/transaction/issue.mako',
permission='Issue Create')
def issue_get(request):
id = request.matchdict.get('id', None)
perms = Literal(json.dumps(request.session['perms']))
cost_centers = []
for item in CostCenter.list():
cost_centers.append({'CostCenterID': item.id, 'Name': item.name})
cost_centers = Literal(json.dumps(cost_centers, cls=DecimalEncoder))
if id is None:
json_voucher = Literal(json.dumps(blank_voucher('Issue', session_current_date(request)), cls=DecimalEncoder))
else:
voucher = Voucher.by_id(uuid.UUID(id))
json_voucher = Literal(json.dumps(voucher_info(voucher), cls=DecimalEncoder))
return {'title': 'Hops n Grains - Issue Entry',
'id': id,
'perms': perms,
'cost_centers': cost_centers,
'json_voucher': json_voucher}

View File

@ -1,30 +0,0 @@
import json
import uuid
from pyramid.view import view_config
from brewman.helpers import Literal
from brewman.models.voucher import Voucher
from brewman.views import DecimalEncoder
from brewman.views.services.voucher import voucher_info, blank_voucher
from brewman.views.transactions import session_current_date
@view_config(request_method='GET', route_name='purchase_id', renderer='brewman:templates/transaction/purchase.mako',
permission='Purchase Update')
@view_config(request_method='GET', route_name='purchase', renderer='brewman:templates/transaction/purchase.mako',
permission='Purchase Create')
def purchase_get(request):
id = request.matchdict.get('id', None)
perms = Literal(json.dumps(request.session['perms']))
if id is None:
json_voucher = Literal(json.dumps(blank_voucher('Purchase', session_current_date(request)), cls=DecimalEncoder))
else:
voucher = Voucher.by_id(uuid.UUID(id))
json_voucher = Literal(json.dumps(voucher_info(voucher), cls=DecimalEncoder))
return {'title': 'Hops n Grains - Purchase Entry',
'id': id,
'perms': perms,
'json_voucher': json_voucher}