Use clin values to render budget information

- creates a relationship `clins` on task order model
- two properties on task order model to calculate budget amounts
This commit is contained in:
Montana 2019-06-04 16:15:24 -04:00
parent 08c1a967ba
commit e4cbe892fc
2 changed files with 25 additions and 5 deletions

View File

@ -6,7 +6,8 @@ from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import relationship
from werkzeug.datastructures import FileStorage
from atst.models import Attachment, Base, types, mixins
from atst.models import Attachment, Base, mixins, types
from atst.models.clin import JEDICLINType
class Status(Enum):
@ -33,6 +34,8 @@ class TaskOrder(Base, mixins.TimestampsMixin):
signer_dod_id = Column(String)
signed_at = Column(DateTime)
clins = relationship("CLIN")
@hybrid_property
def pdf(self):
return self._pdf
@ -83,9 +86,26 @@ class TaskOrder(Base, mixins.TimestampsMixin):
return (self.end_date - date.today()).days
@property
def total_obligated_funds(self):
total = 0
for clin in self.clins:
if clin.jedi_clin_type in [
JEDICLINType.JEDI_CLIN_1,
JEDICLINType.JEDI_CLIN_3,
]:
total += clin.obligated_amount
return total
@property
def total_contract_amount(self):
total = 0
for clin in self.clins:
total += clin.obligated_amount
return total
@property
# TODO delete when we delete task_order_review flow
def budget(self):
# TODO: fix task order -- reimplement using CLINs
# Faked for display purposes
return 100000
@property

View File

@ -2,13 +2,13 @@
<div class="col totals-box">
<div class="h4">Total obligated funds</div>
<div class="h3">$500,000</div>
<div class="h3">{{ task_order.total_obligated_funds | dollars }}</div>
<div>This is the funding allocated to cloud services. It may be 100% or a portion of the total task order budget.</div>
<hr>
<div class="h4">Total contract amount</div>
<div class="h3">{{ task_order.budget | dollars }}</div>
<div class="h3">{{ task_order.total_contract_amount | dollars }}</div>
<div>This is the value of all funds obligated for this contract, including -- but not limited to -- funds obligated for the cloud.</div>
</div>