Restructure project #3
|
@ -44,7 +44,7 @@ def search_product(string, session, find_hidden_products=True):
|
||||||
.filter(
|
.filter(
|
||||||
or_(
|
or_(
|
||||||
Product.bar_code == string,
|
Product.bar_code == string,
|
||||||
and_(Product.name == string, Product.hidden == False),
|
and_(Product.name == string, Product.hidden is False),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
@ -68,7 +68,7 @@ def search_product(string, session, find_hidden_products=True):
|
||||||
.filter(
|
.filter(
|
||||||
or_(
|
or_(
|
||||||
Product.bar_code.ilike(f"%{string}%"),
|
Product.bar_code.ilike(f"%{string}%"),
|
||||||
and_(Product.name.ilike(f"%{string}%"), Product.hidden == False),
|
and_(Product.name.ilike(f"%{string}%"), Product.hidden is False),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
|
@ -103,14 +103,13 @@ def guess_data_type(string):
|
||||||
|
|
||||||
def argmax(d, all=False, value=None):
|
def argmax(d, all=False, value=None):
|
||||||
maxarg = None
|
maxarg = None
|
||||||
maxargs = []
|
if value is not None:
|
||||||
if value != None:
|
|
||||||
dd = d
|
dd = d
|
||||||
d = {}
|
d = {}
|
||||||
for key in list(dd.keys()):
|
for key in list(dd.keys()):
|
||||||
d[key] = value(dd[key])
|
d[key] = value(dd[key])
|
||||||
for key in list(d.keys()):
|
for key in list(d.keys()):
|
||||||
if maxarg == None or d[key] > d[maxarg]:
|
if maxarg is None or d[key] > d[maxarg]:
|
||||||
maxarg = key
|
maxarg = key
|
||||||
if all:
|
if all:
|
||||||
return [k for k in list(d.keys()) if d[k] == d[maxarg]]
|
return [k for k in list(d.keys()) if d[k] == d[maxarg]]
|
||||||
|
|
|
@ -283,10 +283,8 @@ def buildDatabaseFromDb(inputType, inputProduct, inputUser):
|
||||||
for transaction in transaction_list:
|
for transaction in transaction_list:
|
||||||
if transaction.purchase:
|
if transaction.purchase:
|
||||||
products = "¤".join([ent.product.name for ent in transaction.purchase.entries])
|
products = "¤".join([ent.product.name for ent in transaction.purchase.entries])
|
||||||
description = ""
|
|
||||||
else:
|
else:
|
||||||
products = ""
|
products = ""
|
||||||
description = transaction.description
|
|
||||||
line = line_format % (
|
line = line_format % (
|
||||||
"purchase",
|
"purchase",
|
||||||
transaction.time,
|
transaction.time,
|
||||||
|
|
|
@ -1,3 +1,28 @@
|
||||||
|
__all__ = [
|
||||||
|
"AddProductMenu",
|
||||||
|
"AddStockMenu",
|
||||||
|
"AddUserMenu",
|
||||||
|
"AdjustCreditMenu",
|
||||||
|
"AdjustStockMenu",
|
||||||
|
"BalanceMenu",
|
||||||
|
"BuyMenu",
|
||||||
|
"CleanupStockMenu",
|
||||||
|
"EditProductMenu",
|
||||||
|
"EditUserMenu",
|
||||||
|
"FAQMenu",
|
||||||
|
"LoggedStatisticsMenu",
|
||||||
|
"MainMenu",
|
||||||
|
"Menu",
|
||||||
|
"PrintLabelMenu",
|
||||||
|
"ProductListMenu",
|
||||||
|
"ProductPopularityMenu",
|
||||||
|
"ProductRevenueMenu",
|
||||||
|
"ProductSearchMenu",
|
||||||
|
"ShowUserMenu",
|
||||||
|
"TransferMenu",
|
||||||
|
"UserListMenu",
|
||||||
|
]
|
||||||
|
|
||||||
from .addstock import AddStockMenu
|
from .addstock import AddStockMenu
|
||||||
from .buymenu import BuyMenu
|
from .buymenu import BuyMenu
|
||||||
from .editing import (
|
from .editing import (
|
||||||
|
|
|
@ -5,10 +5,8 @@ from datetime import datetime
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
Boolean,
|
|
||||||
DateTime,
|
DateTime,
|
||||||
Integer,
|
Integer,
|
||||||
String,
|
|
||||||
)
|
)
|
||||||
from sqlalchemy.orm import (
|
from sqlalchemy.orm import (
|
||||||
Mapped,
|
Mapped,
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
__all__ = [
|
||||||
|
'Base',
|
||||||
|
'Product',
|
||||||
|
'Purchase',
|
||||||
|
'PurchaseEntry',
|
||||||
|
'Transaction',
|
||||||
|
'User',
|
||||||
|
'UserProducts',
|
||||||
|
]
|
||||||
|
|
||||||
from .Base import Base
|
from .Base import Base
|
||||||
from .Product import Product
|
from .Product import Product
|
||||||
from .Purchase import Purchase
|
from .Purchase import Purchase
|
||||||
|
|
Loading…
Reference in New Issue