Esempio n. 1
0
def get_request_members_in_project(project, customer_order, year, month):
    """指定案件の指定注文書の中に、対象のメンバーを取得する。

    :param project: 指定案件
    :param customer_order: 指定注文書
    :param year: 対象年
    :param month: 対象月
    :return: メンバーのリスト
    """
    first_day = common.get_first_day_from_ym(year + month)
    last_day = common.get_last_day_by_month(first_day)
    if customer_order.projects.filter(is_deleted=False).count() > 1:
        # 一つの注文書に複数の案件がある場合
        projects = customer_order.projects.filter(is_deleted=False)
        project_members = models.ProjectMember.objects.filter(
            project__in=projects,
            start_date__lte=last_day,
            end_date__gte=first_day,
            is_deleted=False,
        )
    elif project.customerorder_set.filter(start_date__lte=last_day,
                                          end_date__gte=first_day,
                                          is_deleted=False).count() > 1:
        # 1つの案件に複数の注文書ある場合
        raise CustomException(constants.ERROR_NOT_IMPLEMENTED)
    else:
        project_members = project.get_project_members_by_month(year, month)
    return project_members
Esempio n. 2
0
def get_request_members_in_project(project, client_order, ym):
    """指定案件の指定注文書の中に、対象のメンバーを取得する。

    :param project: 指定案件
    :param client_order: 指定注文書
    :param ym: 対象年月
    :return: メンバーのリスト
    """
    if client_order.projects.public_filter(is_deleted=False).count() > 1:
        # 一つの注文書に複数の案件がある場合
        projects = client_order.projects.public_filter(is_deleted=False)
        project_members = models.ProjectMember.objects.public_filter(project__in=projects)
    elif project.get_order_by_month(ym[:4], ym[4:]).count() > 1:
        # 1つの案件に複数の注文書ある場合
        project_members = []
        if client_order.member_comma_list:
            # 重複したメンバーを外す。
            member_id_list = sorted(set(client_order.member_comma_list.split(",")))
            first_day = common.get_first_day_from_ym(ym)
            last_day = common.get_last_day_by_month(first_day)
            for pm_id in member_id_list:
                try:
                    project_members.append(
                        models.ProjectMember.objects.get(pk=int(pm_id), is_deleted=False, status=2,
                                                         start_date__lte=last_day,
                                                         end_date__gte=first_day))
                except ObjectDoesNotExist:
                    pass
    else:
        project_members = project.get_project_members_by_month(ym=ym)
    return project_members
Esempio n. 3
0
def get_user_holidays_by_month(sys_user, year, month):
    used_days = 0
    if sys_user:
        first_day = common.get_first_day_from_ym('%s%02d' % (year, int(month)))
        last_day = common.get_last_day_by_month(first_day)
        used_holidays = models.HolidaysApplication.objects.\
            filter(Q(start_date__gte=first_day) | Q(end_date__lte=last_day),
                   employee=sys_user)
        for holiday in used_holidays:
            used_days += holiday.use_days
    return used_days
Esempio n. 4
0
def cost_subcontractor_members_by_month(year, month):
    first_day = common.get_first_day_from_ym(year + month)
    last_day = common.get_last_day_by_month(first_day)
    queryset = models.MemberAttendance.objects.public_filter(
        Q(project_member__member__bpcontract__end_date__gte=first_day)
        | Q(project_member__member__bpcontract__end_date__isnull=True),
        project_member__member__bpcontract__start_date__lte=last_day,
        year=year,
        month=month,
    ).order_by('project_member__member__first_name',
               'project_member__member__last_name').distinct()
    return queryset
Esempio n. 5
0
 def post(self, request, *args, **kwargs):
     company = Company.get_company()
     partner = models.Partner.objects.get(pk=kwargs.get('pk'))
     project_member = ProjectMember.objects.get(
         pk=kwargs.get('project_member_id'))
     year = request.data.get('year')
     month = request.data.get('month')
     first_day = common.get_first_day_from_ym(year + month)
     last_day = common.get_last_day_by_month(first_day)
     end_date = last_day if last_day <= project_member.end_date else project_member.end_date
     publish_date = datetime.datetime.strptime(
         request.data.get('publish_date'), '%Y-%m-%d')
     end_year = request.data.get('end_year')
     end_month = request.data.get('end_month')
     salesperson = get_member_salesperson_by_month(project_member.member,
                                                   end_date)
     order = models.BpMemberOrder.get_next_bp_order(partner, project_member,
                                                    year, month,
                                                    publish_date, end_year,
                                                    end_month, salesperson)
     order_data = self.get_order_data(
         company=company,
         partner=partner,
         order_no=order.order_no,
         year=year,
         month=month,
         publish_date=publish_date,
         salesperson=salesperson,
         end_year=end_year,
         end_month=end_month,
         project_member=project_member,
     )
     if not order.pk:
         order.created_user = request.user
     order.updated_user = request.user
     order.save(other_data=order_data)
     filename, filename_request = common.get_order_file_path(
         order.order_no, project_member.member.full_name)
     # 注文書
     attachment = self.create_order_file(order, 'partner/member_order.html',
                                         order_data, filename,
                                         order.filename)
     order.filename = attachment.uuid
     # 注文請書
     attachment = self.create_order_file(
         order, 'partner/member_order_request.html', order_data, filename,
         order.filename_request)
     order.filename_request = attachment.uuid
     order.save(update_fields=('filename', 'filename_request'))
     return Response(serializers.BpMemberOrderDisplaySerializer(order).data)
Esempio n. 6
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
Esempio n. 7
0
    def get_project_members_by_month(self, year, month):
        """指定年月に案件にアサインしているメンバー

        :param year:
        :param month:
        :return:
        """
        first_day = common.get_first_day_from_ym(year + month)
        last_day = common.get_last_day_by_month(first_day)
        return self.projectmember_set.filter(
            start_date__lte=last_day,
            end_date__gte=first_day,
            is_deleted=False
        ).exclude(
            status='1'  # 提案中を除外
        )
Esempio n. 8
0
 def get_form(self, request, obj=None, **kwargs):
     form = super(ClientOrderAdmin, self).get_form(request, obj, **kwargs)
     project_id = request.GET.get('project_id', None)
     ym = request.GET.get("ym", None)
     banks = BankInfo.objects.public_all()
     if project_id:
         project = Project.objects.public_filter(pk=project_id)
         form.base_fields['projects'].initial = project
         form.base_fields['name'].initial = project[0].name if project.count() > 0 else ""
     if ym:
         first_day = common.get_first_day_from_ym(ym)
         form.base_fields['start_date'].initial = first_day
         form.base_fields['end_date'].initial = common.get_last_day_by_month(first_day)
     if banks.count() > 0:
         form.base_fields['bank_info'].initial = banks[0]
     return form
Esempio n. 9
0
 def get_form(self, request, obj=None, **kwargs):
     form = super(ClientOrderAdmin, self).get_form(request, obj, **kwargs)
     project_id = request.GET.get('project_id', None)
     ym = request.GET.get("ym", None)
     banks = models.BankInfo.objects.public_all()
     if project_id:
         project = models.Project.objects.public_filter(pk=project_id)
         form.base_fields['projects'].initial = project
         form.base_fields['name'].initial = project[
             0].name if project.count() > 0 else ""
     if ym:
         first_day = common.get_first_day_from_ym(ym)
         form.base_fields['start_date'].initial = first_day
         form.base_fields[
             'end_date'].initial = common.get_last_day_by_month(first_day)
     if banks.count() > 0:
         form.base_fields['bank_info'].initial = banks[0]
     return form
Esempio n. 10
0
def get_projects_orders(ym, q=None, o=None):
    """案件の注文情報を取得する。

    :param ym:対象年月
    :param q:絞り込み条件
    :param o:並び順
    :return:
    """
    first_day = common.get_first_day_from_ym(ym)
    last_day = common.get_last_day_by_month(first_day)

    project_orders = models.ClientOrder.projects.through.objects\
        .filter(Q(clientorder__isnull=True) | Q(clientorder__start_date__lte=last_day,
                                                clientorder__end_date__gte=first_day),
                project__start_date__lte=last_day,
                project__end_date__gte=first_day).distinct()

    if q:
        if 'project__projectrequest__request_no__contains' in q:
            q.update({'project__projectrequest__year': ym[:4],
                      'project__projectrequest__month': ym[4:]})
        project_orders = project_orders.filter(**q)

    order_by_request_no = None
    if o:
        if 'project__projectrequest__request_no' in o:
            order_by_request_no = 'ASC'
            o.remove('project__projectrequest__request_no')
        elif '-project__projectrequest__request_no' in o:
            order_by_request_no = 'DESC'
            o.remove('-project__projectrequest__request_no')
        project_orders = project_orders.order_by(*o)

    all_project_orders = []
    for project_order in project_orders:
        project_request = project_order.project.get_project_request(ym[:4], ym[4:], project_order.clientorder)
        all_project_orders.append((project_order.project, project_request, project_order.clientorder))
    if order_by_request_no == 'ASC':
        all_project_orders.sort(key=lambda d: d[1].request_no)
    elif order_by_request_no == 'DESC':
        all_project_orders.sort(key=lambda d: d[1].request_no, reverse=True)
    return all_project_orders
Esempio n. 11
0
def get_partner_member_contract(partner, member, year=None, month=None):
    """協力社員の契約を取得

    :param partner: 協力会社
    :param member: 社員
    :param year: 対象年
    :param month: 対象月
    :return:
    """
    try:
        first_day = common.get_first_day_from_ym(year + month)
        last_day = common.get_last_day_by_month(first_day)
        return models.BpContract.objects.get(
            Q(end_date__gte=first_day) | Q(end_date__isnull=True),
            start_date__lte=last_day,
            company=partner,
            member=member,
        )
    except ObjectDoesNotExist:
        raise CustomException(constants.ERROR_NO_PARTNER_CONTRACT.format(name=member, company=partner))
    except MultipleObjectsReturned:
        raise CustomException(constants.ERROR_MULTI_PARTNER_CONTRACT.format(name=member, company=partner))
Esempio n. 12
0
def cost_subcontractors_by_month(year, month):
    first_day = common.get_first_day_from_ym(year + month)
    last_day = common.get_last_day_by_month(first_day)
    queryset = models.MemberAttendance.objects.public_filter(
        Q(project_member__member__bpcontract__end_date__gte=first_day)
        | Q(project_member__member__bpcontract__end_date__isnull=True),
        project_member__member__bpcontract__start_date__lte=last_day,
        year=year,
        month=month,
    ).order_by(
        'project_member__member__subcontractor').distinct().prefetch_related(
            'project_member__member__subcontractor', )

    subcontractors = dict()
    for member_attendance in queryset:
        cost = member_attendance.get_all_cost()
        if member_attendance.project_member.member.subcontractor in subcontractors:
            subcontractors[
                member_attendance.project_member.member.subcontractor] += cost
        else:
            subcontractors[
                member_attendance.project_member.member.subcontractor] = cost
    return subcontractors.items()
Esempio n. 13
0
def generate_request_data(company, project, client_order, bank_info, ym, project_request):
    first_day = common.get_first_day_from_ym(ym)
    last_day = common.get_last_day_by_month(first_day)
    data = {'DETAIL': {}, 'EXTRA': {}}
    data['EXTRA']['YM'] = ym
    # お客様郵便番号
    data['DETAIL']['CLIENT_POST_CODE'] = common.get_full_postcode(project.client.post_code)
    # お客様住所
    data['DETAIL']['CLIENT_ADDRESS'] = project.client.address1 + project.client.address2
    # お客様電話番号
    data['DETAIL']['CLIENT_TEL'] = project.client.tel
    # お客様名称
    data['DETAIL']['CLIENT_COMPANY_NAME'] = project.client.name
    # 作業期間
    data['DETAIL']['WORK_PERIOD'] = first_day.strftime(u'%Y年%m月%d日'.encode('utf-8')).decode('utf-8') + u" ~ " + last_day.strftime(u'%Y年%m月%d日'.encode('utf-8')).decode('utf-8')
    data['EXTRA']['WORK_PERIOD_START'] = first_day
    data['EXTRA']['WORK_PERIOD_END'] = last_day
    # 注文番号
    data['DETAIL']['ORDER_NO'] = client_order.order_no if client_order.order_no else u""
    # 注文日
    data['DETAIL']['REQUEST_DATE'] = client_order.order_date.strftime('%Y/%m/%d') if client_order.order_date else ""
    # 契約件名
    data['DETAIL']['CONTRACT_NAME'] = project_request.request_name
    # お支払い期限
    data['DETAIL']['REMIT_DATE'] = project.client.get_pay_date(date=first_day).strftime('%Y/%m/%d')
    data['EXTRA']['REMIT_DATE'] = project.client.get_pay_date(date=first_day)
    # 請求番号
    data['DETAIL']['REQUEST_NO'] = project_request.request_no
    # 発行日(対象月の最終日)
    data['DETAIL']['PUBLISH_DATE'] = last_day.strftime(u"%Y年%m月%d日".encode('utf-8')).decode('utf-8')
    data['EXTRA']['PUBLISH_DATE'] = last_day
    # 本社郵便番号
    data['DETAIL']['POST_CODE'] = common.get_full_postcode(company.post_code)
    # 本社住所
    data['DETAIL']['ADDRESS'] = company.address1 + company.address2
    # 会社名
    data['DETAIL']['COMPANY_NAME'] = company.name
    # 代表取締役
    member = company.get_master()
    data['DETAIL']['MASTER'] = u"%s %s" % (member.first_name, member.last_name) if member else ""
    # 本社電話番号
    data['DETAIL']['TEL'] = company.tel
    # 振込先銀行名称
    data['EXTRA']['BANK'] = bank_info
    data['DETAIL']['BANK_NAME'] = bank_info.bank_name if bank_info else u""
    # 支店番号
    data['DETAIL']['BRANCH_NO'] = bank_info.branch_no if bank_info else u""
    # 支店名称
    data['DETAIL']['BRANCH_NAME'] = bank_info.branch_name if bank_info else u""
    # 預金種類
    data['DETAIL']['ACCOUNT_TYPE'] = bank_info.get_account_type_display() if bank_info else u""
    # 口座番号
    data['DETAIL']['ACCOUNT_NUMBER'] = bank_info.account_number if bank_info else u""
    # 口座名義人
    data['DETAIL']['BANK_ACCOUNT_HOLDER'] = bank_info.account_holder if bank_info else u""

    # 全員の合計明細
    detail_all = dict()
    # メンバー毎の明細
    detail_members = []

    project_members = get_request_members_in_project(project, client_order, ym)
    members_amount = 0
    if project.is_lump:
        members_amount = project.lump_amount
        # 番号
        detail_all['NO'] = u"1"
        # 項目:契約件名に設定
        detail_all['ITEM_NAME_ATTENDANCE_TOTAL'] = data['DETAIL']['CONTRACT_NAME']
        # 数量
        detail_all['ITEM_COUNT'] = u"1"
        # 単位
        detail_all['ITEM_UNIT'] = u"一式"
        # 金額
        detail_all['ITEM_AMOUNT_ATTENDANCE_ALL'] = members_amount
        # 備考
        detail_all['ITEM_COMMENT'] = project.lump_comment if project.is_lump else u""
    else:
        for i, project_member in enumerate(project_members):
            dict_expenses = dict()
            # この項目は請求書の出力ではなく、履歴データをProjectRequestDetailに保存するために使う。
            dict_expenses["EXTRA_PROJECT_MEMBER"] = project_member
            # 番号
            dict_expenses['NO'] = str(i + 1)
            # 項目
            dict_expenses['ITEM_NAME'] = project_member.member.__unicode__()
            # 時給の場合
            if project.is_hourly_pay:
                # 単価(円)
                dict_expenses['ITEM_PRICE'] = project_member.hourly_pay
                # Min/Max(H)
                dict_expenses['ITEM_MIN_MAX'] = u""
            else:
                # 単価(円)
                dict_expenses['ITEM_PRICE'] = project_member.price
                # Min/Max(H)
                dict_expenses['ITEM_MIN_MAX'] = "%s/%s" % (int(project_member.min_hours), int(project_member.max_hours))
            dict_expenses.update(project_member.get_attendance_dict(first_day.year, first_day.month))
            # 金額合計
            members_amount += dict_expenses['ITEM_AMOUNT_TOTAL']
            detail_members.append(dict_expenses)

    detail_expenses, expenses_amount = get_request_expenses_list(project,
                                                                 first_day.year,
                                                                 '%02d' % (first_day.month,),
                                                                 project_members)

    data['detail_all'] = detail_all
    data['MEMBERS'] = detail_members
    data['EXPENSES'] = detail_expenses  # 清算リスト
    data['DETAIL']['ITEM_AMOUNT_ATTENDANCE'] = members_amount
    if project.client.decimal_type == '0':
        data['DETAIL']['ITEM_AMOUNT_ATTENDANCE_TAX'] = int(round(members_amount * project.client.tax_rate))
    else:
        # 出勤のトータル金額の税金
        data['DETAIL']['ITEM_AMOUNT_ATTENDANCE_TAX'] = int(members_amount * project.client.tax_rate)
    data['DETAIL']['ITEM_AMOUNT_ATTENDANCE_ALL'] = members_amount + int(data['DETAIL']['ITEM_AMOUNT_ATTENDANCE_TAX'])
    data['DETAIL']['ITEM_AMOUNT_ALL'] = int(data['DETAIL']['ITEM_AMOUNT_ATTENDANCE_ALL']) + expenses_amount
    data['DETAIL']['ITEM_AMOUNT_ALL_COMMA'] = humanize.intcomma(data['DETAIL']['ITEM_AMOUNT_ALL'])

    project_request.amount = data['DETAIL']['ITEM_AMOUNT_ALL']
    project_request.turnover_amount = members_amount
    project_request.tax_amount = data['DETAIL']['ITEM_AMOUNT_ATTENDANCE_TAX']
    project_request.expenses_amount = expenses_amount

    return data
Esempio n. 14
0
def generate_order_data(company, subcontractor, user, ym):
    """註文書を生成するために使うデータを生成する。

    :param company 発注元会社
    :param subcontractor 発注先
    :param user ログインしているユーザ
    :param ym 対象年月
    :return エクセルのバイナリー
    """
    data = {'DETAIL': {}}
    # 発行年月日
    date = datetime.date.today()
    data['DETAIL']['PUBLISH_DATE'] = u"%s年%02d月%02d日" % (date.year, date.month, date.day)
    # 下請け会社名
    data['DETAIL']['SUBCONTRACTOR_NAME'] = subcontractor.name
    # 委託業務責任者(乙)
    data['DETAIL']['SUBCONTRACTOR_MASTER'] = subcontractor.president
    # 作成者
    salesperson = get_user_profile(user)
    data['DETAIL']['AUTHOR_FIRST_NAME'] = salesperson.first_name if salesperson else ''
    # 会社名
    data['DETAIL']['COMPANY_NAME'] = company.name
    # 本社郵便番号
    data['DETAIL']['POST_CODE'] = common.get_full_postcode(company.post_code)
    # 本社電話番号
    data['DETAIL']['TEL'] = company.tel
    # 代表取締役
    member = company.get_master()
    data['DETAIL']['MASTER'] = u"%s %s" % (member.first_name, member.last_name) if member else ""
    # 本社住所
    data['DETAIL']['ADDRESS1'] = company.address1
    data['DETAIL']['ADDRESS2'] = company.address2
    # 作業期間
    if not ym:
        first_day = common.get_first_day_current_month()
    else:
        first_day = common.get_first_day_from_ym(ym)
    last_day = common.get_last_day_by_month(first_day)
    data['DETAIL']['START_DATE'] = u"%s年%02d月%02d日" % (first_day.year, first_day.month, first_day.day)
    data['DETAIL']['END_DATE'] = u"%s年%02d月%02d日" % (last_day.year, last_day.month, last_day.day)

    members = []
    # 全ての協力社員の注文情報を取得する。
    for member in subcontractor.get_members_by_month(first_day):
        bp_member_info = member.get_bp_member_info(first_day)
        members.append({'ITEM_NAME': member.__unicode__(),  # 協力社員名前
                        'ITEM_COST': humanize.intcomma(member.cost),  # 月額基本料金
                        'ITEM_MIN_HOUR': humanize.intcomma(bp_member_info.min_hours),  # 基準時間(最小値)
                        'ITEM_MAX_HOUR': humanize.intcomma(bp_member_info.max_hours),  # 基準時間(最大値)
                        'ITEM_PLUS_PER_HOUR': humanize.intcomma(bp_member_info.plus_per_hour),  # 超過単価
                        'ITEM_MINUS_PER_HOUR': humanize.intcomma(bp_member_info.minus_per_hour),  # 不足単価
                        })
    data['MEMBERS'] = members

    # 注文情報を追加する
    try:
        order = models.SubcontractorOrder.objects.get(subcontractor=subcontractor,
                                                      year=str(first_day.year),
                                                      month="%02d" % (first_day.month,))
        data['DETAIL']['ORDER_NO'] = order.order_no
        order.updated_user = user
    except ObjectDoesNotExist:
        data['DETAIL']['ORDER_NO'] = get_order_no(user)
        order = models.SubcontractorOrder(subcontractor=subcontractor,
                                          order_no=data['DETAIL']['ORDER_NO'],
                                          year=str(first_day.year),
                                          month="%02d" % (first_day.month,))
        order.created_user = user
    order.save()
    return data
Esempio n. 15
0
def generate_request_heading(company, project, customer_order, year, month,
                             initial):
    first_day = common.get_first_day_from_ym(year + month)
    first_day = project.start_date if project.start_date > first_day else first_day
    last_day = common.get_last_day_from_ym(year + month)
    last_day = project.end_date if project.end_date < last_day else last_day
    data = dict()
    # 代表取締役
    data['MASTER'] = company.president
    # お客様郵便番号
    data['CUSTOMER_POST_CODE'] = common.get_full_postcode(
        project.customer.post_code)
    # お客様住所
    data['CUSTOMER_ADDRESS'] = (project.customer.address1
                                or '') + (project.customer.address2 or '')
    # お客様電話番号
    data['CUSTOMER_TEL'] = project.customer.tel or ''
    # お客様名称
    data['CUSTOMER_COMPANY_NAME'] = project.customer.name
    # 作業期間
    f = '%Y{0}%m{1}%d{2}'
    period_start = first_day.strftime(f).format(*'年月日')
    period_end = last_day.strftime(f).format(*'年月日')
    data['WORK_PERIOD'] = period_start + " ~ " + period_end
    data['WORK_PERIOD_START'] = first_day
    data['WORK_PERIOD_END'] = last_day
    # 注文番号
    if initial and 'order_no' in initial:
        data['ORDER_NO'] = initial.get('order_no')
    else:
        data[
            'ORDER_NO'] = customer_order.order_no if customer_order.order_no else ""
    # 注文日
    data['REQUEST_DATE'] = customer_order.order_date.strftime(
        '%Y/%m/%d') if customer_order.order_date else ""
    # 契約件名
    if initial and 'contract_name' in initial:
        data['CONTRACT_NAME'] = initial.get('contract_name')
    else:
        data['CONTRACT_NAME'] = customer_order.name
    # お支払い期限
    data['REMIT_DATE'] = project.customer.get_pay_date(
        date=first_day).strftime('%Y/%m/%d')
    data['REMIT_DATE_PURE'] = project.customer.get_pay_date(date=first_day)
    # # 請求番号
    # data['REQUEST_NO'] = project.get_next_request_no(year, month)
    # 発行日(対象月の最終日)
    data['PUBLISH_DATE'] = last_day.strftime(f).format(*'年月日')
    data['PUBLISH_DATE_PURE'] = last_day
    # 本社郵便番号
    data['POST_CODE'] = common.get_full_postcode(company.post_code)
    # 本社住所
    data['ADDRESS'] = (company.address1 or '') + (company.address2 or '')
    # 会社名
    data['COMPANY_NAME'] = company.name
    # 本社電話番号
    data['TEL'] = company.tel
    if initial and 'bank_account' in initial:
        bank_account = initial.get('bank_account')
    else:
        bank_account = customer_order.bank_account
    data['BANK_ACCOUNT'] = bank_account
    # 振込先銀行名称
    data['BANK_NAME'] = bank_account.bank.name if bank_account else ""
    # 支店番号
    data['BRANCH_NO'] = bank_account.branch_no if bank_account else ""
    # 支店名称
    data['BRANCH_NAME'] = bank_account.branch_name if bank_account else ""
    # 預金種類
    data['ACCOUNT_TYPE'] = bank_account.get_account_type_display(
    ) if bank_account else ""
    data[
        'ACCOUNT_TYPE_PURE'] = bank_account.account_type if bank_account else ""
    # 口座番号
    data[
        'ACCOUNT_NUMBER'] = bank_account.account_number if bank_account else ""
    # 口座名義人
    data[
        'BANK_ACCOUNT_HOLDER'] = bank_account.account_holder if bank_account else ""

    return data
Esempio n. 16
0
def generate_partner_order_heading(
        company, partner, contract, year, month, publish_date, interval, salesperson,
        project_member=None,
):
    first_day = common.get_first_day_from_ym(year + month)
    last_day = common.get_last_day_by_month(first_day)
    data = dict()
    if project_member is not None:
        project = project_member.project
        member = project_member.member
        start_date = first_day if first_day >= project_member.start_date else project_member.start_date
        end_date = last_day if last_day <= project_member.end_date else project_member.end_date
    else:
        # 一括の場合
        project = contract.project
        member = None
        data['delivery_date'] = contract.delivery_date
        data['project_content'] = contract.project_content
        data['workload'] = contract.workload
        data['project_result'] = contract.project_result
        data['allowance_base'] = contract.get_cost()
        data['allowance_base_tax'] = contract.allowance_base_tax
        data['allowance_base_total'] = contract.allowance_base_total
        start_date = project.start_date
        end_date = project.end_date
    data['publish_date'] = publish_date.strftime('%Y-%m-%d') \
        if isinstance(publish_date, (datetime.date, datetime.datetime)) else publish_date
    data['partner_name'] = partner.name
    data['partner_post_code'] = partner.post_code
    data['partner_address1'] = partner.address1
    data['partner_address2'] = partner.address2
    data['partner_tel'] = partner.tel
    data['partner_fax'] = partner.fax
    # 本社情報
    data['company_name'] = company.name
    data['company_tel'] = company.tel
    data['company_address1'] = company.address1
    data['company_address2'] = company.address2
    # 案件情報
    data['project_name'] = project.name
    data['start_date'] = start_date
    data['end_date'] = end_date
    data['master'] = company.president
    data['middleman'] = salesperson.full_name if salesperson else None
    data['partner_master'] = partner.president
    data['partner_middleman'] = partner.middleman
    data['member_name'] = member.full_name if member else None
    data['location'] = project.address if project.address else constants.LABEL_BP_ORDER_DEFAULT_LOCATION
    # 精算情報
    data['is_hourly_pay'] = contract.is_hourly_pay
    if project_member is not None:
        data['is_fixed_cost'] = contract.is_fixed_cost
        data['is_show_formula'] = contract.is_show_formula
        data['calculate_type_comment'] = contract.get_calculate_type_comment()
        data['allowance_base'] = contract.get_cost() * interval
        data['allowance_base_memo'] = contract.allowance_base_memo
        if interval > 1:
            data['allowance_base_memo'] = "基本料金:¥{}円  ({}税金抜き)".format(
                humanize.intcomma(data['allowance_base']),
                '固定、' if contract.is_fixed_cost else '',
            )
        data['allowance_time_min'] = contract.get_allowance_time_min(year, month)
        data['allowance_time_max'] = contract.allowance_time_max
        data['allowance_time_memo'] = contract.get_allowance_time_memo(year, month)
        data['allowance_overtime'] = contract.allowance_overtime
        data['allowance_overtime_memo'] = contract.allowance_overtime_memo
        data['allowance_absenteeism'] = contract.get_allowance_absenteeism(year, month)
        data['allowance_absenteeism_memo'] = contract.get_allowance_absenteeism_memo(year, month)
        data['allowance_other'] = contract.allowance_other
        data['allowance_other_memo'] = contract.get_allowance_other_memo()
        data['delivery_properties_comment'] = Config.get_bp_order_delivery_properties()
        data['payment_condition_comments'] = Config.get_bp_order_payment_condition()
        data['contract_items_comments'] = Config.get_bp_order_contract_items()
    data['comment'] = contract.comment
    return data