Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grant amount/percent fields to finaid approval form #3116

Merged
merged 4 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions esp/esp/accounting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def __unicode__(self):

class FinancialAidGrant(models.Model):
request = AjaxForeignKey(FinancialAidRequest)
amount_max_dec = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text='Enter a number here to grant a dollar value of financial aid. The grant will cover this amount or the full cost of the program, whichever is less.')
percent = models.PositiveIntegerField(blank=True, null=True, help_text='Enter an integer between 0 and 100 here to grant a certain percentage discount to the program after the above dollar credit is applied. 0 means no additional discount, 100 means no payment required.')
amount_max_dec = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text='Enter a number here to grant a dollar value of financial aid. The grant will cover this amount or the full cost, whichever is less.')
percent = models.PositiveIntegerField(blank=True, null=True, help_text='Enter an integer between 0 and 100 here to grant a certain percentage discount after the above dollar credit is applied. 0 means no additional discount, 100 means no payment required.')
timestamp = models.DateTimeField(auto_now=True)
finalized = models.BooleanField(default=False, editable=False)

Expand Down
14 changes: 8 additions & 6 deletions esp/esp/program/modules/handlers/finaidapprovemodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from esp.program.modules.base import ProgramModuleObj, needs_admin, main_call
from esp.utils.web import render_to_response
from esp.program.models import FinancialAidRequest
from esp.accounting.models import FinancialAidGrant


class FinAidApproveModule(ProgramModuleObj):
Expand All @@ -57,9 +58,10 @@ class Meta:
@needs_admin
def finaidapprove(self, request, tl, one, two, module, extra, prog):
context = {}
message = ""
users_approved = []
users_error = []
context['amount_max_dec_help_text'] = FinancialAidGrant._meta.get_field('amount_max_dec').help_text
context['percent_help_text'] = FinancialAidGrant._meta.get_field('percent').help_text

# The following code was copied and modified from finaid_approve.py in useful_scripts

Expand All @@ -70,16 +72,16 @@ def finaidapprove(self, request, tl, one, two, module, extra, prog):
# populate the query set cache (whereas if we used .exists() or .count(), they
# wouldn't, and the later iteration would hit the database again)
if len(reqs) == 0:
message = "No requests found."
context["error"] = message
context["error"] = "No requests found."
return render_to_response(self.baseDir()+'finaid.html', request, context)

if request.method == 'POST':
context['POST'] = True

# ITERATE & APPROVE REQUESTS
userchecklist = request.POST.getlist("user")
approve_blanks = request.POST.get('approve_blanks', False);
approve_blanks = request.POST.get('approve_blanks', False)
amount_max_dec = request.POST.get('amount_max_dec', None)
percent = request.POST.get('percent', None)

def is_blank(x):
return x is None or x == ""
Expand All @@ -96,7 +98,7 @@ def is_blank(x):
continue

try:
req.approve(dollar_amount = None, discount_percent=100)
req.approve(dollar_amount = amount_max_dec, discount_percent = percent)
users_approved.append(req.user.name())
except:
users_error.append(req.user.name())
Expand Down
10 changes: 8 additions & 2 deletions esp/templates/program/modules/finaidapprovemodule/finaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ <h1>Financial Aid Requests for {{ program.niceName }}</h1>
</table>
</div>

<label for="amount_max_dec">{{ amount_max_dec_help_text }}</label>
<input name="amount_max_dec" type="number" min="0.00" step="0.01" max="2500" value="0.00" required>
<br />
<label for="amount_max_dec">{{ percent_help_text }}</label>
<input name="percent" type="number" min="0" step="1" max="100" value="100" required>
<br />
<input type="submit" value="Approve Requests" class="btn btn-primary" >
<input type="checkbox" id="approve_blanks_checkbox" name="approve_blanks" value=True> Approve blank requests?
<input type="checkbox" id="approve_blanks_checkbox" name="approve_blanks" checked> Approve blank requests?
</form>

{% if error %}
Expand All @@ -93,7 +99,7 @@ <h3 style="padding-top: 10px;"> {{ users_approved|length }} New Approvals</h3>
<h4>
{{ users_approved|join:", " }}
</h4>
{% else %}
{% elif POST %}
<h3 style="padding-top: 10px;"> 0 New Approvals </h3>
{% endif %}

Expand Down