Пример #1
0
 def test_asset_count_price(self):
     day = datetime.date(2013, 4, 25)
     venture = models.Venture(venture_id=3)
     venture.save()
     device = models.Device(
         device_id=3,
         asset_id=5,
     )
     device.save()
     daily = models.DailyDevice(
         pricing_device=device,
         date=day,
         name='ziew',
         price='1337',
         pricing_venture=venture,
     )
     daily.save()
     subventure = models.Venture(venture_id=2, parent=venture)
     subventure.save()
     other_device = models.Device(
         device_id=2,
         asset_id=3,
     )
     other_device.save()
     other_daily = models.DailyDevice(
         pricing_device=other_device,
         date=day,
         name='ziew',
         price='833833',
         pricing_venture=subventure,
     )
     other_daily.save()
     count, price, cost = venture.get_assets_count_price_cost(day, day)
     self.assertEquals(count, 1)
     self.assertEquals(price, decimal.Decimal('1337'))
     count, price, cost = venture.get_assets_count_price_cost(
         day,
         day,
         True,
     )
     self.assertEquals(count, 2)
     self.assertEquals(price, decimal.Decimal('835170'))
Пример #2
0
    def setUp(self):
        self.report_start = datetime.date(2013, 4, 20)
        self.report_end = datetime.date(2013, 4, 30)
        # ventures
        self.venture = models.Venture(venture_id=1, name='b', is_active=True)
        self.venture.save()
        self.subventure = models.Venture(
            venture_id=2,
            parent=self.venture,
            name='bb',
            is_active=False,
        )
        self.subventure.save()
        self.venture2 = models.Venture(venture_id=3, name='a', is_active=True)
        self.venture2.save()

        # usages
        self.usage_type = models.UsageType(name='UT1', symbol='ut1')
        self.usage_type.save()
        usage_type2 = models.UsageType(
            name='UT2',
            symbol='ut2',
            show_in_ventures_report=False,
        )
        usage_type2.save()

        # usages by warehouse
        self.warehouse_usage_type = models.UsageType(
            name='UT3',
            symbol='ut3',
            by_warehouse=True,
            order=3,
            use_universal_plugin=False,
        )
        self.warehouse_usage_type.save()

        # service
        self.service = models.Service(name='Service1')
        self.service.save()
Пример #3
0
 def test_extra_cost_models(self):
     type_ = models.ExtraCostType(name='ziew')
     type_.save()
     venture = models.Venture(venture_id=3)
     venture.save()
     cost = models.ExtraCost(
         type=type_,
         monthly_cost=3,
         pricing_venture=venture,
     )
     cost.save()
     self.assertEquals(type_.name, 'ziew')
     self.assertEquals(venture.venture_id, 3)
     self.assertEquals(cost.type, type_)
     self.assertEquals(cost.monthly_cost, 3)
     self.assertEquals(cost.pricing_venture, venture)
Пример #4
0
 def test_extra_cost_models(self):
     type_ = models.ExtraCostType(name='ziew')
     type_.save()
     venture = models.Venture(venture_id=3)
     venture.save()
     cost = models.ExtraCost(
         type=type_,
         start=datetime.datetime(2013, 4, 24),
         end=datetime.datetime(2013, 4, 26),
         price=3,
         pricing_venture=venture,
     )
     cost.save()
     self.assertEquals(type_.name, 'ziew')
     self.assertEquals(venture.venture_id, 3)
     self.assertEquals(cost.type, type_)
     self.assertEquals(cost.start, datetime.datetime(2013, 4, 24))
     self.assertEquals(cost.end, datetime.datetime(2013, 4, 26))
     self.assertEquals(cost.price, 3)
     self.assertEquals(cost.pricing_venture, venture)
Пример #5
0
 def test_extra_costs(self):
     day = datetime.date(2013, 4, 25)
     venture = models.Venture(venture_id=3)
     venture.save()
     extra_cost_type = models.ExtraCostType(name='waciki')
     extra_cost_type.save()
     extra_cost = models.ExtraCost(
         pricing_venture=venture,
         start=day,
         end=day,
         type=extra_cost_type,
         price='65535',
     )
     extra_cost.save()
     price = venture.get_extra_costs(day, day, extra_cost_type)
     self.assertEqual(price, decimal.Decimal('65535'))
     price = venture.get_extra_costs(
         datetime.date(2013, 4, 24),
         datetime.date(2013, 4, 24),
         extra_cost_type,
     )
     self.assertEqual(price, decimal.Decimal('0'))
Пример #6
0
 def test_usages_count_price(self):
     day = datetime.date(2013, 4, 25)
     venture = models.Venture(venture_id=3)
     venture.save()
     usage_type = models.UsageType(name='waciki')
     usage_type.save()
     daily_usage = models.DailyUsage(
         type=usage_type,
         value=32,
         date=day,
         pricing_venture=venture,
     )
     daily_usage.save()
     other_day = datetime.date(2013, 4, 24)
     daily_usage = models.DailyUsage(
         type=usage_type,
         value=32,
         date=other_day,
         pricing_venture=venture,
     )
     daily_usage.save()
     usage_price = models.UsagePrice(
         start=day,
         end=day,
         price=4,
         type=usage_type,
     )
     usage_price.save()
     count, price = venture.get_usages_count_price(day, day, usage_type)
     self.assertEquals(count, 32)
     self.assertEquals(price, decimal.Decimal('128'))
     day = datetime.date(2013, 4, 26)
     count, price = venture.get_usages_count_price(day, day, usage_type)
     self.assertEquals(count, 0)
     self.assertEquals(price, decimal.Decimal('0'))
     day = datetime.date(2013, 4, 24)
     count, price = venture.get_usages_count_price(day, day, usage_type)
     self.assertEquals(count, 32)
     self.assertIsNone(price)
    def setUp(self):
        self.plugin = SampleReportPlugin()

        # usage types
        self.usage_type = models.UsageType(
            name='UsageType1',
            symbol='ut1',
            by_warehouse=False,
            by_cost=False,
            type='BU',
        )
        self.usage_type.save()
        self.usage_type_cost_wh = models.UsageType(
            name='UsageType2',
            symbol='ut2',
            by_warehouse=True,
            by_cost=True,
            type='BU',
        )
        self.usage_type_cost_wh.save()

        # warehouses
        self.warehouse1 = models.Warehouse(
            name='Warehouse1',
            show_in_report=True,
        )
        self.warehouse1.save()
        self.warehouse2 = models.Warehouse(
            name='Warehouse2',
            show_in_report=True,
        )
        self.warehouse2.save()
        self.warehouses = models.Warehouse.objects.all()

        # ventures
        self.venture1 = models.Venture(
            venture_id=1,
            name='V1',
            is_active=True,
        )
        self.venture1.save()
        self.venture2 = models.Venture(
            venture_id=2,
            name='V2',
            is_active=True,
        )
        self.venture2.save()
        self.venture3 = models.Venture(venture_id=3, name='V3', is_active=True)
        self.venture3.save()
        self.venture4 = models.Venture(venture_id=4, name='V4', is_active=True)
        self.venture4.save()
        self.ventures = models.Venture.objects.all()

        # daily usages of base type
        # ut1:
        #   venture1: 10
        #   venture2: 20
        # ut2:
        #   venture1: 20 (half in warehouse1, half in warehouse2)
        #   venture2: 40 (half in warehouse1, half in warehouse2)
        start = datetime.date(2013, 10, 8)
        end = datetime.date(2013, 10, 22)
        base_usage_types = models.UsageType.objects.filter(type='BU')
        for i, ut in enumerate(base_usage_types, start=1):
            days = rrule.rrule(rrule.DAILY, dtstart=start, until=end)
            for j, day in enumerate(days, start=1):
                for k, venture in enumerate(self.ventures, start=1):
                    daily_usage = models.DailyUsage(
                        date=day,
                        pricing_venture=venture,
                        value=10 * i * k,
                        type=ut,
                    )
                    if ut.by_warehouse:
                        daily_usage.warehouse = (
                            self.warehouses[j % len(self.warehouses)]
                        )
                    daily_usage.save()

        # usage prices
        dates = [
            (datetime.date(2013, 10, 5), datetime.date(2013, 10, 12)),
            (datetime.date(2013, 10, 13), datetime.date(2013, 10, 17)),
            (datetime.date(2013, 10, 18), datetime.date(2013, 10, 25)),
        ]
        # (real cost/price, forecast cost/price)
        ut_prices_costs = [
            (self.usage_type, [(10, 50), (20, 60), (30, 70)]),
            (self.usage_type_cost_wh, [
                [(3600, 2400), (5400, 5400), (4800, 12000)],  # warehouse1
                [(3600, 5400), (3600, 1200), (7200, 3600)],  # warehouse2
            ]),
        ]

        def add_usage_price(usage_type, prices_costs, warehouse=None):
            for daterange, price_cost in zip(dates, prices_costs):
                start, end = daterange
                usage_price = models.UsagePrice(
                    type=usage_type,
                    start=start,
                    end=end,
                )
                if warehouse is not None:
                    usage_price.warehouse = warehouse
                if usage_type.by_cost:
                    usage_price.cost = price_cost[0]
                    usage_price.forecast_cost = price_cost[1]
                else:
                    usage_price.price = price_cost[0]
                    usage_price.forecast_price = price_cost[1]
                usage_price.save()

        for ut, prices in ut_prices_costs:
            if ut.by_warehouse:
                for i, prices_wh in enumerate(prices):
                    warehouse = self.warehouses[i]
                    add_usage_price(ut, prices_wh, warehouse)
            else:
                add_usage_price(ut, prices)
Пример #8
0
    def setUp(self):
        # usage types
        self.usage_type = models.UsageType(
            name='UsageType1',
            symbol='ut1',
            by_warehouse=False,
            by_cost=False,
            type='BU',
            divide_by=1,
        )
        self.usage_type.save()
        self.usage_type_cost_wh = models.UsageType(
            name='UsageType2',
            symbol='ut2',
            by_warehouse=True,
            by_cost=True,
            type='BU',
            rounding=2,
        )
        self.usage_type_cost_wh.save()
        self.usage_type_cost_sum = models.UsageType(
            name='UsageType3',
            symbol='ut3',
            by_warehouse=False,
            by_cost=True,
            type='BU',
            by_internet_provider=True,
            rounding=1,
        )
        self.usage_type_cost_sum.save()
        self.usage_type_average = models.UsageType(
            name='UsageType4',
            symbol='ut4',
            by_warehouse=False,
            by_cost=False,
            type='BU',
            average=True,
            divide_by=2,
        )
        self.usage_type_average.save()

        # warehouses
        self.warehouse1 = models.Warehouse(
            name='Warehouse1',
            show_in_report=True,
        )
        self.warehouse1.save()
        self.warehouse2 = models.Warehouse(
            name='Warehouse2',
            show_in_report=True,
        )
        self.warehouse2.save()
        self.warehouses = models.Warehouse.objects.all()

        # internet providers
        self.net_provider1 = models.InternetProvider(
            name='InternetProvider1', )
        self.net_provider1.save()
        self.net_provider2 = models.InternetProvider(
            name='InternetProvider2', )
        self.net_provider2.save()
        self.net_providers = models.InternetProvider.objects.all()

        # ventures
        self.venture1 = models.Venture(venture_id=1, name='V1', is_active=True)
        self.venture1.save()
        self.venture2 = models.Venture(venture_id=2, name='V2', is_active=True)
        self.venture2.save()
        self.venture3 = models.Venture(venture_id=3, name='V3', is_active=True)
        self.venture3.save()
        self.venture4 = models.Venture(venture_id=4, name='V4', is_active=True)
        self.venture4.save()
        self.ventures_subset = [self.venture1, self.venture2]
        self.ventures = models.Venture.objects.all()

        # daily usages of base type
        # ut1:
        #   venture1: 10
        #   venture2: 20
        # ut2:
        #   venture1: 20 (half in warehouse1, half in warehouse2)
        #   venture2: 40 (half in warehouse1, half in warehouse2)
        # ut3:
        #   venture1: 30
        #   venture2: 60
        # ut4:
        #   venture1: 40
        #   venture2: 80
        start = datetime.date(2013, 10, 8)
        end = datetime.date(2013, 10, 22)
        base_usage_types = models.UsageType.objects.filter(type='BU')
        self.ventures_devices = {}
        for k, venture in enumerate(self.ventures, start=1):
            device = utils.get_or_create_device()
            self.ventures_devices[venture] = device
            for i, ut in enumerate(base_usage_types, start=1):
                days = rrule.rrule(rrule.DAILY, dtstart=start, until=end)
                for j, day in enumerate(days, start=1):
                    daily_usage = models.DailyUsage(
                        date=day,
                        pricing_venture=venture,
                        pricing_device=device,
                        value=10 * i * k,
                        type=ut,
                    )
                    if ut.by_warehouse:
                        daily_usage.warehouse = (
                            self.warehouses[j % len(self.warehouses)])
                    daily_usage.save()

        # usage prices
        dates = [
            (datetime.date(2013, 10, 5), datetime.date(2013, 10, 12)),
            (datetime.date(2013, 10, 13), datetime.date(2013, 10, 17)),
            (datetime.date(2013, 10, 18), datetime.date(2013, 10, 25)),
        ]
        # (real cost/price, forecast cost/price)
        ut_prices_costs = [
            (self.usage_type, [(10, 50), (20, 60), (30, 70)]),
            (
                self.usage_type_cost_wh,
                [
                    [(3600, 2400), (5400, 5400), (4800, 12000)],  # warehouse1
                    [(3600, 5400), (3600, 1200), (7200, 3600)],  # warehouse2
                ]),
            (
                self.usage_type_cost_sum,
                [
                    [(1000, 2000), (2000, 3000), (4000, 5000)],  # provider 1
                    [(10000, 20000), (20000, 30000),
                     (40000, 50000)],  # provider 2
                ]),
            (self.usage_type_average, [(10, 20), (20, 30), (30, 40)]),
        ]

        def add_usage_price(usage_type,
                            prices_costs,
                            net_provider=None,
                            warehouse=None):
            for daterange, price_cost in zip(dates, prices_costs):
                start, end = daterange
                usage_price = models.UsagePrice(
                    type=usage_type,
                    start=start,
                    end=end,
                )
                if warehouse is not None:
                    usage_price.warehouse = warehouse
                if net_provider is not None:
                    usage_price.internet_provider = net_provider
                if usage_type.by_cost:
                    usage_price.cost = price_cost[0]
                    usage_price.forecast_cost = price_cost[1]
                else:
                    usage_price.price = price_cost[0]
                    usage_price.forecast_price = price_cost[1]
                usage_price.save()

        for ut, prices in ut_prices_costs:
            if ut.by_warehouse:
                for i, prices_wh in enumerate(prices):
                    warehouse = self.warehouses[i]
                    add_usage_price(ut, prices_wh, warehouse=warehouse)
            elif ut.by_internet_provider:
                for i, prices_ip in enumerate(prices):
                    net_provider = self.net_providers[i]
                    add_usage_price(ut, prices_ip, net_provider=net_provider)
            else:
                add_usage_price(ut, prices)
Пример #9
0
 def test_ventures_all(self):
     day = datetime.date(2013, 4, 25)
     venture = models.Venture(venture_id=3, name='a')
     venture.save()
     device = models.Device(
         device_id=3,
         asset_id=5,
     )
     device.save()
     daily = models.DailyDevice(
         pricing_device=device,
         date=day,
         name='ziew',
         price='1337',
         pricing_venture=venture,
     )
     daily.save()
     subventure = models.Venture(venture_id=2, parent=venture, name='b')
     subventure.save()
     other_device = models.Device(
         device_id=2,
         asset_id=3,
     )
     other_device.save()
     other_daily = models.DailyDevice(
         pricing_device=other_device,
         date=day,
         name='ziew',
         price='833833',
         pricing_venture=subventure,
     )
     other_daily.save()
     usage_type = models.UsageType(name='waciki')
     usage_type.save()
     daily_usage = models.DailyUsage(
         type=usage_type,
         value=32,
         date=day,
         pricing_venture=venture,
     )
     daily_usage.save()
     extra_cost_type = models.ExtraCostType(name='waciki')
     extra_cost_type.save()
     extra_cost = models.ExtraCost(
         pricing_venture=venture,
         start=day,
         end=day,
         type=extra_cost_type,
         price='65535',
     )
     extra_cost.save()
     view = TopVentures()
     for progress, data in view.get_data(day, day, show_in_ralph=True):
         pass
     self.assertEquals(
         data,
         [
             [
                 3,                 # id
                 'a',               # path
                 True,              # show_in_ralph
                 '',                # department
                 '',                # business segment
                 '',                # Profit center
                 2.0,               # assets count
                 '835 170.00 PLN',  # assets price
                 '0.00 PLN',        # assets cost
                 32.0,              # usage count
                 '0.00 PLN',        # usage price
                 '65 535.00 PLN',   # extra cost
             ],
         ],
     )
     view = AllVentures()
     for progress, data in view.get_data(day, day, show_in_ralph=True):
         pass
     self.assertEquals(
         data,
         [
             [
                 3,
                 'a',
                 True,  # show_in_ralph
                 '',
                 '',
                 '',
                 1.0,
                 '1 337.00 PLN',
                 '0.00 PLN',
                 32.0,
                 'NO PRICE',
                 '65 535.00 PLN',
             ],
             [
                 2,
                 'a/b',
                 True,  # show_in_ralph
                 '',
                 '',
                 '',
                 1.0,
                 '833 833.00 PLN',
                 '0.00 PLN',
                 0,
                 '0.00 PLN',
                 '0.00 PLN',
             ],
         ],
     )
Пример #10
0
    def setUp(self):
        # usage types
        self.usage_type = models.UsageType(
            name='UsageType1',
            symbol='ut1',
            by_warehouse=False,
            by_cost=False,
            type='BU',
        )
        self.usage_type.save()
        self.usage_type_cost_wh = models.UsageType(
            name='UsageType2',
            symbol='ut2',
            by_warehouse=True,
            by_cost=True,
            type='BU',
        )
        self.usage_type_cost_wh.save()

        self.service_usage_type1 = models.UsageType(
            name='ServiceUsageType1',
            symbol='sut1',
            type='SU',
            divide_by=5,
            rounding=2,
        )
        self.service_usage_type1.save()
        self.service_usage_type2 = models.UsageType(
            name='ServiceUsageType2',
            # symbol='sut2',
            type='SU',
        )
        self.service_usage_type2.save()

        # warehouses
        self.warehouse1 = models.Warehouse(
            name='Warehouse1',
            show_in_report=True,
        )
        self.warehouse1.save()
        self.warehouse2 = models.Warehouse(
            name='Warehouse2',
            show_in_report=True,
        )
        self.warehouse2.save()
        self.warehouses = models.Warehouse.objects.all()

        # service
        self.service = models.Service(name='Service1')
        self.service.save()
        self.service.base_usage_types.add(self.usage_type_cost_wh,
                                          self.usage_type)
        models.ServiceUsageTypes(
            usage_type=self.service_usage_type1,
            service=self.service,
            start=datetime.date(2013, 10, 1),
            end=datetime.date(2013, 10, 15),
            percent=30,
        ).save()
        models.ServiceUsageTypes(
            usage_type=self.service_usage_type2,
            service=self.service,
            start=datetime.date(2013, 10, 1),
            end=datetime.date(2013, 10, 15),
            percent=70,
        ).save()
        models.ServiceUsageTypes(
            usage_type=self.service_usage_type1,
            service=self.service,
            start=datetime.date(2013, 10, 16),
            end=datetime.date(2013, 10, 30),
            percent=40,
        ).save()
        models.ServiceUsageTypes(
            usage_type=self.service_usage_type2,
            service=self.service,
            start=datetime.date(2013, 10, 16),
            end=datetime.date(2013, 10, 30),
            percent=60,
        ).save()
        self.service.save()

        # ventures
        self.venture1 = models.Venture(
            venture_id=1,
            name='V1',
            is_active=True,
            service=self.service,  # venture is providing service
        )
        self.venture1.save()
        self.venture2 = models.Venture(
            venture_id=2,
            name='V2',
            is_active=True,
            service=self.service,  # venture is providing service
        )
        self.venture2.save()
        self.venture3 = models.Venture(venture_id=3, name='V3', is_active=True)
        self.venture3.save()
        self.venture4 = models.Venture(venture_id=4, name='V4', is_active=True)
        self.venture4.save()
        self.service_ventures = list(self.service.venture_set.all())
        self.not_service_ventures = list(
            models.Venture.objects.exclude(
                id__in=[i.id for i in self.service_ventures]))
        self.ventures = models.Venture.objects.all()

        # daily usages of base type
        # ut1:
        #   venture1: 10
        #   venture2: 20
        # ut2:
        #   venture1: 20 (half in warehouse1, half in warehouse2)
        #   venture2: 40 (half in warehouse1, half in warehouse2)
        start = datetime.date(2013, 10, 8)
        end = datetime.date(2013, 10, 22)
        base_usage_types = models.UsageType.objects.filter(type='BU')
        for i, ut in enumerate(base_usage_types, start=1):
            days = rrule.rrule(rrule.DAILY, dtstart=start, until=end)
            for j, day in enumerate(days, start=1):
                for k, venture in enumerate(self.ventures, start=1):
                    daily_usage = models.DailyUsage(
                        date=day,
                        pricing_venture=venture,
                        value=10 * i * k,
                        type=ut,
                    )
                    if ut.by_warehouse:
                        daily_usage.warehouse = (
                            self.warehouses[j % len(self.warehouses)])
                    daily_usage.save()

        # usage prices
        dates = [
            (datetime.date(2013, 10, 5), datetime.date(2013, 10, 12)),
            (datetime.date(2013, 10, 13), datetime.date(2013, 10, 17)),
            (datetime.date(2013, 10, 18), datetime.date(2013, 10, 25)),
        ]
        # (real cost/price, forecast cost/price)
        ut_prices_costs = [
            (self.usage_type, [(10, 50), (20, 60), (30, 70)]),
            (
                self.usage_type_cost_wh,
                [
                    [(3600, 2400), (5400, 5400), (4800, 12000)],  # warehouse1
                    [(3600, 5400), (3600, 1200), (7200, 3600)],  # warehouse2
                ]),
        ]

        def add_usage_price(usage_type, prices_costs, warehouse=None):
            for daterange, price_cost in zip(dates, prices_costs):
                start, end = daterange
                usage_price = models.UsagePrice(
                    type=usage_type,
                    start=start,
                    end=end,
                )
                if warehouse is not None:
                    usage_price.warehouse = warehouse
                if usage_type.by_cost:
                    usage_price.cost = price_cost[0]
                    usage_price.forecast_cost = price_cost[1]
                else:
                    usage_price.price = price_cost[0]
                    usage_price.forecast_price = price_cost[1]
                usage_price.save()

        for ut, prices in ut_prices_costs:
            if ut.by_warehouse:
                for i, prices_wh in enumerate(prices):
                    warehouse = self.warehouses[i]
                    add_usage_price(ut, prices_wh, warehouse)
            else:
                add_usage_price(ut, prices)

        # usage of service resources
        start = datetime.date(2013, 10, 8)
        end = datetime.date(2013, 10, 22)
        service_usage_types = models.UsageType.objects.filter(type='SU')
        for i, ut in enumerate(service_usage_types, start=1):
            days = rrule.rrule(rrule.DAILY, dtstart=start, until=end)
            for j, day in enumerate(days, start=1):
                for k, venture in enumerate(self.not_service_ventures,
                                            start=1):
                    daily_usage = models.DailyUsage(
                        date=day,
                        pricing_venture=venture,
                        value=10 * i * k,
                        type=ut,
                    )
                    daily_usage.save()

        self.maxDiff = None
Пример #11
0
 def test_venture_model(self):
     venture = models.Venture(venture_id=3)
     venture.save()
     venture = models.Venture.objects.get(venture_id=3)
     self.assertEquals(venture.venture_id, 3)
Пример #12
0
    def setUp(self):
        # set up decimal precision to make comparisons easier
        decimal_context = getcontext()
        self.__prev_decimal_prec = decimal_context.prec
        decimal_context.prec = 4

        self.plugin = Team

        # usage type
        self.usage_type = models.UsageType(
            name='Teams',
            symbol='Teams',
            by_team=True,
            type='BU',
        )
        self.usage_type.save()

        # teams
        self.team_time = models.Team(
            name='T1',
            billing_type='TIME',
            show_percent_column=True,
        )
        self.team_time.save()
        self.team_devices_cores = models.Team(
            name='T2',
            billing_type='DEVICES_CORES',
        )
        self.team_devices_cores.save()
        self.team_devices = models.Team(
            name='T3',
            billing_type='DEVICES',
        )
        self.team_devices.save()
        self.team_distribute = models.Team(
            name='T4',
            billing_type='DISTRIBUTE',
        )
        self.team_distribute.save()
        self.teams = models.Team.objects.all()

        # dateranges
        self.daterange1 = models.TeamDaterange(
            team=self.team_time,
            start=date(2013, 10, 1),
            end=date(2013, 10, 10),
        )
        self.daterange1.save()
        self.daterange2 = models.TeamDaterange(
            team=self.team_time,
            start=date(2013, 10, 11),
            end=date(2013, 10, 30),
        )
        self.daterange2.save()

        # costs
        # team time
        up = models.UsagePrice(
            type=self.usage_type,
            cost=300,
            forecast_cost=600,
            start=date(2013, 10, 1),
            end=date(2013, 10, 15),
            team=self.team_time,
            team_members_count=10,
        )
        up.save()
        up = models.UsagePrice(
            type=self.usage_type,
            cost=900,
            forecast_cost=450,
            start=date(2013, 10, 16),
            end=date(2013, 10, 30),
            team=self.team_time,
            team_members_count=20,
        )
        up.save()

        up = models.UsagePrice(
            type=self.usage_type,
            cost=300,
            forecast_cost=600,
            start=date(2013, 10, 1),
            end=date(2013, 10, 30),
            team=self.team_devices_cores,
            team_members_count=20,
        )
        up.save()

        up = models.UsagePrice(
            type=self.usage_type,
            cost=800,
            forecast_cost=1600,
            start=date(2013, 10, 1),
            end=date(2013, 10, 10),
            team=self.team_devices,
            team_members_count=20,
        )
        up.save()
        up = models.UsagePrice(
            type=self.usage_type,
            cost=100,
            forecast_cost=200,
            start=date(2013, 10, 11),
            end=date(2013, 10, 30),
            team=self.team_devices,
            team_members_count=10,
        )
        up.save()

        up = models.UsagePrice(
            type=self.usage_type,
            cost=3000,
            forecast_cost=1500,
            start=date(2013, 10, 1),
            end=date(2013, 10, 15),
            team=self.team_distribute,
            team_members_count=10,
        )
        up.save()
        up = models.UsagePrice(
            type=self.usage_type,
            cost=6000,
            forecast_cost=3000,
            start=date(2013, 10, 16),
            end=date(2013, 10, 30),
            team=self.team_distribute,
            team_members_count=10,
        )
        up.save()

        # ventures
        self.venture1 = models.Venture(name='V1', venture_id=1, is_active=True)
        self.venture1.save()
        self.venture2 = models.Venture(name='V2', venture_id=2, is_active=True)
        self.venture2.save()
        self.venture3 = models.Venture(name='V3', venture_id=3, is_active=True)
        self.venture3.save()
        self.ventures = models.Venture.objects.all()

        # ventures percentage (only for time team)
        percentage = (
            (self.daterange1, [30, 30, 40]),
            (self.daterange2, [20, 50, 30]),
        )
        for team_daterange, percent in percentage:
            for venture, p in zip(self.ventures, percent):
                tvp = models.TeamVenturePercent(
                    team_daterange=team_daterange,
                    venture=venture,
                    percent=p,
                )
                tvp.save()