Receipt Done
This commit is contained in:
parent
cf0da7e309
commit
89600d2cab
99
brewman/brewman/static/partial/receipt.html
Normal file
99
brewman/brewman/static/partial/receipt.html
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<form method="post" autocomplete="off" class="form-horizontal" ng-controller="ReceiptCtrl">
|
||||||
|
<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="ddlLedger" class="control-label">From</label>
|
||||||
|
|
||||||
|
<div class="controls">
|
||||||
|
<select id="ddlLedger" class="select-box" ng-model="journal.Ledger.LedgerID"
|
||||||
|
ng-options="l.id as l.label for l in ledgers"> </select>
|
||||||
|
|
||||||
|
<div class=" input-prepend">
|
||||||
|
<span class="add-on">₹</span><input type="text" id="txtLedgerAmount" class="span2" autocomplete="off"
|
||||||
|
placeholder="Amount" ng-model="journal.Amount"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=" control-group" id="add">
|
||||||
|
<label for="txtLedger" class="control-label">Add</label>
|
||||||
|
|
||||||
|
<div class="controls">
|
||||||
|
<autocomplete id="txtLedger" url="/Services/Accounts" selname="name"
|
||||||
|
selid="id" ng-model="name"></autocomplete>
|
||||||
|
<div class=" input-prepend">
|
||||||
|
<span class="add-on">₹</span>
|
||||||
|
<input type="text" id="txtAmount" class="span2" autocomplete="off"
|
||||||
|
placeholder="Amount" ng-model="amount"/>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-success" ng-click="addJournal()">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>Name</th>
|
||||||
|
<th>Amount</th>
|
||||||
|
<th>Delete</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbodyMain">
|
||||||
|
<tr ng-repeat="journal in voucher.Journals | journalDebit:-1">
|
||||||
|
<td>{{journal.Ledger.Name}}</td>
|
||||||
|
<td>{{journal.Amount}}</td>
|
||||||
|
<td>
|
||||||
|
<button ng-click="removeJournal(journal)">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['Receipt Create']">Save
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code == '(Auto)'"
|
||||||
|
ng-disabled="!perms['Receipt 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['Receipt 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>
|
@ -7,8 +7,8 @@
|
|||||||
when('/Payment', {templateUrl: '/partial/payment.html', controller: PaymentCtrl}).
|
when('/Payment', {templateUrl: '/partial/payment.html', controller: PaymentCtrl}).
|
||||||
when('/Payment/:id', {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', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}).
|
||||||
// when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}).
|
when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl}).
|
||||||
|
|
||||||
when('/Ledger', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}).
|
when('/Ledger', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}).
|
||||||
when('/Ledger/:id', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}).
|
when('/Ledger/:id', {templateUrl: '/partial/ledger.html', controller: LedgerCtrl}).
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
function ReceiptCtrl($scope, Voucher) {
|
function ReceiptCtrl($scope, $routeParams, $location, Voucher, LedgerService) {
|
||||||
$scope.voucher = new Voucher(voucher);
|
if (typeof $routeParams.id === 'undefined') {
|
||||||
$scope.ledgers = ledgers;
|
$scope.voucher = Voucher.get({type:'Receipt'});
|
||||||
|
} else {
|
||||||
|
$scope.voucher = Voucher.get({id:$routeParams.id});
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.ledgers = LedgerService.query({type:1});
|
||||||
|
|
||||||
$scope.addJournal = function () {
|
$scope.addJournal = function () {
|
||||||
for (var i = 0, l = this.voucher.Journals.length; i < l; i++) {
|
for (var i = 0, l = this.voucher.Journals.length; i < l; i++) {
|
||||||
@ -24,6 +29,7 @@
|
|||||||
delete $scope.name;
|
delete $scope.name;
|
||||||
$('#txtLedger').focus();
|
$('#txtLedger').focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeJournal = function (journal) {
|
$scope.removeJournal = function (journal) {
|
||||||
var index = this.voucher.Journals.indexOf(journal);
|
var index = this.voucher.Journals.indexOf(journal);
|
||||||
this.voucher.Journals.splice(index, 1);
|
this.voucher.Journals.splice(index, 1);
|
||||||
@ -31,6 +37,7 @@
|
|||||||
|
|
||||||
$scope.$watch('voucher.Journals', function (journals, oldValue) {
|
$scope.$watch('voucher.Journals', function (journals, oldValue) {
|
||||||
var amount = 0;
|
var amount = 0;
|
||||||
|
if (typeof journals !== 'undefined') {
|
||||||
for (var i = 0, l = journals.length; i < l; i++) {
|
for (var i = 0, l = journals.length; i < l; i++) {
|
||||||
if (journals[i].Debit === 1) {
|
if (journals[i].Debit === 1) {
|
||||||
var debitJournal = journals[i];
|
var debitJournal = journals[i];
|
||||||
@ -41,6 +48,7 @@
|
|||||||
if (debitJournal.Amount !== amount) {
|
if (debitJournal.Amount !== amount) {
|
||||||
debitJournal.Amount = amount;
|
debitJournal.Amount = amount;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
$scope.get = function (voucherid) {
|
$scope.get = function (voucherid) {
|
||||||
@ -54,6 +62,7 @@
|
|||||||
$scope.save = function () {
|
$scope.save = function () {
|
||||||
$scope.voucher.$save(function (u, putResponseHeaders) {
|
$scope.voucher.$save(function (u, putResponseHeaders) {
|
||||||
$scope.toasts.push({Type:'Success', Message:u.Code});
|
$scope.toasts.push({Type:'Success', Message:u.Code});
|
||||||
|
$location.path('/Receipt/' + u.VoucherID)
|
||||||
}, function (data, status) {
|
}, function (data, status) {
|
||||||
$scope.toasts.push({Type:'Error', Message:data.data});
|
$scope.toasts.push({Type:'Error', Message:data.data});
|
||||||
});
|
});
|
||||||
@ -62,6 +71,7 @@
|
|||||||
$scope.delete = function () {
|
$scope.delete = function () {
|
||||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||||
$scope.toasts.push({Type:'Success', Message:''});
|
$scope.toasts.push({Type:'Success', Message:''});
|
||||||
|
$location.path('/Receipt')
|
||||||
}, function (data, status) {
|
}, function (data, status) {
|
||||||
$scope.toasts.push({Type:'Error', Message:data.data});
|
$scope.toasts.push({Type:'Error', Message:data.data});
|
||||||
});
|
});
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
${h.ScriptLink(request, 'journal.js')}
|
${h.ScriptLink(request, 'journal.js')}
|
||||||
${h.ScriptLink(request, 'payment.js')}
|
${h.ScriptLink(request, 'payment.js')}
|
||||||
|
${h.ScriptLink(request, 'receipt.js')}
|
||||||
|
|
||||||
${h.ScriptLink(request, 'ledger.js')}
|
${h.ScriptLink(request, 'ledger.js')}
|
||||||
${h.ScriptLink(request, 'trial_balance.js')}
|
${h.ScriptLink(request, 'trial_balance.js')}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
${h.ScriptLink(request, 'journal.js')}
|
${h.ScriptLink(request, 'journal.js')}
|
||||||
${h.ScriptLink(request, 'payment.js')}
|
${h.ScriptLink(request, 'payment.js')}
|
||||||
|
${h.ScriptLink(request, 'receipt.js')}
|
||||||
|
|
||||||
${h.ScriptLink(request, 'ledger.js')}
|
${h.ScriptLink(request, 'ledger.js')}
|
||||||
${h.ScriptLink(request, 'trial_balance.js')}
|
${h.ScriptLink(request, 'trial_balance.js')}
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
<%inherit file="../base.mako"/>
|
|
||||||
<%block name="header">
|
|
||||||
${h.ScriptLink(request, 'receipt.js')}
|
|
||||||
<script type="text/javascript">
|
|
||||||
const perms = ${perms};
|
|
||||||
const voucher = ${json_voucher};
|
|
||||||
const ledgers = ${ledgers};
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function () {
|
|
||||||
$('#txtLedger').focus();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</%block>
|
|
||||||
<%block name="content">
|
|
||||||
<form method="post" autocomplete="off" class="form-horizontal" ng-controller="ReceiptCtrl">
|
|
||||||
${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="ddlLedger" class="control-label">From</label>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<select id="ddlLedger" class="select-box" ng-model="journal.Ledger.LedgerID"
|
|
||||||
ng-options="l.LedgerID as l.Name for l in ledgers"> </select>
|
|
||||||
|
|
||||||
<div class=" input-prepend">
|
|
||||||
<span class="add-on">₹</span><input type="text" id="txtLedgerAmount" class="span2" autocomplete="off"
|
|
||||||
placeholder="Amount" ng-model="journal.Amount"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class=" control-group" id="add">
|
|
||||||
<label for="txtLedger" class="control-label">Add</label>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<autocomplete id="txtLedger" url="${request.route_url('services_account_list')}" selname="name"
|
|
||||||
selid="id" ng-model="name"></autocomplete>
|
|
||||||
<div class=" input-prepend">
|
|
||||||
<span class="add-on">₹</span>
|
|
||||||
<input type="text" id="txtAmount" class="span2" autocomplete="off"
|
|
||||||
placeholder="Amount" ng-model="amount"/>
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-success" ng-click="addJournal()">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 class="Name">Name</th>
|
|
||||||
<th class="Amount">Amount</th>
|
|
||||||
<th class="Delete">Delete</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="tbodyMain">
|
|
||||||
<tr class="Journal" ng-repeat="journal in voucher.Journals | journalDebit:-1">
|
|
||||||
<td class="Name">{{journal.Ledger.Name}}</td>
|
|
||||||
<td data-column="Amount" class="Amount Editable">{{journal.Amount}}</td>
|
|
||||||
<td class="Delete">
|
|
||||||
<button ng-click="removeJournal(journal)">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['Receipt Create']">Save
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-primary" ng-click="save()" ng-hide="voucher.Code == '(Auto)'"
|
|
||||||
ng-disabled="!perms['Receipt 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['Receipt 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>
|
|
@ -3,6 +3,10 @@ from pyramid.view import view_config
|
|||||||
from brewman.helpers import Literal
|
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',
|
@view_config(request_method='GET', route_name='journal_id', renderer='brewman:templates/angular_base.mako',
|
||||||
permission='Journal Update')
|
permission='Journal Update')
|
||||||
@view_config(request_method='GET', route_name='journal', renderer='brewman:templates/angular_base.mako',
|
@view_config(request_method='GET', route_name='journal', renderer='brewman:templates/angular_base.mako',
|
||||||
|
@ -1,32 +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.ledger import ledger_list
|
|
||||||
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='receipt_id', renderer='brewman:templates/transaction/receipt.mako',
|
|
||||||
permission='Receipt Update')
|
|
||||||
@view_config(request_method='GET', route_name='receipt', renderer='brewman:templates/transaction/receipt.mako',
|
|
||||||
permission='Receipt Create')
|
|
||||||
def journal_get(request):
|
|
||||||
id = request.matchdict.get('id', None)
|
|
||||||
perms = Literal(json.dumps(request.session['perms']))
|
|
||||||
ledgers = Literal(json.dumps(ledger_list(type=1)))
|
|
||||||
if id is None:
|
|
||||||
json_voucher = Literal(json.dumps(blank_voucher('Receipt', 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 - Receipt Entry',
|
|
||||||
'id': id,
|
|
||||||
'perms': perms,
|
|
||||||
'ledgers': ledgers,
|
|
||||||
'json_voucher': json_voucher}
|
|
Loading…
x
Reference in New Issue
Block a user