def changeMonth(self): ''' Changes the month and then copy despesas mensais from previous months if they don't exist. ''' from processor.DespesaMensalProcessor import DespesaMensalProcessor monthFilter = self.month months = self.monthDAO.find(monthFilter) month = None if len(months) == 1: month = months[0] else: month = monthFilter monthId = self.monthDAO.add(month) month.id = monthId print('Copying despesas from the past months...') DespesaMensalProcessor(month = month).copy() print('...Done') despesaMensalProcessor = DespesaMensalProcessor(month = month) despesaMensalProcessor.updateDespReservaAnual() despesaMensalProcessor.updateDespCarneLeao() month.month = DateUtil.toDate(month.month) return month
class DespesaAnualProcessor(DespesaChildProcessor): def __init__(self, month=None): super().__init__(month=month) self.despesaAnualDAO = DespesaAnualDAO() self.despesaMensalProcessor = DespesaMensalProcessor(month=month) def getDAO(self): return self.despesaAnualDAO def getModelType(self): return DespesaAnual def add(self, model): # skipping DespesaChildProcessor intentionally to avoid post CRUD actions GenericProcessor.add(self, model) self.despesaMensalProcessor.updateDespReservaAnual() def delete(self, model): # skipping DespesaChildProcessor intentionally to avoid post CRUD actions GenericProcessor.delete(self, model) self.despesaMensalProcessor.updateDespReservaAnual() def update(self, model): # skipping DespesaChildProcessor intentionally to avoid post CRUD actions GenericProcessor.update(self, model) self.despesaMensalProcessor.updateDespReservaAnual()