Example #1
0
    def from_dic(dic, user):
        haghighi_max_loan_amount = config.objects.get(
            pk='HAGHIGHI_MAX_LOAN_AMOUNT')
        hoghooghi_max_loan_amount = config.objects.get(
            pk='HOGHOOGHI_MAX_LOAN_AMOUNT')
        customer = customer_repository.find_customer(dic['cif'])
        if len(customer) == 0:
            raise ValidationException("Customer does not exist")

        deposit = deposit_repository.find_deposit(dic['cif'],
                                                  dic['deposit_number'])
        if len(deposit) == 0:
            raise ValidationException(
                "Deposit and customer are not compatible")

        amount = int(dic['request_amount'])
        print amount
        if dic['type'] == 'haghighi':
            if amount > int(haghighi_max_loan_amount.value):
                raise ValidationException("Request amount is more than max")

        if dic['type'] == 'hoghooghi':
            if amount > int(hoghooghi_max_loan_amount.value):
                raise ValidationException("Request amount is more than max")

        if customer[0]["F51"] == '0' and dic['type'] == 'hoghooghi':
            raise ValidationException(
                "Customer is enterprise but request is real")

        if customer[0]["F51"] == '1' and dic['type'] == 'haghighi':
            raise ValidationException(
                "Customer is real but request is enterprise")

        request = Request(
            type=dic['type'],
            cif=dic['cif'],
            deposit_number=dic['deposit_number'],
            user_id=user.id,
            branch_code=user.profile.branch_code,
            business_part_id=dic['business_part'],
            request_description_id=dic['request_description'],
            has_loan_from_current_bank=dic['has_loan_from_current_bank'] ==
            'True',
            request_amount=dic['request_amount'])

        if dic.get('agent_national_number', None):
            request.agent_id = dic['agent_national_number']

        return request
Example #2
0
    def get(self, request):
        customer_id = request.GET.get('customer_id')
        next_level = request.GET.get('next', None)
        customer = None
        message = None
        if customer_id is not None and customer_id != '':
            try:
                if len(find_customer(customer_id)) == 0:
                    message = 'customer does not exist'
                customer = EnterpriseCustomerInformation.objects.get(
                    pk=customer_id)

            except ObjectDoesNotExist as e:
                print e

        provinces = Province.objects.all()
        towns = Town.objects.filter(province_id=provinces.first().id)
        register_towns = RegisterTown.objects.all()
        company_types = CompanyType.objects.all()
        all_towns = Town.objects.all()
        job_types = JobType.objects.all()
        board_of_directors = BoadOfDirectorRole.objects.all()
        certificate_types = JobCertificateType.objects.filter(type='hoghooghi')

        context = RequestContext(
            request, {
                'customer_type': 'haghighi',
                'customer_info': customer,
                'provinces': provinces,
                'company_types': company_types,
                'register_towns': register_towns,
                'towns': towns,
                'job_types': job_types,
                'certificate_types': certificate_types,
                'customer_id': customer_id,
                'message': message,
                'all_towns': all_towns,
                'board_of_directors': board_of_directors,
                'next_level': next_level
            })

        template = loader.get_template('register_enterprise_customer.html')

        return HttpResponse(template.render(context))
Example #3
0
    def get(self, request):
        customer_id = request.GET.get('customer_id')
        next_level = request.GET.get('next', None)
        customer = None
        message = None
        if customer_id is not None and customer_id != '':
            try:
                if len(find_customer(customer_id)) == 0:
                    message = 'customer does not exist'
                customer = EnterpriseCustomerInformation.objects.get(pk=customer_id)

            except ObjectDoesNotExist as e:
                print e

        provinces = Province.objects.all()
        towns = Town.objects.filter(province_id=provinces.first().id)
        register_towns = RegisterTown.objects.all()
        company_types = CompanyType.objects.all()
        all_towns = Town.objects.all()
        job_types = JobType.objects.all()
        board_of_directors = BoadOfDirectorRole.objects.all()
        certificate_types = JobCertificateType.objects.filter(type='hoghooghi')

        context = RequestContext(request, {'customer_type': 'haghighi',
                                           'customer_info': customer,
                                           'provinces': provinces,
                                           'company_types': company_types,
                                           'register_towns': register_towns,
                                           'towns': towns,
                                           'job_types': job_types,
                                           'certificate_types': certificate_types,
                                           'customer_id': customer_id,
                                           'message': message,
                                           'all_towns': all_towns,
                                           'board_of_directors': board_of_directors,
                                           'next_level': next_level
        })

        template = loader.get_template('register_enterprise_customer.html')

        return HttpResponse(template.render(context))
Example #4
0
    def from_dic(dic, user):
        haghighi_max_loan_amount = config.objects.get(pk='HAGHIGHI_MAX_LOAN_AMOUNT')
        hoghooghi_max_loan_amount = config.objects.get(pk='HOGHOOGHI_MAX_LOAN_AMOUNT')
        customer = customer_repository.find_customer(dic['cif'])
        if len(customer) == 0:
            raise ValidationException("Customer does not exist")

        deposit = deposit_repository.find_deposit(dic['cif'], dic['deposit_number'])
        if len(deposit) == 0:
            raise ValidationException("Deposit and customer are not compatible")

        amount = int(dic['request_amount'])
        print amount
        if dic['type'] == 'haghighi':
            if amount > int(haghighi_max_loan_amount.value):
                raise ValidationException("Request amount is more than max")

        if dic['type'] == 'hoghooghi':
            if amount > int(hoghooghi_max_loan_amount.value):
                raise ValidationException("Request amount is more than max")

        if customer[0]["F51"] == '0' and dic['type'] == 'hoghooghi':
            raise ValidationException("Customer is enterprise but request is real")

        if customer[0]["F51"] == '1' and dic['type'] == 'haghighi':
            raise ValidationException("Customer is real but request is enterprise")

        request = Request(type=dic['type'], cif=dic['cif'], deposit_number=dic['deposit_number'], user_id=user.id,
                          branch_code=user.profile.branch_code,
                          business_part_id=dic['business_part'], request_description_id=dic['request_description'],
                          has_loan_from_current_bank=dic['has_loan_from_current_bank'] == 'True',
                          request_amount=dic['request_amount'])

        if dic.get('agent_national_number', None):
            request.agent_id = dic['agent_national_number']

        return request