Feature: Discontinued Ledgers / Products will not show up in Vouchers reducing confusion.

This commit is contained in:
Tanshu 2013-10-03 15:58:16 +05:30
parent 62918bcee5
commit 218a1781a8
8 changed files with 27 additions and 23 deletions

View File

@ -52,8 +52,10 @@ class Product(Base):
return "{0} ({1})".format(self.name, self.units)
@classmethod
def list(cls, name):
def list(cls, name, active):
query = DBSession.query(cls)
if active is not None:
query = query.filter(cls.discontinued != active)
for item in name.split():
query = query.filter(cls.name.ilike('%' + item + '%'))
return query.order_by(cls.name)
@ -197,14 +199,16 @@ class LedgerBase(Base):
return DBSession.query(cls).all()
@classmethod
def list(cls, type, name, is_reconcilable):
def list(cls, type, name, reconcilable, active):
query = DBSession.query(cls)
if type is not None:
if not isinstance(type, int):
type = int(type)
query = query.filter(cls.type == type)
if is_reconcilable is not None:
query = query.filter(cls.is_reconcilable == is_reconcilable)
if reconcilable is not None:
query = query.filter(cls.is_reconcilable == reconcilable)
if active is not None:
query = query.filter(cls.is_active == active)
if name is not None:
for item in name.split():
query = query.filter(cls.name.ilike('%' + item + '%'))

View File

@ -152,12 +152,12 @@ var JournalCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher
$scope.accounts = function ($viewValue) {
var deferred = $q.defer();
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
deferred.resolve(result);
});
return deferred.promise;
}
}]
};
}];
JournalCtrl.resolve = {
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {

View File

@ -152,7 +152,7 @@ var PaymentCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'voucher
$scope.accounts = function ($viewValue) {
var deferred = $q.defer();
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
deferred.resolve(result);
});
return deferred.promise;

View File

@ -159,7 +159,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', '
$scope.accounts = function ($viewValue) {
var deferred = $q.defer();
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
deferred.resolve(result);
});
return deferred.promise;

View File

@ -164,15 +164,15 @@ var PurchaseCtrl = ['$scope', '$location', '$q', 'dateFilter', '$modal', 'vouche
$scope.accounts = function ($viewValue) {
var deferred = $q.defer();
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
Account.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
deferred.resolve(result);
});
return deferred.promise;
}
};
$scope.products = function ($viewValue) {
var deferred = $q.defer();
Product.autocomplete({term: $viewValue, count: 20}, function (result) {
Product.autocomplete({term: $viewValue, count: 20, a:true}, function (result) {
deferred.resolve(result);
});
return deferred.promise;

View File

@ -152,13 +152,12 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', '$q', 'dateFilter', '$
$scope.accounts = function ($viewValue) {
var deferred = $q.defer();
Account.autocomplete({term: $viewValue, count: 20}, function (result) {
Account.autocomplete({term: $viewValue, count: 20, 'a':true}, function (result) {
deferred.resolve(result);
});
return deferred.promise;
}
}]
};
}];
ReceiptCtrl.resolve = {
voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) {

View File

@ -94,16 +94,15 @@ def show_term(request):
type = int(type) if type is not None else None
filter = request.GET.get('term', None)
filter = filter if filter is not None and filter is not '' else None
is_reconcilable = request.GET.get('r', None)
is_reconcilable = is_reconcilable if is_reconcilable is not None else None
reconcilable = request.GET.get('r', None)
reconcilable = reconcilable if reconcilable is not None else None
active = request.GET.get('a', None)
active = active if active is not None else None
count = request.GET.get('count', None)
count = None if count is None or count == '' else int(count)
return ledger_list(type, filter, count, is_reconcilable)
def ledger_list(type=None, filter=None, count=None, is_reconcilable=None):
list = []
for index, item in enumerate(LedgerBase.list(type, filter, is_reconcilable)):
for index, item in enumerate(LedgerBase.list(type, filter, reconcilable, active)):
list.append({'LedgerID': item.id, 'Name': item.name})
if count is not None and index == count - 1:
break

View File

@ -95,10 +95,12 @@ def show_list(request):
def show_term(request):
term = request.GET.get('term', None)
term = term if term is not None and term is not '' else None
active = request.GET.get('a', None)
active = active if active is not None else None
count = request.GET.get('count', None)
count = None if count is None or count == '' else int(count)
list = []
for index, item in enumerate(Product.list(term)):
for index, item in enumerate(Product.list(term, active)):
list.append({'ProductID': item.id, 'Name': item.full_name, 'Price': item.price})
if count is not None and index == count - 1:
break