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_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):
reported_clin_name: str

View File

@ -325,15 +325,16 @@ def create_billing_instruction(self):
clins = TaskOrders.get_clins_for_create_billing_instructions()
for clin in clins:
portfolio = clin.task_order.portfolio
clin_data = clin.to_dictionary()
portfolio_data = portfolio.to_dictionary()
payload = BillingInstructionCSPPayload(
tenant_id=portfolio.csp_data.get("tenant_id"),
billing_account_name=portfolio.csp_data.get("billing_account_name"),
billing_profile_name=portfolio.csp_data.get("billing_profile_name"),
**clin_data,
**portfolio_data,
initial_clin_amount=clin.obligated_amount,
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:

View File

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

View File

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