Ejemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        print(request.POST)

        # create the user ticket
        user_obj = Profile.objects.get(user=request.user)
        company_obj = Company.objects.get(
            name__iexact=request.POST.get("company"))
        SupportTickets.objects.create(
            user=user_obj,
            title=request.POST.get("title"),
            content=request.POST.get("message"),
            ticket_id=random_string_generator(7),
            affected_company=company_obj,
            slug=random_string_generator(20),
        )

        # send mail to system core..
        sg = SendGridAPIClient(email_settings.SENDGRID_API_KEY)
        message = Mail(
            from_email=email_settings.DEFAULT_FROM_EMAIL,
            to_emails=email_settings.SUPPORT_EMAIL,
            subject="A New Ticket Was Opened!",
            html_content=
            "A support ticket has been opened please confirm and attend to all opened tickets."
        )
        sg.send(message)
        return JsonResponse({"message": "Ticket Created Successfully!"})
Ejemplo n.º 2
0
def post_save_user_create_reciever(sender, instance, created, *args, **kwargs):
    if created:
        obj = EmailActivation.objects.create(user=instance,
                                             email=instance.email)
        obj.send_activation()
        Profile.objects.create(user=instance,
                               slug=unique_slug_generator_by_email(instance),
                               token=random_string_generator(45),
                               keycode=random_string_generator(4))
Ejemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        print(request.data)
        data = request.data
        user_profile_obj = Profile.objects.get(user=self.request.user)
        thisBorrower = Borrower.objects.get(user=user_profile_obj)

        message = data.get('message')
        amount = data.get('amount')

        LoanRequests.objects.create(
            borrower=thisBorrower,
            amount=amount,
            request_status='Still Processing',
            duration_figure=int(data.get('durationFigure')),
            duration=data.get('durationPeriod'),
            repayment_interval=data.get('repaymentInterval'),
            slug=slugify("{borrower}-{amount}-{primaryKey}".format(
                borrower=thisBorrower,
                amount=data.get('amount'),
                primaryKey=random_string_generator(6))))
        # Send an Email Saying Loan Application Was Made By A User
        html_ = "The User ({loanUser}), just applied for a loan, validate user account and process loan application".format(
            loanUser=thisBorrower)
        subject = 'New Loan Application From {loanUser}'.format(
            loanUser=thisBorrower)
        from_email = email_settings.EMAIL_HOST_USER
        recipient_list = ['*****@*****.**']

        from django.core.mail import EmailMessage
        message = EmailMessage(subject, html_, from_email, recipient_list)
        message.fail_silently = False
        message.send()
        return Response({'message': 'Loan Request Application Was Successful'},
                        status=201)
Ejemplo n.º 4
0
 def post(self, *args, **kwargs):
     bank_inst = BankCode.objects.get(
         name__exact=self.request.POST.get('bank'))
     country_inst = Country(code=self.request.POST.get('country'))
     print(country_inst, country_inst.name)
     Borrower.objects.create(
         registered_to=self.get_object(),
         first_name=self.request.POST.get('firstName'),
         last_name=self.request.POST.get('lastName'),
         gender=self.request.POST.get('gender'),
         address=self.request.POST.get('address'),
         lga=self.request.POST.get('lga'),
         state=self.request.POST.get('state'),
         country=country_inst,
         country_text=country_inst.name,
         title=self.request.POST.get('title'),
         phone=self.request.POST.get('phone'),
         land_line=self.request.POST.get('landPhone'),
         business_name=self.request.POST.get('businessName'),
         working_status=self.request.POST.get('workingStatus'),
         email=self.request.POST.get('email'),
         unique_identifier=self.request.POST.get('unique_identifier'),
         bank=bank_inst,
         bank_text=bank_inst.name,
         account_number=self.request.POST.get('accountNumber'),
         bvn=self.request.POST.get('bvn'),
         date_of_birth=self.request.POST.get('dateOfBirth'),
         slug=slugify(
             "{firstName}-{lastName}-{company}-{primaryKey}".format(
                 firstName=self.request.POST.get('firstName'),
                 lastName=self.request.POST.get('lastName'),
                 company=self.get_object(),
                 primaryKey=random_string_generator(4))))
     return JsonResponse({'message': 'Account created successfully!'})
Ejemplo n.º 5
0
    def post(self, request, *args, **kwargs):
        branch_instance = Branch.objects.create(
            branch_custom=request.POST['branchCode'],
            address=request.POST['branchAddress'],
            slug=random_string_generator())

        company_instance = self.get_object()
        company_instance.name = request.POST['companyName']
        if request.POST['companyEmail']:
            company_instance.email = request.POST['companyEmail']
        else:
            company_instance.email = self.get_object(
            ).user.user.email  # .user.user.email
        company_instance.branch = branch_instance
        company_instance.slug = "{name}-{randstr}".format(
            name=slugify(request.POST['companyName']),
            randstr=random_string_generator(size=4))
        company_instance.save()
        company_instance.user.working_for.add(company_instance)

        payload = {"success": True}
        return JsonResponse(payload)
Ejemplo n.º 6
0
    def post(self, *args, **kwargs):
        print(self.request.POST)
        bank_inst = BankCode.objects.get(name__exact=self.request.POST.get('bank'))
        print(bank_inst)
        country_inst = Country(code=self.request.POST.get('country'))
        print(country_inst, country_inst.name)
        company = Company.objects.get(name="Amju")
        print(company)
        borrower_instance = Borrower.objects.get(user=self.get_object())
        borrower_instance.registered_to = company
        borrower_instance.first_name = self.request.POST.get('firstName')
        borrower_instance.last_name = self.request.POST.get('lastName')
        borrower_instance.phone = self.request.POST.get('landPhone')
        borrower_instance.gender = self.request.POST.get('gender')
        borrower_instance.address = self.request.POST.get('address')
        borrower_instance.lga = self.request.POST.get('lga')
        borrower_instance.state = self.request.POST.get('state')
        borrower_instance.country = country_inst
        borrower_instance.title = self.request.POST.get('title')
        borrower_instance.land_line = self.request.POST.get('landPhone')
        borrower_instance.business_name = self.request.POST.get('businessName')
        borrower_instance.working_status = self.request.POST.get('workingStatus')
        borrower_instance.unique_identifier = self.request.POST.get('unique_identifier')
        borrower_instance.bank = bank_inst
        borrower_instance.account_number = self.request.POST.get('accountNumber')
        borrower_instance.bvn = self.request.POST.get('bvn')
        borrower_instance.card_number = self.request.POST.get('cardNumber')
        borrower_instance.expiry_month = self.request.POST.get('expiryMonth')
        borrower_instance.expiry_year = self.request.POST.get('expiryYear')
        borrower_instance.cvv = self.request.POST.get('cvv')
        borrower_instance.date_of_birth = self.request.POST.get('dateOfBirth')
        borrower_instance.slug = slugify("{firstName}-{lastName}-{company}-{primaryKey}".format(
            firstName=self.request.POST.get('firstName'), lastName=self.request.POST.get('lastName'),
            company=self.get_object(), primaryKey=random_string_generator(4)
        ))
        borrower_instance.save()

        thisUser = Profile.objects.get(user=self.request.user)
        thisUser.phone = self.request.POST.get('landPhone')
        thisUser.save()

        return JsonResponse({'message': 'Account completed successfully!'})
Ejemplo n.º 7
0
    def post(self, *args, **kwargs):
        number_of_repayment_fig = self.request.POST.get(
            "repaymentIntervalFigure")
        number_of_repayment_period = self.request.POST.get(
            "repaymentIntervalPeriod")
        repayment_span = "{figure} {period}".format(
            figure=number_of_repayment_fig, period=number_of_repayment_period)
        loan_key_value = random_string_generator(9)

        profile_inst = Profile.objects.get(user__exact=self.request.user)
        borrower_inst = Borrower.objects.get(
            slug__iexact=self.request.POST.get("borrower"))
        loan_inst = LoanType.objects.get(
            package__name__exact=self.request.POST.get("loanType"))
        loan_collection_type = ModeOfRepayments.objects.get(
            package__name__exact=self.request.POST.get("loanCollectionType"))

        release_date = datetime.strptime(self.request.POST.get('releaseDate'),
                                         '%Y-%m-%d')

        loan_slug = slugify("{loanType}-{accountOfficer}-{primaryKey}".format(
            loanType=loan_inst,
            accountOfficer=profile_inst,
            primaryKey=random_string_generator(6)))

        if secondWordExtract(repayment_span) == "Months":
            collection_date = release_date + relativedelta(months=1)
            end_date = release_date + relativedelta(
                months=int(digitExtract(repayment_span)))
            print(release_date, collection_date, end_date)
        elif secondWordExtract(repayment_span) == "Years":
            collection_date = release_date + relativedelta(years=1)
            end_date = release_date + relativedelta(
                years=int(digitExtract(repayment_span)))
        elif secondWordExtract(repayment_span) == "Weeks":
            collection_date = release_date + relativedelta(weeks=1)
            end_date = release_date + relativedelta(
                weeks=int(digitExtract(repayment_span)))
        else:
            collection_date = release_date + relativedelta(days=1)
            end_date = release_date + relativedelta(
                days=int(digitExtract(repayment_span)))

        Loan.objects.create(
            account_officer=profile_inst,
            company=self.get_object(),
            borrower=borrower_inst,
            loan_type=loan_inst,
            loan_key=loan_key_value,
            principal_amount=self.request.POST.get('amount'),
            interest=self.request.POST.get('interestFigure'),
            interest_period=self.request.POST.get('interestPeriod'),
            loan_duration_circle=self.request.POST.get('durationPeriod'),
            loan_duration_circle_figure=self.request.POST.get(
                'durationFigure'),
            repayment_circle=self.request.POST.get('repaymentInterval'),
            number_repayments=repayment_span,
            collection_date=collection_date,
            release_date=release_date,
            end_date=end_date,
            processing_fee=self.request.POST.get('processingFee'),
            insurance=self.request.POST.get('insuranceFee'),
            balance_due="Modify/Change Loan",
            mode_of_repayments=loan_collection_type,
            slug=loan_slug,
        )

        # Send an Email Saying Loan Application Was Made By A User
        html_ = "Your loan request have been approved by AMJU UNIQUE MFB, you would be sent RRR form or OTP verification for final confirmation before funds can be disbursed, Please bear in mind, we would remove our loan processing and insurance fee alongside."
        subject = 'Loan Request Notice From AMJU'
        from_email = email_settings.EMAIL_HOST_USER
        recipient_list = [borrower_inst.email]

        from django.core.mail import EmailMessage
        message = EmailMessage(subject, html_, from_email, recipient_list)
        message.fail_silently = False
        message.send()

        base_url = getattr(settings, 'BASE_URL',
                           'https://loans.amjuuniquemfbng.com')

        if str(loan_collection_type) == "Remita Direct Debit":
            urlpath = reverse('loans-url:loan-standing-order-create',
                              kwargs={
                                  'slug': self.get_object().slug,
                                  'loan_slug': loan_slug,
                                  'loan_key': loan_key_value
                              })
            finalpath = "{base}{path}".format(base=base_url, path=urlpath)
            print(finalpath)
            loan_data = {
                'companySlug': self.get_object().slug,
                'loanSlug': loan_slug,
                'loanKey': loan_key_value
            }
        elif str(loan_collection_type) == "Data Referencing":
            urlpath = ""
            finalpath = ""
            loan_data = ""
        elif str(loan_collection_type) == "Paystack Partial Debit":
            urlpath = ""
            finalpath = ""
            loan_data = ""
        return JsonResponse({
            'message': 'Submitted For Processing',
            'urlpath': finalpath,
            'loanKey': loan_key_value,
            'loan_data': loan_data
        })