Fixes to pricing and customer models. Add req deliv to order. And more..

* Fix NullPriceAllowed and logic in price calculation
* Fix CustomerCategory join in Customer model
* Add RequestedDeliveryDate to order creation
* Start using Jeeves Signatures on order creation
This commit is contained in:
Marcus Lindvall 2019-09-23 14:12:34 +02:00
parent fc7c1e13bc
commit 6339e9d1ce
4 changed files with 63 additions and 24 deletions

View file

@ -3,6 +3,7 @@
from pyjeeves.models.raw import Company as CompanyModel, Customer as CustomerModel
from pyjeeves.models import db
from sqlalchemy.sql.expression import and_
from sqlalchemy.orm.strategy_options import Load
from pyjeeves import logging
logger = logging.getLogger("PyJeeves." + __name__)
@ -25,10 +26,24 @@ class Company():
return [c.CompanyModel for c in cust]
@staticmethod
def get_list(ftg_nr=[]):
return db.raw.query(CompanyModel).filter(
CompanyModel.FtgNr.in_(ftg_nr)
).all()
def get_customer_numbers(category_list=[10], class_list=[], filter_inactive=True):
category_in = CustomerModel.kundkategorikod.in_(category_list) if category_list else and_()
class_in = CustomerModel.kundklass.in_(class_list) if class_list else and_()
inactive = and_(CustomerModel.Makulerad == 0) if filter_inactive else and_()
cust = db.raw.query(CustomerModel).options(
Load(CustomerModel).noload('*')).filter(
and_(category_in, class_in, inactive)).all()
return [c.FtgNr for c in cust]
@staticmethod
def get_list(ftg_nr=[], filter_=and_(CustomerModel.Makulerad == 0), offset=0, limit=100):
ftg_filter = and_()
if ftg_nr:
ftg_filter = CompanyModel.FtgNr.in_(ftg_nr)
return db.raw.query(CompanyModel).join(CustomerModel).filter(
and_(ftg_filter, filter_)).order_by(
CompanyModel.FtgNr.desc()).offset(offset).limit(limit).all()
if __name__ == '__main__':