def turnover_projections(self): """ Return a query for turnover projections """ query = TurnoverProjection.query() query = query.filter( TurnoverProjection.company_id == self.request.context.id) result = query.filter(TurnoverProjection.year == self.year) return result
def turnover_projections(self): """ Return a query for turnover projections """ query = TurnoverProjection.query() query = query.filter( TurnoverProjection.company_id==self.request.context.id ) result = query.filter(TurnoverProjection.year==self.year) return result
def submit_success(self, appstruct): """ Add/Edit a turnover projection in the database """ appstruct['year'] = self.year appstruct['company_id'] = self.request.context.id query = self.turnover_projections() query = query.filter(TurnoverProjection.month == appstruct['month']) result = query.first() projection = result or TurnoverProjection() projection = merge_session_with_post(projection, appstruct) if projection.id is not None: projection = self.request.dbsession.merge(projection) else: self.request.dbsession.add(projection) url = get_current_url(self.request) return HTTPFound(url)
def getOne(): return TurnoverProjection.query().first()