Esempio n. 1
0
def get_form_expected_form_details_dto():

    brand1= GetFormBrandDtoWithItemId(
            brand_id=1,
            name="HoneyBee",
            min_quantity=2,
            max_quantity=10,
            price_per_item=100,
            item_id=1)
    brand2 = GetFormBrandDtoWithItemId(
            brand_id=2,
            name="KnockOut",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=1)
    brand3 = GetFormBrandDtoWithItemId(
            brand_id=3,
            name="KingFisher",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=2)
        
    order1 = GetFormItemOrderDto(order_id=1,
                                 brand_id=1,
                                 ordered_count=10,
                                 out_of_stock=0)
    order2 = GetFormItemOrderDto(order_id=2,
                                 brand_id=3,
                                 ordered_count=10,
                                 out_of_stock=0)
    
    item1 = GetFormItemDto(item_id=1,
                           name="choco",
                           description="choco",
                           brands=[brand1, brand2],
                           order=order1)
    item2 = GetFormItemDto(item_id=2,
                           name="lace",
                           description="lace",
                           brands=[brand3],
                           order=order2)

    section1 = GetFormSectionDto(section_id=1,
                                 name="SECTION1",
                                 description="DESCRIP SECTION1",
                                 items=[item1, item2])

    section2 = GetFormSectionDto(section_id=2,
                                 name="SECTION2",
                                 description="DESCRIP SECTION2",
                                 items=[])
    
    get_form_dto = GetFormDto(form_id=1,
                              name="FORM1",
                              close_date=datetime.datetime(2020, 10, 10, 0, 0),
                              sections=[section1, section2])

    return get_form_dto
    def _get_item_order_dto(self, item_id, order_dtos):
        order_dto = self._is_item_has_order_if_exists_return_order_obj(
            item_id=item_id, order_dtos=order_dtos)

        if order_dto:
            return GetFormItemOrderDto(order_id=order_dto.item_id,
                                       brand_id=order_dto.brand_id,
                                       ordered_count=order_dto.count,
                                       out_of_stock=order_dto.out_of_stock)
        else:
            return GetFormItemOrderDto(order_id=0,
                                       brand_id=0,
                                       ordered_count=0,
                                       out_of_stock=0)
    def _get_item_order_dto(self, item_id, order_dtos):
        order_dto = self._is_item_has_order_if_exists_return_order_obj(
            item_id=item_id, order_dtos=order_dtos)

        if order_dto:
            # i have user print statement here
            print("ordered count ", order_dto.count)
            return GetFormItemOrderDto(order_id=order_dto.order_id,
                                       brand_id=order_dto.brand_id,
                                       ordered_count=order_dto.count,
                                       out_of_stock=order_dto.out_of_stock)
        else:
            return GetFormItemOrderDto(order_id=0,
                                       brand_id=0,
                                       ordered_count=0,
                                       out_of_stock=0)
Esempio n. 4
0
    def _get_item_details_dtos(self,
                               section_order_dtos,
                               section_items_dtos,
                               brand_dicts):

        item_dto_list = []

        for item in section_items_dtos:
            brand_dtos = self._get_item_brands_dto_list(
                item=item,
                brand_dicts=brand_dicts)

            (order_id,
             brand_id,
             ordered_count,
             out_of_stock) = self._get_order_related_data_for_item(
                 item=item,
                 orders=section_order_dtos,
                 brand_dicts=brand_dicts)

            item_order_dto = GetFormItemOrderDto(order_id=order_id,
                                                 brand_id=brand_id,
                                                 ordered_count=ordered_count,
                                                 out_of_stock=out_of_stock)
                    
            dto = GetFormItemDto(item_id=item.item_id,
                                 name=item.name,
                                 description=item.description,
                                 brands=brand_dtos,
                                 order=item_order_dto)
            item_dto_list.append(dto)

        return item_dto_list