Explicitly pass in kwargs instead of splatting clin and portfolio data

This commit is contained in:
leigh-mil 2020-02-19 11:10:20 -05:00
parent 5c7dfc428e
commit 0bda0c481e
4 changed files with 6 additions and 14 deletions

View File

@ -220,14 +220,6 @@ class BillingInstructionCSPPayload(BaseCSPPayload):
billing_account_name: str billing_account_name: str
billing_profile_name: str billing_profile_name: str
class Config:
fields = {
"initial_clin_amount": "obligated_amount",
"initial_clin_start_date": "start_date",
"initial_clin_end_date": "end_date",
"initial_clin_type": "number",
}
class BillingInstructionCSPResult(AliasModel): class BillingInstructionCSPResult(AliasModel):
reported_clin_name: str reported_clin_name: str

View File

@ -325,15 +325,16 @@ def create_billing_instruction(self):
clins = TaskOrders.get_clins_for_create_billing_instructions() clins = TaskOrders.get_clins_for_create_billing_instructions()
for clin in clins: for clin in clins:
portfolio = clin.task_order.portfolio portfolio = clin.task_order.portfolio
clin_data = clin.to_dictionary()
portfolio_data = portfolio.to_dictionary()
payload = BillingInstructionCSPPayload( payload = BillingInstructionCSPPayload(
tenant_id=portfolio.csp_data.get("tenant_id"), tenant_id=portfolio.csp_data.get("tenant_id"),
billing_account_name=portfolio.csp_data.get("billing_account_name"), billing_account_name=portfolio.csp_data.get("billing_account_name"),
billing_profile_name=portfolio.csp_data.get("billing_profile_name"), billing_profile_name=portfolio.csp_data.get("billing_profile_name"),
**clin_data, initial_clin_amount=clin.obligated_amount,
**portfolio_data, initial_clin_start_date=str(clin.start_date),
initial_clin_end_date=str(clin.end_date),
initial_clin_type=clin.number,
initial_task_order_id=str(clin.task_order_id),
) )
try: try:

View File

@ -71,8 +71,6 @@ class CLIN(Base, mixins.TimestampsMixin):
for c in self.__table__.columns for c in self.__table__.columns
if c.name not in ["id"] if c.name not in ["id"]
} }
data["start_date"] = str(data["start_date"])
data["end_date"] = str(data["end_date"])
return data return data

View File

@ -561,6 +561,7 @@ class TestCreateBillingInstructions:
session.begin_nested() session.begin_nested()
create_billing_instruction() create_billing_instruction()
session.add(sent_clin)
# check that last_sent_at has been update for the new clin only # check that last_sent_at has been update for the new clin only
assert new_clin.last_sent_at assert new_clin.last_sent_at