diff --git a/alembic/versions/f03333c42bdb_add_total_amount_to_clins.py b/alembic/versions/f03333c42bdb_add_total_amount_to_clins.py new file mode 100644 index 00000000..8201bb61 --- /dev/null +++ b/alembic/versions/f03333c42bdb_add_total_amount_to_clins.py @@ -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 ### diff --git a/atst/domain/task_orders.py b/atst/domain/task_orders.py index 2c27977c..93521843 100644 --- a/atst/domain/task_orders.py +++ b/atst/domain/task_orders.py @@ -58,6 +58,7 @@ class TaskOrders(BaseDomainClass): number=clin_data["number"], start_date=clin_data["start_date"], end_date=clin_data["end_date"], + total_amount=clin_data["total_amount"], obligated_amount=clin_data["obligated_amount"], jedi_clin_type=clin_data["jedi_clin_type"], ) diff --git a/atst/forms/task_order.py b/atst/forms/task_order.py index 09a8fe8e..579c0cc0 100644 --- a/atst/forms/task_order.py +++ b/atst/forms/task_order.py @@ -47,6 +47,10 @@ class CLINForm(FlaskForm): format="%m/%d/%Y", validators=[Optional()], ) + total_amount = DecimalField( + label=translate("task_orders.form.total_funds_label"), + validators=[Optional()], + ) obligated_amount = DecimalField( label=translate("task_orders.form.obligated_funds_label"), validators=[Optional()], diff --git a/atst/models/clin.py b/atst/models/clin.py index da2d1d02..6107a1f3 100644 --- a/atst/models/clin.py +++ b/atst/models/clin.py @@ -23,6 +23,7 @@ class CLIN(Base, mixins.TimestampsMixin): number = Column(String, nullable=True) start_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) jedi_clin_type = Column(SQLAEnum(JEDICLINType, native_enum=False), nullable=True) @@ -46,6 +47,7 @@ class CLIN(Base, mixins.TimestampsMixin): self.number, self.start_date, self.end_date, + self.total_amount, self.obligated_amount, self.jedi_clin_type, ] diff --git a/tests/factories.py b/tests/factories.py index 7dd4a2f6..45c0be86 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -291,6 +291,7 @@ class CLINFactory(Base): number = factory.LazyFunction(random_task_order_number) start_date = datetime.date.today() 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)) jedi_clin_type = factory.LazyFunction( lambda *args: random.choice(list(clin.JEDICLINType))