Пример #1
0
def add_task_orders_to_portfolio(portfolio):
    today = date.today()
    future = today + timedelta(days=100)
    yesterday = today - timedelta(days=1)
    five_days = timedelta(days=5)

    def build_pdf():
        return {
            "filename": "sample_task_order.pdf",
            "object_name": str(uuid4())
        }

    draft_to = TaskOrderFactory.build(portfolio=portfolio, pdf=None)
    unsigned_to = TaskOrderFactory.build(portfolio=portfolio, pdf=build_pdf())
    upcoming_to = TaskOrderFactory.build(portfolio=portfolio,
                                         signed_at=yesterday,
                                         pdf=build_pdf())
    expired_to = TaskOrderFactory.build(portfolio=portfolio,
                                        signed_at=yesterday,
                                        pdf=build_pdf())
    active_to = TaskOrderFactory.build(portfolio=portfolio,
                                       signed_at=yesterday,
                                       pdf=build_pdf())

    clins = [
        CLINFactory.build(task_order=unsigned_to,
                          start_date=(today - five_days),
                          end_date=today),
        CLINFactory.build(task_order=upcoming_to,
                          start_date=future,
                          end_date=(today + five_days)),
        CLINFactory.build(task_order=expired_to,
                          start_date=(today - five_days),
                          end_date=yesterday),
        CLINFactory.build(task_order=active_to,
                          start_date=yesterday,
                          end_date=future),
    ]

    task_orders = [draft_to, unsigned_to, upcoming_to, expired_to, active_to]

    db.session.add_all(task_orders + clins)
    db.session.commit()
Пример #2
0
def add_task_orders_to_portfolio(portfolio):
    today = date.today()
    future = today + timedelta(days=100)
    yesterday = today - timedelta(days=1)
    five_days = timedelta(days=5)

    def build_pdf():
        return {
            "filename": "sample_task_order.pdf",
            "object_name": str(uuid4())
        }

    draft_to = TaskOrderFactory.build(portfolio=portfolio, pdf=None)
    unsigned_to = TaskOrderFactory.build(portfolio=portfolio, pdf=build_pdf())
    upcoming_to = TaskOrderFactory.build(portfolio=portfolio,
                                         signed_at=yesterday,
                                         pdf=build_pdf())
    expired_to = TaskOrderFactory.build(portfolio=portfolio,
                                        signed_at=yesterday,
                                        pdf=build_pdf())
    active_to = TaskOrderFactory.build(portfolio=portfolio,
                                       signed_at=yesterday,
                                       pdf=build_pdf())

    clins = [
        CLINFactory.build(task_order=unsigned_to,
                          start_date=(today - five_days),
                          end_date=today),
        CLINFactory.build(task_order=upcoming_to,
                          start_date=future,
                          end_date=(today + five_days)),
        CLINFactory.build(task_order=expired_to,
                          start_date=(today - five_days),
                          end_date=yesterday),
        CLINFactory.build(
            task_order=active_to,
            start_date=yesterday,
            end_date=future,
            total_amount=1_000_000,
            obligated_amount=500_000,
            jedi_clin_type=JEDICLINType.JEDI_CLIN_1,
        ),
        CLINFactory.build(
            task_order=active_to,
            start_date=yesterday,
            end_date=future,
            total_amount=500_000,
            obligated_amount=200_000,
            jedi_clin_type=JEDICLINType.JEDI_CLIN_2,
        ),
    ]