Add "total amount" to CLINS

- includes migration for change to model
This commit is contained in:
graham-dds 2019-09-05 15:09:20 -04:00
parent e565913f48
commit f3eea39536
5 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,29 @@
"""Add total amount to CLINs
Revision ID: f03333c42bdb
Revises: 4a3122ffe898
Create Date: 2019-09-04 15:35:39.446486
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f03333c42bdb' # pragma: allowlist secret
down_revision = '30ea1cb20807' # pragma: allowlist secret
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('clins', sa.Column('total_amount', sa.Numeric(scale=2), nullable=True))
op.execute("UPDATE clins SET total_amount = 0")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('clins', 'total_amount')
# ### end Alembic commands ###

View File

@ -58,6 +58,7 @@ class TaskOrders(BaseDomainClass):
number=clin_data["number"], number=clin_data["number"],
start_date=clin_data["start_date"], start_date=clin_data["start_date"],
end_date=clin_data["end_date"], end_date=clin_data["end_date"],
total_amount=clin_data["total_amount"],
obligated_amount=clin_data["obligated_amount"], obligated_amount=clin_data["obligated_amount"],
jedi_clin_type=clin_data["jedi_clin_type"], jedi_clin_type=clin_data["jedi_clin_type"],
) )

View File

@ -47,6 +47,10 @@ class CLINForm(FlaskForm):
format="%m/%d/%Y", format="%m/%d/%Y",
validators=[Optional()], validators=[Optional()],
) )
total_amount = DecimalField(
label=translate("task_orders.form.total_funds_label"),
validators=[Optional()],
)
obligated_amount = DecimalField( obligated_amount = DecimalField(
label=translate("task_orders.form.obligated_funds_label"), label=translate("task_orders.form.obligated_funds_label"),
validators=[Optional()], validators=[Optional()],

View File

@ -23,6 +23,7 @@ class CLIN(Base, mixins.TimestampsMixin):
number = Column(String, nullable=True) number = Column(String, nullable=True)
start_date = Column(Date, nullable=True) start_date = Column(Date, nullable=True)
end_date = Column(Date, nullable=True) end_date = Column(Date, nullable=True)
total_amount = Column(Numeric(scale=2), nullable=True)
obligated_amount = Column(Numeric(scale=2), nullable=True) obligated_amount = Column(Numeric(scale=2), nullable=True)
jedi_clin_type = Column(SQLAEnum(JEDICLINType, native_enum=False), nullable=True) jedi_clin_type = Column(SQLAEnum(JEDICLINType, native_enum=False), nullable=True)
@ -46,6 +47,7 @@ class CLIN(Base, mixins.TimestampsMixin):
self.number, self.number,
self.start_date, self.start_date,
self.end_date, self.end_date,
self.total_amount,
self.obligated_amount, self.obligated_amount,
self.jedi_clin_type, self.jedi_clin_type,
] ]

View File

@ -291,6 +291,7 @@ class CLINFactory(Base):
number = factory.LazyFunction(random_task_order_number) number = factory.LazyFunction(random_task_order_number)
start_date = datetime.date.today() start_date = datetime.date.today()
end_date = factory.LazyFunction(random_future_date) end_date = factory.LazyFunction(random_future_date)
total_amount = factory.LazyFunction(lambda *args: random.randint(100, 999999))
obligated_amount = factory.LazyFunction(lambda *args: random.randint(100, 999999)) obligated_amount = factory.LazyFunction(lambda *args: random.randint(100, 999999))
jedi_clin_type = factory.LazyFunction( jedi_clin_type = factory.LazyFunction(
lambda *args: random.choice(list(clin.JEDICLINType)) lambda *args: random.choice(list(clin.JEDICLINType))