Fix: Batch autocomplete would bork on empty string as it would try to split Null
v8.0.1
This commit is contained in:
parent
889cac237c
commit
14930954a2
@ -1 +1 @@
|
||||
__version__ = "8.0.0"
|
||||
__version__ = "8.0.1"
|
||||
|
@ -109,15 +109,15 @@ class Product(Base):
|
||||
|
||||
@classmethod
|
||||
def query(cls, q, is_purchased=None, active=None, db=None):
|
||||
query_ = db.query(Product)
|
||||
query_ = db.query(cls)
|
||||
if active is not None:
|
||||
query_ = query_.filter(Product.is_active == active)
|
||||
query_ = query_.filter(cls.is_active == active)
|
||||
if is_purchased is not None:
|
||||
query_ = query_.filter(Product.is_purchased == is_purchased)
|
||||
query_ = query_.filter(cls.is_purchased == is_purchased)
|
||||
if q is not None:
|
||||
for item in q.split():
|
||||
if item.strip() != "":
|
||||
query_ = query_.filter(Product.name.ilike("%" + item + "%"))
|
||||
query_ = query_.filter(cls.name.ilike(f"%{item}%"))
|
||||
return query_
|
||||
|
||||
@classmethod
|
||||
@ -326,7 +326,7 @@ class AccountBase(Base):
|
||||
query_ = query_.filter(cls.is_active == active)
|
||||
if q is not None:
|
||||
for item in q.split():
|
||||
query_ = query_.filter(cls.name.ilike("%" + item + "%"))
|
||||
query_ = query_.filter(cls.name.ilike(f"%{item}%"))
|
||||
return query_.order_by(cls.name)
|
||||
|
||||
def create(self, db: Session):
|
||||
|
@ -391,14 +391,15 @@ class Batch(Base):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def list(cls, name, include_nil, date, db: Session):
|
||||
query = db.query(Batch).join(Batch.product)
|
||||
def list(cls, q, include_nil, date, db: Session):
|
||||
query = db.query(cls).join(cls.product)
|
||||
if not include_nil:
|
||||
query = query.filter(cls.quantity_remaining > 0)
|
||||
if date is not None:
|
||||
query = query.filter(cls.name <= date)
|
||||
for item in name.split():
|
||||
query = query.filter(Product.name.ilike(f"%{item}%"))
|
||||
if q is not None:
|
||||
for item in q.split():
|
||||
query = query.filter(cls.name.ilike(f"%{item}%"))
|
||||
return query.order_by(Product.name).order_by(cls.name).all()
|
||||
|
||||
@classmethod
|
||||
|
@ -152,7 +152,6 @@ async def show_term(
|
||||
current_user: UserToken = Depends(get_user),
|
||||
):
|
||||
count = c
|
||||
|
||||
list_ = []
|
||||
for index, item in enumerate(AccountBase.query(q, t, r, a, db)):
|
||||
list_.append({"id": item.id, "name": item.name})
|
||||
|
@ -29,12 +29,9 @@ def batch_term(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: UserToken = Depends(get_user),
|
||||
):
|
||||
filter_ = q if q is not None and q.strip() != "" else None
|
||||
date = None if not d else datetime.datetime.strptime(d, "%d-%b-%Y")
|
||||
list_ = []
|
||||
for index, item in enumerate(
|
||||
Batch.list(filter_, include_nil=False, date=date, db=db)
|
||||
):
|
||||
for index, item in enumerate(Batch.list(q, include_nil=False, date=date, db=db)):
|
||||
text = f"{item.product.name} ({item.product.units}) {item.quantity_remaining:.2f}@{item.rate:.2f} from {item.name.strftime('%d-%b-%Y')}"
|
||||
list_.append(
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "brewman"
|
||||
version = "8.0.0"
|
||||
version = "8.0.1"
|
||||
description = "Accounting plus inventory management for a restaurant."
|
||||
authors = ["tanshu <git@tanshu.com>"]
|
||||
|
||||
@ -41,7 +41,6 @@ skip_glob = ["*/setup.py"]
|
||||
filter_files = true
|
||||
known_first_party = "poetry"
|
||||
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
include = '\.pyi?$'
|
||||
|
@ -1,11 +1,18 @@
|
||||
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
#
|
||||
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
|
||||
|
||||
> 0.5%
|
||||
last 2 versions
|
||||
# For the full list of supported browsers by the Angular framework, please see:
|
||||
# https://angular.io/guide/browser-support
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
last 1 Chrome version
|
||||
last 1 Firefox version
|
||||
last 2 Edge major versions
|
||||
last 2 Safari major versions
|
||||
last 2 iOS major versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
not IE 9-11
|
||||
not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
|
||||
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
||||
|
@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "overlord",
|
||||
"version": "8.0.0",
|
||||
"version": "8.0.1",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"eslint": "eslint",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e",
|
||||
"eslint": "eslint",
|
||||
"prettier": "prettier",
|
||||
"husky": "husky"
|
||||
},
|
||||
@ -76,8 +76,7 @@
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"pre-push": "ng build --prod"
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
|
@ -7,7 +7,7 @@ import * as moment from 'moment';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
import {environment} from "../../environments/environment";
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { Product } from '../core/product';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
@ -182,7 +182,7 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
listenToProductChanges() {
|
||||
this.products = this.resetStockForm.get('product').valueChanges.pipe(
|
||||
startWith(null),
|
||||
startWith(''),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||
version: '8.0.0',
|
||||
version: '8.0.1',
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||
version: '8.0.0',
|
||||
version: '8.0.1',
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user