Return VAT Rate for articles
This commit is contained in:
parent
1ae563654c
commit
7310954468
2 changed files with 16 additions and 2 deletions
|
|
@ -27,7 +27,7 @@ try:
|
||||||
meta.reflect(bind=db.raw.connection(),
|
meta.reflect(bind=db.raw.connection(),
|
||||||
only=['ar', 'ars', 'xae', 'xare', 'fr', 'kus', 'x1k',
|
only=['ar', 'ars', 'xae', 'xare', 'fr', 'kus', 'x1k',
|
||||||
'oh', 'orp', 'lp', 'vg', 'xp', 'xm', 'prh', 'prl',
|
'oh', 'orp', 'lp', 'vg', 'xp', 'xm', 'prh', 'prl',
|
||||||
'kp', 'kpw', 'cr', 'X4', 'xw'])
|
'kp', 'kpw', 'cr', 'X4', 'xw', 'X1'])
|
||||||
except OperationalError as e:
|
except OperationalError as e:
|
||||||
logger.error("Failed to read Jeeves DB structure")
|
logger.error("Failed to read Jeeves DB structure")
|
||||||
raise e
|
raise e
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,12 @@ class ArticleBalance(RawBaseModel):
|
||||||
ArtNr = Column(Integer, ForeignKey('ar.ArtNr'), primary_key=True)
|
ArtNr = Column(Integer, ForeignKey('ar.ArtNr'), primary_key=True)
|
||||||
|
|
||||||
|
|
||||||
|
class VATRate(RawBaseModel):
|
||||||
|
__tablename__ = 'X1'
|
||||||
|
__column_map__ = {'MomsKod': 'VATID', 'MomsSats': 'VATRate'}
|
||||||
|
__to_dict_only__ = ('MomsKod', 'MomsSats')
|
||||||
|
|
||||||
|
|
||||||
class Article(RawBaseModel):
|
class Article(RawBaseModel):
|
||||||
__tablename__ = 'ar'
|
__tablename__ = 'ar'
|
||||||
|
|
||||||
|
|
@ -119,7 +125,8 @@ class Article(RawBaseModel):
|
||||||
'WholeSaleUnit',
|
'WholeSaleUnit',
|
||||||
'WholeSaleAmount',
|
'WholeSaleAmount',
|
||||||
'ListPrice',
|
'ListPrice',
|
||||||
'Balance')
|
'Balance',
|
||||||
|
'VATRate')
|
||||||
|
|
||||||
ArtNr = Column(Integer, primary_key=True)
|
ArtNr = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
|
|
@ -127,12 +134,15 @@ class Article(RawBaseModel):
|
||||||
ArtProdKlass = Column(Integer, ForeignKey('xp.ArtProdKlass'), primary_key=True)
|
ArtProdKlass = Column(Integer, ForeignKey('xp.ArtProdKlass'), primary_key=True)
|
||||||
ArtKod = Column(Integer, ForeignKey('xm.ArtKod'), primary_key=True)
|
ArtKod = Column(Integer, ForeignKey('xm.ArtKod'), primary_key=True)
|
||||||
|
|
||||||
|
MomsKod = Column(Integer, ForeignKey('X1.MomsKod'))
|
||||||
|
|
||||||
CommodityGroup = relationship(CommodityGroup, lazy='joined')
|
CommodityGroup = relationship(CommodityGroup, lazy='joined')
|
||||||
ProductClass = relationship(ProductClass, lazy='joined')
|
ProductClass = relationship(ProductClass, lazy='joined')
|
||||||
ArticleClass = relationship(ArticleClass, lazy='joined')
|
ArticleClass = relationship(ArticleClass, lazy='joined')
|
||||||
ArticleBalance = relationship(ArticleBalance)
|
ArticleBalance = relationship(ArticleBalance)
|
||||||
|
|
||||||
ArticleUnit = relationship(ArticleUnit, uselist=True)
|
ArticleUnit = relationship(ArticleUnit, uselist=True)
|
||||||
|
ArticleVATRate = relationship(VATRate, lazy='joined')
|
||||||
|
|
||||||
def _get_alt_unit(self):
|
def _get_alt_unit(self):
|
||||||
# Find matching alternative unit for amount per piece, or return default for the article.
|
# Find matching alternative unit for amount per piece, or return default for the article.
|
||||||
|
|
@ -171,6 +181,10 @@ class Article(RawBaseModel):
|
||||||
# Amount of units in the alternative unit of the article, or 1 if none exist.
|
# Amount of units in the alternative unit of the article, or 1 if none exist.
|
||||||
return self.get_unit_conv()
|
return self.get_unit_conv()
|
||||||
|
|
||||||
|
@hybrid_property
|
||||||
|
def VATRate(self):
|
||||||
|
return self.ArticleVATRate.MomsSats
|
||||||
|
|
||||||
@hybrid_property
|
@hybrid_property
|
||||||
def ListPrice(self):
|
def ListPrice(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue