def cybersource(self, request, tl, one, two, module, extra, prog):

        # Force users to pay for non-optional stuffs
        user = request.user

        iac = IndividualAccountingController(self.program, request.user)
        context = {}
        context['module'] = self
        context['one'] = one
        context['two'] = two
        context['tl']  = tl
        context['user'] = user
        context['contact_email'] = self.program.director_email
        context['invoice_id'] = iac.get_id()
        context['identifier'] = iac.get_identifier()
        payment_type = iac.default_payments_lineitemtype()
        sibling_type = iac.default_siblingdiscount_lineitemtype()
        grant_type = iac.default_finaid_lineitemtype()
        context['itemizedcosts'] = iac.get_transfers().exclude(line_item__in=[payment_type, sibling_type, grant_type]).order_by('-line_item__required')
        context['itemizedcosttotal'] = iac.amount_due()
        context['subtotal'] = iac.amount_requested()
        context['financial_aid'] = iac.amount_finaid()
        context['sibling_discount'] = iac.amount_siblingdiscount()
        context['amount_paid'] = iac.amount_paid()
        context['result'] = request.GET.get("result")
        context['post_url'] = settings.CYBERSOURCE_CONFIG['post_url']
        context['merchant_id'] = settings.CYBERSOURCE_CONFIG['merchant_id']

        if (not context['post_url']) or (not context['merchant_id']):
            raise ESPError("The Cybersource module is not configured")

        return render_to_response(self.baseDir() + 'cardpay.html', request, context)
    def cybersource(self, request, tl, one, two, module, extra, prog):

        # Force users to pay for non-optional stuffs
        user = request.user

        iac = IndividualAccountingController(self.program, request.user)
        context = {}
        context['module'] = self
        context['one'] = one
        context['two'] = two
        context['tl'] = tl
        context['user'] = user
        context['contact_email'] = self.program.director_email
        context['invoice_id'] = iac.get_id()
        context['identifier'] = iac.get_identifier()
        payment_type = iac.default_payments_lineitemtype()
        sibling_type = iac.default_siblingdiscount_lineitemtype()
        grant_type = iac.default_finaid_lineitemtype()
        context['itemizedcosts'] = iac.get_transfers().exclude(
            line_item__in=[payment_type, sibling_type, grant_type]).order_by(
                '-line_item__required')
        context['itemizedcosttotal'] = iac.amount_due()
        context['subtotal'] = iac.amount_requested()
        context['financial_aid'] = iac.amount_finaid()
        context['sibling_discount'] = iac.amount_siblingdiscount()
        context['amount_paid'] = iac.amount_paid()
        context['result'] = request.GET.get("result")
        context['post_url'] = settings.CYBERSOURCE_CONFIG['post_url']
        context['merchant_id'] = settings.CYBERSOURCE_CONFIG['merchant_id']

        if (not context['post_url']) or (not context['merchant_id']):
            raise ESPError("The Cybersource module is not configured")

        return render_to_response(self.baseDir() + 'cardpay.html', request,
                                  context)
Пример #3
0
    def accounting(self, request, tl, one, two, module, extra, prog):
        '''Lists accounting for a student.

        Defaults to the current user, but can take the user ID in the extra
        argument instead.'''

        if extra:
            user = ESPUser.objects.get(id=extra)
        else:
            user = request.user

        iac = IndividualAccountingController(prog, user)
        classified_transfers = [{
            'transfer': t,
            'type': iac.classify_transfer(t)
        } for t in iac.get_transfers().select_related('line_item')]
        context = {
            'target_user': user,
            'transfers': classified_transfers,
            'identifier': iac.get_identifier(),
            'grant': iac.latest_finaid_grant(),
        }
        if iac.transfers_to_program_exist():
            context['transfers_exist'] = True
            context['requested'] = iac.amount_requested(ensure_required=False)
            context['finaid'] = iac.amount_finaid()
            context['siblingdiscount'] = iac.amount_siblingdiscount()
            context['paid'] = iac.amount_paid()
            context['due'] = iac.amount_due()
        return render_to_response(self.baseDir() + 'accounting.html', request,
                                  context)
    def payonline(self, request, tl, one, two, module, extra, prog):

        user = ESPUser(request.user)

        iac = IndividualAccountingController(self.program, request.user)
        context = {}
        context['module'] = self
        context['one'] = one
        context['two'] = two
        context['tl'] = tl
        context['user'] = user
        context['invoice_id'] = iac.get_id()
        context['identifier'] = iac.get_identifier()
        payment_type = iac.default_payments_lineitemtype()
        sibling_type = iac.default_siblingdiscount_lineitemtype()
        grant_type = iac.default_finaid_lineitemtype()
        context['itemizedcosts'] = iac.get_transfers().exclude(
            line_item__in=[payment_type, sibling_type, grant_type]).order_by(
                '-line_item__required')
        context['itemizedcosttotal'] = iac.amount_due()
        context['subtotal'] = iac.amount_requested()
        context['financial_aid'] = iac.amount_finaid()
        context['sibling_discount'] = iac.amount_siblingdiscount()
        context['amount_paid'] = iac.amount_paid()

        if 'HTTP_HOST' in request.META:
            context['hostname'] = request.META['HTTP_HOST']
        else:
            context['hostname'] = Site.objects.get_current().domain
        context['institution'] = settings.INSTITUTION_NAME
        context['storename'] = self.store_id
        context['support_email'] = settings.DEFAULT_EMAIL_ADDRESSES['support']

        return render_to_response(self.baseDir() + 'cardpay.html', request,
                                  context)
    def paynow_cybersource(self, request, tl, one, two, module, extra, prog):

        # Force users to pay for non-optional stuffs
        user = ESPUser(request.user)

        iac = IndividualAccountingController(self.program, request.user)
        context = {}
        context['module'] = self
        context['one'] = one
        context['two'] = two
        context['tl'] = tl
        context['user'] = user
        context['invoice_id'] = iac.get_id()
        context['identifier'] = iac.get_identifier()
        payment_type = iac.default_payments_lineitemtype()
        sibling_type = iac.default_siblingdiscount_lineitemtype()
        grant_type = iac.default_finaid_lineitemtype()
        context['itemizedcosts'] = iac.get_transfers().exclude(
            line_item__in=[payment_type, sibling_type, grant_type]).order_by(
                '-line_item__required')
        context['itemizedcosttotal'] = iac.amount_due()
        context['subtotal'] = iac.amount_requested()
        context['financial_aid'] = iac.amount_finaid()
        context['sibling_discount'] = iac.amount_siblingdiscount()
        context['amount_paid'] = iac.amount_paid()

        return render_to_response(self.baseDir() + 'cardpay.html', request,
                                  context)
    def payonline(self, request, tl, one, two, module, extra, prog):

        #   Check that the user has completed all required modules so that they
        #   are "finished" registering for the program.  (In other words, they
        #   should be registered for at least one class, and filled out other
        #   required forms, before paying by credit card.)
        modules = prog.getModules(request.user, tl)
        completedAll = True
        for module in modules:
            if not module.isCompleted() and module.required:
                completedAll = False
        if not completedAll and not request.user.isAdmin(prog):
            raise ESPError("Please go back and ensure that you have completed all required steps of registration before paying by credit card.", log=False)

        #   Check for setup of module.  This is also required to initialize settings.
        self.check_setup()

        user = request.user

        iac = IndividualAccountingController(self.program, request.user)
        context = {}
        context['module'] = self
        context['program'] = prog
        context['user'] = user
        context['invoice_id'] = iac.get_id()
        context['identifier'] = iac.get_identifier()
        payment_type = iac.default_payments_lineitemtype()
        sibling_type = iac.default_siblingdiscount_lineitemtype()
        grant_type = iac.default_finaid_lineitemtype()
        offer_donation = self.settings['offer_donation']
        donate_type = iac.get_lineitemtypes().get(text=self.settings['donation_text']) if offer_donation else None
        context['itemizedcosts'] = iac.get_transfers().exclude(line_item__in=filter(None, [payment_type, sibling_type, grant_type, donate_type])).order_by('-line_item__required')
        context['itemizedcosttotal'] = iac.amount_due()
        #   This amount should be formatted as an integer in order to be
        #   accepted by Stripe.
        context['totalcost_cents'] = int(context['itemizedcosttotal'] * 100)
        context['subtotal'] = iac.amount_requested()
        context['financial_aid'] = iac.amount_finaid()
        context['sibling_discount'] = iac.amount_siblingdiscount()
        context['amount_paid'] = iac.amount_paid()

        #   Load donation amount separately, since the client-side code needs to know about it separately.
        donation_prefs = iac.get_preferences([donate_type,]) if offer_donation else None
        if donation_prefs:
            context['amount_donation'] = Decimal(donation_prefs[0][2])
            context['has_donation'] = True
        else:
            context['amount_donation'] = Decimal('0.00')
            context['has_donation'] = False
        context['amount_without_donation'] = context['itemizedcosttotal'] - context['amount_donation']

        if 'HTTP_HOST' in request.META:
            context['hostname'] = request.META['HTTP_HOST']
        else:
            context['hostname'] = Site.objects.get_current().domain
        context['institution'] = settings.INSTITUTION_NAME
        context['support_email'] = settings.DEFAULT_EMAIL_ADDRESSES['support']

        return render_to_response(self.baseDir() + 'cardpay.html', request, context)
Пример #7
0
    def paiditems(self, request, tl, one, two, module, extra, prog):

        #   Get a user
        user, found = search_for_user(request)
        if not found:
            return user

        #   Get the optional purchases for that user
        iac = IndividualAccountingController(prog, user)
        context = {}
        context['student'] = user
        context['requireditems'] = iac.get_transfers(required_only=True)
        context['reserveditems'] = iac.get_transfers(optional_only=True)
        context['amount_requested'] = iac.amount_requested()
        context['amount_finaid'] = iac.amount_finaid()
        context['amount_due'] = iac.amount_due()

        return render_to_response(self.baseDir()+'paiditems.html', request, context)
Пример #8
0
    def finalize(self):
        #   Create a transfer for the amount of this grant
        if self.finalized:
            return

        from esp.accounting.controllers import IndividualAccountingController
        iac = IndividualAccountingController(self.program, self.user)
        source_account = iac.default_finaid_account()
        dest_account = iac.default_source_account()
        line_item_type = iac.default_finaid_lineitemtype()

        (transfer, created) = Transfer.objects.get_or_create(
            source=source_account,
            destination=dest_account,
            user=self.user,
            line_item=line_item_type,
            amount_dec=iac.amount_finaid())
        self.finalized = True
        self.save()
        return transfer
Пример #9
0
    def paiditems(self, request, tl, one, two, module, extra, prog):

        #   Get a user
        filterObj, found = UserSearchController().create_filter(
            request, self.program)
        if not found:
            return filterObj
        user = filterObj.getList(ESPUser).distinct()[0]

        #   Get the optional purchases for that user
        iac = IndividualAccountingController(prog, user)
        context = {}
        context['student'] = user
        context['requireditems'] = iac.get_transfers(required_only=True)
        context['reserveditems'] = iac.get_transfers(optional_only=True)
        context['amount_requested'] = iac.amount_requested()
        context['amount_finaid'] = iac.amount_finaid()
        context['amount_due'] = iac.amount_due()

        return render_to_response(self.baseDir() + 'paiditems.html', request,
                                  context)
Пример #10
0
    def finalize(self):
        #   Create a transfer for the amount of this grant
        if self.finalized:
            return

        from esp.accounting.controllers import IndividualAccountingController
        iac = IndividualAccountingController(self.program, self.user)
        source_account = iac.default_finaid_account()
        dest_account = iac.default_source_account()
        line_item_type = iac.default_finaid_lineitemtype()

        (transfer, created) = Transfer.objects.get_or_create(source=source_account, destination=dest_account, user=self.user, line_item=line_item_type, amount_dec=iac.amount_finaid())
        self.finalized = True
        self.save()
        return transfer
Пример #11
0
    def payonline(self, request, tl, one, two, module, extra, prog):

        #   Check that the user has completed all required modules so that they
        #   are "finished" registering for the program.  (In other words, they
        #   should be registered for at least one class, and filled out other
        #   required forms, before paying by credit card.)
        modules = prog.getModules(request.user, tl)
        completedAll = True
        for module in modules:
            if not module.isCompleted() and module.required:
                completedAll = False
        if not completedAll and not request.user.isAdmin(prog):
            raise ESPError(
                "Please go back and ensure that you have completed all required steps of registration before paying by credit card.",
                log=False)

        #   Check for setup of module.  This is also required to initialize settings.
        self.check_setup()

        user = request.user

        iac = IndividualAccountingController(self.program, request.user)
        context = {}
        context['module'] = self
        context['program'] = prog
        context['user'] = user
        context['invoice_id'] = iac.get_id()
        context['identifier'] = iac.get_identifier()
        payment_type = iac.default_payments_lineitemtype()
        sibling_type = iac.default_siblingdiscount_lineitemtype()
        grant_type = iac.default_finaid_lineitemtype()
        offer_donation = self.settings['offer_donation']
        donate_type = iac.get_lineitemtypes().get(
            text=self.settings['donation_text']) if offer_donation else None
        context['itemizedcosts'] = iac.get_transfers().exclude(
            line_item__in=filter(
                None, [payment_type, sibling_type, grant_type, donate_type
                       ])).order_by('-line_item__required')
        context['itemizedcosttotal'] = iac.amount_due()
        #   This amount should be formatted as an integer in order to be
        #   accepted by Stripe.
        context['totalcost_cents'] = int(context['itemizedcosttotal'] * 100)
        context['subtotal'] = iac.amount_requested()
        context['financial_aid'] = iac.amount_finaid()
        context['sibling_discount'] = iac.amount_siblingdiscount()
        context['amount_paid'] = iac.amount_paid()

        #   Load donation amount separately, since the client-side code needs to know about it separately.
        donation_prefs = iac.get_preferences([
            donate_type,
        ]) if offer_donation else None
        if donation_prefs:
            context['amount_donation'] = Decimal(donation_prefs[0][2])
            context['has_donation'] = True
        else:
            context['amount_donation'] = Decimal('0.00')
            context['has_donation'] = False
        context['amount_without_donation'] = context[
            'itemizedcosttotal'] - context['amount_donation']

        if 'HTTP_HOST' in request.META:
            context['hostname'] = request.META['HTTP_HOST']
        else:
            context['hostname'] = Site.objects.get_current().domain
        context['institution'] = settings.INSTITUTION_NAME
        context['support_email'] = settings.DEFAULT_EMAIL_ADDRESSES['support']

        return render_to_response(self.baseDir() + 'cardpay.html', request,
                                  context)