Feature: Discontinued Ledgers / Products will not show up in Vouchers reducing confusion.
This commit is contained in:
parent
62918bcee5
commit
218a1781a8
@ -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 + '%'))
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user