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

Fix: Credit Offset Exclude Reserved #2876

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 additions & 0 deletions backend/api/serializers/ComplianceReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,18 @@ def get_max_credit_offset(self, obj):

return max_credit_offset

def get_max_credit_offset_exclude_reserved(self, obj):
max_credit_offset_exclude_reserved = OrganizationService.get_max_credit_offset(
obj.organization,
obj.compliance_period.description,
exclude_reserved=True
)

if max_credit_offset_exclude_reserved < 0:
max_credit_offset_exclude_reserved = 0

return max_credit_offset_exclude_reserved

def get_summary(self, obj):
"""
Retrieve a summary that merges synthetic totals with existing summary data.
Expand Down Expand Up @@ -1255,6 +1267,18 @@ def get_max_credit_offset(self, obj):

return max_credit_offset

def get_max_credit_offset_exclude_reserved(self, obj):
max_credit_offset_exclude_reserved = OrganizationService.get_max_credit_offset(
obj.organization,
obj.compliance_period.description,
exclude_reserved=True
)

if max_credit_offset_exclude_reserved < 0:
max_credit_offset_exclude_reserved = 0

return max_credit_offset_exclude_reserved

def get_history(self, obj):
"""
Returns all the previous status changes for the compliance report
Expand Down
8 changes: 5 additions & 3 deletions backend/api/services/OrganizationService.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ def get_pending_deductions(
if compliance_report.summary.credits_offset is not None:
deductions += compliance_report.summary.credits_offset

if report.status.director_status_id == 'Accepted' and \
ignore_pending_supplemental:
deductions -= report.summary.credits_offset
if report.status.director_status_id == 'Accepted' and ignore_pending_supplemental:
if report.summary is not None:
if report.summary.credits_offset:
deductions -= report.summary.credits_offset

if deductions < 0:
deductions = 0

Expand Down