Stored procedure helpers. Order repo and model. More SQLService updates.

* A generic stored procedure helper added, and support for calling them.
* Order and OrderItem tables added, including helpers and calls to SP for creation and updates.
* Minor updates to other repositories.
This commit is contained in:
Marcus Lindvall 2019-08-30 12:09:10 +02:00
parent b77a7069ce
commit 0af38e286e
9 changed files with 730 additions and 138 deletions

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from pyjeeves.models.raw import Company as CompanyModel, Customer as CustomerModel
from pyjeeves.models import db
from sqlalchemy.sql.expression import and_
from pyjeeves import logging
@ -14,18 +15,18 @@ class Company():
@staticmethod
def get(ftg_nr):
""" Query an article by number """
return CompanyModel.query.filter_by(
return db.raw.query(CompanyModel).filter_by(
FtgNr=ftg_nr
).one()
@staticmethod
def get_all_active_customers():
cust = CustomerModel.query.filter(and_(CustomerModel.Makulerad == 0)).all()
cust = db.raw.query(CustomerModel).filter(and_(CustomerModel.Makulerad == 0)).all()
return [c.CompanyModel for c in cust]
@staticmethod
def get_list(ftg_nr=[]):
return CompanyModel.query.filter(
return db.raw.query(CompanyModel).filter(
CompanyModel.FtgNr.in_(ftg_nr)
).all()