Fix input of RequestedDeliveryDate in order head. Error handling in Company.get
This commit is contained in:
parent
0330e7a4bf
commit
7288e88135
2 changed files with 10 additions and 4 deletions
|
|
@ -407,7 +407,9 @@ class Order(RawBaseModel):
|
||||||
'adapters': {
|
'adapters': {
|
||||||
**{
|
**{
|
||||||
'OrdDatum': lambda ord_date, *_: ord_date.strftime("%Y-%m-%d"),
|
'OrdDatum': lambda ord_date, *_: ord_date.strftime("%Y-%m-%d"),
|
||||||
'OrdBerLevDat': lambda ord_date, *_: ord_date.strftime("%Y-%m-%d"),
|
'OrdBerLevDat': lambda deliv_date, *_: (
|
||||||
|
deliv_date.strftime("%Y-%m-%d")
|
||||||
|
if not isinstance(deliv_date, str) else deliv_date),
|
||||||
},
|
},
|
||||||
**RawBaseModel.__dict_args__['adapters']
|
**RawBaseModel.__dict_args__['adapters']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from pyjeeves.models.raw import Company as CompanyModel, Customer as CustomerMod
|
||||||
from pyjeeves.models import db
|
from pyjeeves.models import db
|
||||||
from sqlalchemy.sql.expression import and_
|
from sqlalchemy.sql.expression import and_
|
||||||
from sqlalchemy.orm.strategy_options import Load
|
from sqlalchemy.orm.strategy_options import Load
|
||||||
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
from pyjeeves import logging
|
from pyjeeves import logging
|
||||||
logger = logging.getLogger("PyJeeves." + __name__)
|
logger = logging.getLogger("PyJeeves." + __name__)
|
||||||
|
|
@ -16,9 +17,12 @@ class Company():
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get(ftg_nr):
|
def get(ftg_nr):
|
||||||
""" Query an article by number """
|
""" Query an article by number """
|
||||||
return db.raw.query(CompanyModel).filter_by(
|
try:
|
||||||
FtgNr=ftg_nr
|
return db.raw.query(CompanyModel).filter_by(
|
||||||
).one()
|
FtgNr=ftg_nr
|
||||||
|
).one()
|
||||||
|
except NoResultFound:
|
||||||
|
raise KeyError
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_all_active_customers():
|
def get_all_active_customers():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue