0
I am developing a small project that takes care of organizing and controlling the daily sales of a retail seller. Basically the user will impute their sales and kpi’s and the application will try to reset the targets according to these values, among other features, taking into account of course, a monthly quota.
My difficulty in this phase of testing is to simulate the passage of time, because much of the applicability of the project is tied to this (reports, feedbacks, etc). I decided to create a class
Timeflow, since in the procedural paradigm it was finding many limitations, necessity of the use of files, as well as lack of organization in the code.
Follow code still at the beginning:
class TimeFlow:
ano = ('Janeiro', 'Fevereiro', 'Março',
'Abril', 'Maio', 'Junho',
'Julho', 'Agosto', 'Setembro',
'Outubro', 'Novembro', 'Dezembro')
semana_completa = ('Segunda-Feira',
'Terça-Feira',
'Quarta-Feira',
'Quinta-Feira',
'Sexta-Feira',
'Sábado',
'Domingo')
def __init__(self):
self.dia = date.today().day
self.mes = ano[date.today().month - 1]
self.ano = date.today().year
self.dia_semana = semana_completa[date.today().weekday() - 1]
def finaliza_dia(self):
duracao_mes = úteis.dias_mes_atual() # função que retorna número de dias do mês atual
if dia == duracao_mes:
pass
# aplicar aqui def de passagem de mês
else:
self.dia += 1
# preciso passar dia da semana também
def finaliza_mes(self):
pass
def finaliza_ano(self):
pass
def mostra_data(self):
pass
My question is how to use the variables that will determine the passage of time and where to create them. I know the method __init__
it runs every time an instance is generated, so it makes sense to put those variables there, right? The problem is that I’m not being able to use year and week_complete structures within the constructor method, as you can see. Or I could just create these variables as class variables?
can you explain to me the use of the replace method? Does relativedelta no longer make this date change automatically? Using the method proximo_mes as reference, if we had left from January 4 for example it would return 01/02/1970, no? In the case of the project I will not need to spend years or months, unless it really is the last day of the month or year, that is, time will naturally pass.
– Curi
Another question is that I am not able to use the module, is raising exception Modulenotfounderror. I have made all possible attempts and even the python-dateutil package appears in the list of external modules. The curious thing is that the IDE also already recognizes the methods self-competing the code. I don’t know what might be going on...
– Curi