示例#1
0
文件: views.py 项目: ajmal017/backend
    def get(self, request):
        """
        Only admin user is allowed to access the private Bse info Tiff file.

        :param request: the email_id of the pertinent user is received from this.
        :return: send the generated tiff file
        """

        # makes sure that only superuser can access this file.

        if request.user.is_superuser:
            exch_backend = helpers.get_exchange_vendor_helper(
            ).get_backend_instance()
            if exch_backend:
                user = pr_models.User.objects.get(
                    email=request.GET.get('email'))
                if is_investable(user) and user.signature != "":
                    result = exch_backend.upload_aof_image(user.id)
                    if result == constants.RETURN_CODE_SUCCESS:
                        return HttpResponse(constants.SUCCESS, status=200)
            # file doesn't exist because investor vault is incomplete.
            return HttpResponse(payment_constant.CANNOT_GENERATE_FILE,
                                status=404)
        else:
            # non-admin is trying to access the file. Prevent access.
            return HttpResponse(constants.FORBIDDEN_ERROR, status=403)
示例#2
0
文件: views.py 项目: ajmal017/backend
    def get(self, request):
        """
        Only admin user is allowed to access the private KYC PDF.

        :param request: the email_id of the pertinent user is received from this.
        :return: send the generated kyc pdf
        """

        # makes sure that only superuser can access this file.

        if request.user.is_superuser:
            user = pr_models.User.objects.get(email=request.GET.get('email'))
            if is_investable(user) and user.signature != "":
                output_file = kyc_pdf_generator.generate_kyc_pdf_new(
                    user.id).split('/')[-1]
                prefix = 'webapp'
                my_file_path = prefix + constants.STATIC + output_file
                my_file = open(my_file_path, "rb")
                content_type = 'application/pdf'
                response = HttpResponse(my_file,
                                        content_type=content_type,
                                        status=200)
                response[
                    'Content-Disposition'] = 'attachment;filename=%s' % str(
                        user.id) + '_kyc.pdf'
                my_file.close()
                return response  # contains the pdf of the pertinent user
            else:
                # file doesn't exist because investor vault is incomplete.
                return HttpResponse(payment_constant.USER_KYC_CANNOT_GENERATE,
                                    status=404)
        else:
            # non-admin is trying to access the file. Prevent access.
            return HttpResponse(constants.FORBIDDEN_ERROR, status=403)
示例#3
0
文件: views.py 项目: ajmal017/backend
    def get(self, request):
        """
        Only admin user is allowed to access the private bank mandate pipe file.

        :param request: the email_id of the pertinent user is received from this.
        :return: send the generated pipe file
        """

        # makes sure that only superuser can access this file.

        if request.user.is_superuser:
            order_detail = OrderDetail.objects.get(
                order_id=request.GET.get('order_id'))
            if order_detail.is_lumpsum == False:
                fund_order_item = order_detail.fund_order_items.first()
                if fund_order_item:
                    order_detail = OrderDetail.objects.filter(
                        is_lumpsum=True,
                        fund_order_items__portfolio_item=fund_order_item.
                        portfolio_item).first()
            if is_investable(order_detail.user):
                exch_backend = helpers.get_exchange_vendor_helper(
                ).get_backend_instance()
                order_vendor = order_detail.vendor
                if order_vendor:
                    exch_backend = helpers.get_exchange_vendor_helper(
                    ).get_backend_instance(order_vendor.name)
                if exch_backend:
                    mandate_helper_instance = bank_mandate_helper.BankMandateHelper(
                    )
                    is_mandate_required, bank_mandate = mandate_helper_instance.is_new_mandate_required(
                        order_detail.user, order_detail, True)
                    status, output_file = exch_backend.generate_bank_mandate_registration(
                        order_detail.user.id, bank_mandate)
                    if status == constants.RETURN_CODE_SUCCESS:
                        if output_file:
                            output_file = output_file.split('/')[-1]
                            prefix = 'webapp'
                            my_file_path = prefix + constants.STATIC + output_file
                            my_file = open(my_file_path, "rb")
                            content_type = 'text/plain'
                            response = HttpResponse(my_file,
                                                    content_type=content_type,
                                                    status=200)
                            response[
                                'Content-Disposition'] = 'attachment;filename=%s' % str(
                                    order_detail.id) + '_order.txt'
                            my_file.close()
                            return response  # contains the pipe file of the pertinent user
                        else:
                            return HttpResponse(constants.SUCCESS, status=200)
            # file doesn't exist because investor vault is incomplete.
            return HttpResponse(payment_constant.CANNOT_GENERATE_FILE,
                                status=404)
        else:
            # non-admin is trying to access the file. Prevent access.
            return HttpResponse(constants.FORBIDDEN_ERROR, status=403)
示例#4
0
    def generate_mandate_pdf(self, bank_mandate_instance):
        if not bank_mandate_instance:
            return None, "Invalid Mandate"

        output_file = None
        error_str = None
        mandate_vendor = bank_mandate_instance.vendor
        exch_backend = helpers.get_exchange_vendor_helper(
        ).get_backend_instance(mandate_vendor.name)
        if exch_backend:
            user = bank_mandate_instance.user
            if utils.is_investable(user) and user.signature != "":
                output_file, error_str = exch_backend.generate_bank_mandate(
                    user.id, bank_mandate_instance)

        return output_file, error_str
示例#5
0
文件: views.py 项目: ajmal017/backend
    def get(self, user_list):
        """
        :param request: the email_id of the pertinent user is received from this.
        :return: send the generated pipe file
        """
        exch_backend = helpers.get_exchange_vendor_helper(
        ).get_backend_instance()
        if exch_backend:
            not_set = []
            for i in user_list:
                user = pr_models.User.objects.get(id=i)
                if not is_investable(user):
                    not_set.append(user.id)
            if len(not_set) > 0:
                return not_set

            return exch_backend.bulk_create_customer(user_list)
示例#6
0
文件: views.py 项目: ajmal017/backend
    def get(self, request):
        """
        Only admin user is allowed to access the private Bse info Tiff file.

        :param request: the email_id of the pertinent user is received from this.
        :return: send the generated tiff file
        """

        # makes sure that only superuser can access this file.

        if request.user.is_superuser:
            exch_backend = helpers.get_exchange_vendor_helper(
            ).get_backend_instance()
            if exch_backend:
                user = pr_models.User.objects.get(
                    email=request.GET.get('email'))
                if is_investable(user) and user.signature != "":
                    output_file = exch_backend.generate_aof_image(
                        user.id).split('/')[-1]
                    prefix = 'webapp'
                    my_file_path = prefix + constants.STATIC + output_file
                    my_file = open(my_file_path, "rb")
                    content_type = 'image/tiff'
                    try:
                        invest_info = pr_models.InvestorInfo.objects.get(
                            user=user)
                        download_name = invest_info.pan_number
                    except:
                        download_name = user.id
                    response = HttpResponse(my_file,
                                            content_type=content_type,
                                            status=200)
                    response[
                        'Content-Disposition'] = 'attachment;filename=%s' % download_name + ".tiff"
                    my_file.close()
                    return response  # contains the pdf of the pertinent user
                else:
                    # file doesn't exist because investor vault is incomplete.
                    return HttpResponse(payment_constant.CANNOT_GENERATE_FILE,
                                        status=404)
        else:
            # non-admin is trying to access the file. Prevent access.
            return HttpResponse(constants.FORBIDDEN_ERROR, status=403)
示例#7
0
文件: views.py 项目: ajmal017/backend
    def get(self, request):
        """
        Only admin user is allowed to access the private Bse redeem pipe file.

        :param request: the email_id of the pertinent user is received from this.
        :return: send the generated pipe file
        """

        # makes sure that only superuser can access this file.

        if request.user.is_superuser:
            group_redeem_detail = GroupedRedeemDetail.objects.get(
                id=request.GET.get('group_redeem_id'))
            if is_investable(group_redeem_detail.user):
                exch_backend = helpers.get_exchange_vendor_helper(
                ).get_backend_instance()
                if exch_backend:
                    error_status, output_file = exch_backend.create_redeem(
                        group_redeem_detail.user.id, group_redeem_detail)
                    if error_status == constants.RETURN_CODE_SUCCESS:
                        if output_file:
                            output_file = output_file.split('/')[-1]
                            prefix = 'webapp'
                            my_file_path = prefix + constants.STATIC + output_file
                            my_file = open(my_file_path, "rb")
                            content_type = 'text/plain'
                            response = HttpResponse(my_file,
                                                    content_type=content_type,
                                                    status=200)
                            response[
                                'Content-Disposition'] = 'attachment;filename=%s' % str(
                                    group_redeem_detail.id) + 'redeem.txt'
                            my_file.close()
                            return response  # contains the pdf of the pertinent user
            # file doesn't exist because investor vault is incomplete.
            return HttpResponse(payment_constant.CANNOT_GENERATE_FILE,
                                status=404)
        else:
            # non-admin is trying to access the file. Prevent access.
            return HttpResponse(constants.FORBIDDEN_ERROR, status=403)
示例#8
0
def generate_client_fatca_pipe(user_list):
    """
    This function generates a pipe separated file for bulk order entry.
    
    :param user_list: list of users to be bulk uploaded.
    :return: url of the generated pipe separated file of the bulk order entry
    """

    base_dir = os.path.dirname(os.path.dirname(__file__)).replace('/webapp/apps/external_api', '')
    output_path = base_dir + '/webapp/static/'
    outfile = open(output_path+"fatca_pipe.txt", "w")
    
    def get_pan_idenitfication_type():
        return "C"
    
    def create_user_dict(user_id):
        """
    
        :return:
        """
        user = profile_models.User.objects.get(id=user_id)
        investor = profile_models.InvestorInfo.objects.get(user=user)
        contact = profile_models.ContactInfo.objects.get(user=user)
    
        bse_dict = OrderedDict([("CLIENT PAN", investor.pan_number),
                               ("CLIENT PAN EXEMPT", None),
                               ("CLIENT APPNAME1", investor.applicant_name),
                               ("CLIENT DOB", investor.dob.strftime("%m/%d/%Y")),
                               ("CLIENT FATHERHUSBAND", None),
                               ("CLIENT SP NAME", None),
                               ("CLIENT TAXSTATUS", cons.CLIENT_TAX_STATUS_MAP["Individual"]),
                               ("CLIENT DATA SRC", cons.FATCA_DATA_SRC_E),
                               ("CLIENT ADDR TYPE", get_bse_address_type_code(contact.communication_address_type)),
                               ("CLIENT POB", investor.place_of_birth),
                               ("CLIENT COB", get_bse_country_code_fatca(investor.country_of_birth)),
                               ("CLIENT TAXRES", get_bse_country_code_fatca("India")),
                               ("CLIENT TAX PIN", investor.pan_number),
                               ("CLIENT TAX PIN TYPE", get_pan_idenitfication_type()),
                               ("CLIENT TAXRES2", None),
                               ("CLIENT TAX PIN2", None),
                               ("CLIENT TAX PIN TYPE2", None),
                               ("CLIENT TAXRES3", None),
                               ("CLIENT TAX PIN3", None),
                               ("CLIENT TAX PIN TYPE3", None),
                               ("CLIENT TAXRES4", None),
                               ("CLIENT TAX PIN4", None),
                               ("CLIENT TAX PIN TYPE4", None),
                               ("CLIENT SRC WEALTH", get_bse_srcwealth_code(investor.occupation_type)),
                               ("CLIENT CORP SERVS", None),
                               ("CLIENT INC SLAB", get_bse_income_code(investor.income)),
                               ("CLIENT NET WORTH", None),
                               ("CLIENT NET WORTH DATE", None),
                               ("CLIENT PEP", get_bse_pep_code(investor.political_exposure)),
                               ("CLIENT OCCUPATIONCODE", get_bse_occupation_code(investor.occupation_type)),
                               ("CLIENT OCCUPATIONType", get_bse_occupation_type(investor.occupation_type)),
                               ("CLIENT EXMPT CODE", None),
                               ("CLIENT FFI_DRNFE", None),
                               ("CLIENT GIIN_NO", None),
                               ("CLIENT SPR_ENTITY", None),
                               ("CLIENT GIIN_NA", None),
                               ("CLIENT GIIN_EXEMC", None),
                               ("CLIENT NFFE_CATG", None),
                               ("CLIENT ACT_NFE_SC", None),
                               ("CLIENT NATURE_BUS", None),
                               ("CLIENT REL_LISTED", None),
                               ("CLIENT EXCH_NAME", cons.EXCHNAME_BSE),
                               ("CLIENT UBO_APPL", "N"),
                               ("CLIENT UBO_COUNT", None),
                               ("CLIENT UBO_NAME", None),
                               ("CLIENT UBO_PAN", None),
                               ("CLIENT UBO_NATION", None),
                               ("CLIENT UBO_ADD1", None),
                               ("CLIENT UBO_ADD2", None),
                               ("CLIENT UBO_ADD3", None),
                               ("CLIENT UBO_CITY", None),
                               ("CLIENT UBO_PIN", None),
                               ("CLIENT UBO_STATE", None),
                               ("CLIENT UBO_CNTRY", None),
                               ("CLIENT UBO_ADD_TY", None),
                               ("CLIENT UBO_CTR", None),
                               ("CLIENT UBO_TIN", None),
                               ("CLIENT UBO_ID_TY", None),
                               ("CLIENT UBO_COB", None),
                               ("CLIENT UBO_DOB", None),
                               ("CLIENT UBO_GENDER", None),
                               ("CLIENT UBO_FR_NAM", None),
                               ("CLIENT UBO_OCC", None),
                               ("CLIENT UBO_OCC_TY", None),
                               ("CLIENT UBO_TEL", None),
                               ("CLIENT UBO_MOBILE", None),
                               ("CLIENT UBO_CODE", None),
                               ("CLIENT UBO_HOL_PC", None),
                               ("CLIENT SDF_FLAG", None),
                               ("CLIENT UBO_DF", "N"),
                               ("CLIENT AADHAAR_RP", None),
                               ("CLIENT NEW_CHANGE", "N"),
                               ("CLIENT LOG_NAME", user.finaskus_id + ":" + investor.modified_at.strftime("%d/%m/%Y")),
                               ("CLIENT FILLER1", None),
                               ("CLIENT FILLER2", None)
                                ])

        for k, v in bse_dict.items():
            if v is None:
                bse_dict[k] = ''
            if type(v) != "<class 'str'>":
                bse_dict[k] = str(bse_dict[k])

        return bse_dict

    not_set = []
    for i in user_list:
        user = profile_models.User.objects.get(id=i)
        if not is_investable(user):
            not_set.append(user.id)
        else:
            investor = profile_models.InvestorInfo.objects.get(user=user)
            if investor and investor.other_tax_payer == True:
                not_set.append(user.id)
    if len(not_set) > 0:
        return not_set
    else:
        for i in range(len(user_list)):
            bulk_order_dict = create_user_dict(user_list[i])
            outfile.write("|".join(bulk_order_dict.values()))
            if i < len(user_list)-1:
                outfile.write("\r")
            bulk_order_dict.clear()
        outfile.close()

        return "webapp/static/fatca_pipe.txt"
示例#9
0
文件: admin.py 项目: ajmal017/backend
 def vault_completed(self, obj):
     """
     returns vault completion  detail alongside each item
     """
     return is_investable(obj.user)