示例#1
0
def get_expected_form_dtos():
    home_page_form_dtos = [
        HomePageFormDto(form_id=1,
                        name="FORM1",
                        status="LIVE",
                        close_date=datetime.datetime(2020,10,10,0,0),
                        expected_delivery_date=datetime.datetime(
                            2020,10,10,0,0),
                        items_count=20,
                        estimated_cost=3000,
                        items_pending_count=5,
                        cost_incurred_for_delivery=0),
        HomePageFormDto(form_id=2,
                        name="FORM2",
                        status="CLOSED",
                        close_date=datetime.datetime(2020,10,10,0,0),
                        expected_delivery_date=datetime.datetime(
                            2020,10,10,0,0),
                        items_count=5,
                        estimated_cost=1000,
                        items_pending_count=5,
                        cost_incurred_for_delivery=0),
        HomePageFormDto(form_id=3,
                        name="FORM3",
                        status="LIVE",
                        close_date=datetime.datetime(2020,10,10,0,0),
                        expected_delivery_date=datetime.datetime(
                            2020,10,10,0,0),
                        items_count=0,
                        estimated_cost=0,
                        items_pending_count=0,
                        cost_incurred_for_delivery=0)

        ]
    return home_page_form_dtos
    def _get_form_details(self, form_obj):

        form = form_obj.form_dto
        orders = form_obj.order_dtos
        brands = form_obj.brand_dtos
        items = form_obj.item_dtos

        brand_dicts = self._get_brands_dicts(brands)

        total_items_count = self._get_total_ordered_items_count(orders=orders)
        estimated_cost = self._get_estimated_cost(orders=orders,
                                                  brand_dicts=brand_dicts)

        pending_items_count = self._get_pending_items(orders)
        incurred_cost = self._get_incurred_cost(orders=orders,
                                                brand_dicts=brand_dicts)

        form_status = \
            self.is_form_is_closed_with_no_pending_item_update_form_status(
                form.status, pending_items_count)

        home_page_form_dto = HomePageFormDto(
             form_id=form.form_id,
             name=form.name,
             status=form_status,
             close_date=form.close_date,
             expected_delivery_date=form.expected_delivery_date,
             items_count=total_items_count,
             estimated_cost=estimated_cost,
             items_pending_count=pending_items_count,
             cost_incurred_for_delivery=incurred_cost
        )

        return home_page_form_dto