def METHOD_NAME(job):
    template = dao_get_template_by_id(job.template_id)
    if template.template_type != LETTER_TYPE:
        return (
            False,
            "Only letter jobs can be cancelled through this endpoint. This is not a letter job.",
        )
    notifications = Notification.query.filter(Notification.job_id == job.id).all()
    count_notifications = len(notifications)
    if job.job_status != JOB_STATUS_FINISHED or count_notifications != job.notification_count:
        return (
            False,
            "We are still processing these letters, please try again in a minute.",
        )
    count_cancellable_notifications = len([n for n in notifications if n.status in CANCELLABLE_JOB_LETTER_STATUSES])
    if count_cancellable_notifications != job.notification_count or not letter_can_be_cancelled(
        NOTIFICATION_CREATED, job.created_at
    ):
        return (
            False,
            "It’s too late to cancel sending, these letters have already been sent.",
        )
    return True, None