Beispiel #1
0
def notify_member_status_mails(batch, status_list, summary):
    """メールを通知する。

    :param batch バッチに管理ファイル
    :param status_list 通知の内容リスト
    :param summary 通知の集計情報
    """
    def get_status_info(salesperson_id):
        for status in status_list:
            if status['salesperson'].pk == salesperson_id:
                return [status]
        return []

    logger = batch.get_logger()
    today = datetime.date.today()
    next_month = common.add_months(today, 1)
    next_2_months = common.add_months(today, 2)
    next_ym = next_month.strftime('%Y%m')
    next_2_ym = next_2_months.strftime('%Y%m')
    # 営業部長取得する
    directors = get_salesperson_director()
    if directors:
        context = {
            'salesperson_list': directors,
            'status_list': status_list,
            'summary': summary,
            'domain': biz_config.get_domain_name(),
            'next_ym': next_ym,
            'next_2_ym': next_2_ym,
        }
        recipient_list = []
        for salesperson in directors:
            recipient_list.extend(salesperson.get_notify_mail_list())
        if recipient_list:
            batch.send_notify_mail(context, recipient_list)
    salesperson_list = get_salesperson_members()
    if salesperson_list:
        for salesperson in salesperson_list:
            recipient_list = salesperson.get_notify_mail_list()
            context = {
                'salesperson_list': [salesperson],
                'status_list': get_status_info(salesperson.pk),
                'summary': None,
                'domain': biz_config.get_domain_name(),
                'next_ym': next_ym,
                'next_2_ym': next_2_ym,
            }
            if recipient_list:
                batch.send_notify_mail(context, recipient_list, no_cc=True)
            else:
                logger.warning(u"%s の宛先が空白になっている。" %
                               (salesperson.__unicode__(), ))
Beispiel #2
0
def get_release_status():
    qs = models.VReleaseMember.objects.values(
        'release_year',
        'release_month',
    ).annotate(member_count=Count('id'), )
    today = timezone.now().date()
    data = {}
    for item in qs:
        ym = '{}{}'.format(item.get('release_year'), item.get('release_month'))
        if ym == today.strftime('%Y%m'):
            data['curr_month'] = item.get('member_count')
        elif ym == common.add_months(today).strftime('%Y%m'):
            data['next_month'] = item.get('member_count')
        elif ym == common.add_months(today, 2).strftime('%Y%m'):
            data['next_2_month'] = item.get('member_count')
    return data
Beispiel #3
0
 def get_queryset(self, request):
     queryset = super(ProjectMemberInline, self).get_queryset(request)
     if queryset.count() > 200:
         queryset = queryset.filter(
             end_date__gte=common.add_months(datetime.date.today(), -2))
     return queryset.filter(member__is_retired=False,
                            member__is_deleted=False).order_by(
                                '-end_date', '-start_date')
Beispiel #4
0
def get_release_members_by_month(date, p=None):
    """指定年月にリリースするメンバーを取得する。

    :param date 指定月
    :param p: 画面からの絞り込み条件
    """
    working_member_next_date = get_working_members(date=common.add_months(date, 1))
    project_members = get_project_members_month(date).filter(member__section__is_on_sales=True,
                                                             member__is_on_sales=True)\
        .exclude(member__in=working_member_next_date)
    if p:
        project_members = project_members.filter(**p)
    return project_members
Beispiel #5
0
    def get_deadline(self):
        """支払通知書とBP注文書をメール送信時の支払締切日を取得する

        来月の第六営業日

        :return:
        """
        date = common.get_first_day_from_ym(self.year + self.month)
        next_month = common.add_months(date, 1)
        business_days = common.get_business_days(next_month.year,
                                                 next_month.month)
        if len(business_days) > 5:
            return business_days[5]
        else:
            return next_month
Beispiel #6
0
    def get_pay_date(self, date=timezone.now().today()):
        """支払い期限日を取得する。

        :param date:
        :return:
        """
        months = int(self.payment_month) if self.payment_month else 1
        pay_month = common.add_months(date, months)
        if self.payment_day == '99' or not self.payment_day:
            return common.get_last_day_by_month(pay_month)
        else:
            pay_day = int(self.payment_day)
            last_day = common.get_last_day_by_month(pay_month)
            if last_day.day < pay_day:
                return last_day
            return datetime.date(pay_month.year, pay_month.month, pay_day)
Beispiel #7
0
def get_next_change_list():
    """入退場リスト

    :return:
    """
    first_day = common.get_first_day_current_month()
    last_day = common.get_last_day_by_month(first_day)
    next_first_day = common.get_first_day_by_month(common.add_months(first_day, 1))
    next_last_day = common.get_last_day_by_month(next_first_day)
    members = models.Member.objects.public_filter(Q(projectmember__end_date__gte=first_day,
                                                    projectmember__end_date__lte=last_day,
                                                    projectmember__is_deleted=False,
                                                    projectmember__status=2)
                                                  | Q(projectmember__start_date__gte=next_first_day,
                                                      projectmember__start_date__lte=next_last_day,
                                                      projectmember__is_deleted=False,
                                                      projectmember__status=2)).distinct()
    return members.filter(section__is_on_sales=True)
Beispiel #8
0
def get_subcontractor_release_next_2_month():
    """再来月にリリースする協力社員を取得する

    """
    next_month = common.add_months(datetime.date.today(), 2)
    return get_subcontractor_release_members_by_month(next_month)
Beispiel #9
0
def get_release_next_2_month():
    """再来月にリリースするメンバーを取得する。

    """
    next_2_month = common.add_months(datetime.date.today(), 2)
    return get_release_members_by_month(next_2_month)