fix
This commit is contained in:
parent
249d9b60d2
commit
abac79a8ae
@ -57,19 +57,19 @@ def send_message_to_user_generic(obj):
|
||||
@shared_task
|
||||
def remind_about_cheque():
|
||||
try:
|
||||
last_month = now() - timedelta(days=30)
|
||||
last_month = now().replace(day=1)
|
||||
users = UserState.objects.filter(is_registered=True)
|
||||
|
||||
for user in users:
|
||||
last_receipt = None
|
||||
cheques_by_user = Cheque.objects.filter(user=user)
|
||||
if len(cheques_by_user) > 0:
|
||||
last_receipt = cheques_by_user.latest('uploaded_at')
|
||||
|
||||
if not last_receipt or last_receipt.uploaded_at < last_month:
|
||||
try:
|
||||
last_receipt = Cheque.objects.latest('uploaded_at')
|
||||
except Cheque.DoesNotExist:
|
||||
continue
|
||||
if last_receipt.uploaded_at < last_month:
|
||||
send_message_to_user.delay(
|
||||
user.chat_id,
|
||||
"Пожалуйста, загрузите новый чек за текущий месяц!"
|
||||
)
|
||||
except Exception:
|
||||
error_logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user