예제 #1
0
 def test_project_effective_costs(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual((self.test_project.planned_costs()).__str__(),
                      "6000.0")
     StandardWorkFactory.create(human_resource=self.human_resource,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_1,
                                task=self.test_1st_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(human_resource=self.human_resource,
                                date=date_now,
                                start_time=datetime_later_1,
                                stop_time=datetime_later_2,
                                task=self.test_1st_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(human_resource=self.human_resource,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_3,
                                task=self.test_2nd_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(human_resource=self.human_resource,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_4,
                                task=self.test_2nd_task,
                                reporting_period=self.test_reporting_period)
     self.assertEqual((self.test_project.effective_costs(
         reporting_period=None)).__str__(), "1755.0")
예제 #2
0
 def test_work_delete(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     self.datetime_later_3 = make_date_utc(
         datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual((self.test_1st_task.planned_duration()).__str__(),
                      "60")
     self.assertEqual((self.test_1st_task.planned_costs()).__str__(), "0")
     self.assertEqual((self.test_2nd_task.planned_duration()).__str__(),
                      "90")
     self.assertEqual((self.test_2nd_task.planned_costs()).__str__(), "0")
     StandardWorkFactory.create(human_resource=self.human_resource,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_1,
                                task=self.test_1st_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(human_resource=self.human_resource,
                                date=date_now,
                                start_time=datetime_later_1,
                                stop_time=datetime_later_2,
                                task=self.test_1st_task,
                                reporting_period=self.test_reporting_period)
     work_cannot_be_deleted = StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=self.datetime_later_3,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period)
     work_can_be_deleted = StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_4,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period)
     self.assertEqual((self.test_1st_task.effective_effort(
         reporting_period=None)).__str__(), "3.5")
     self.assertEqual((self.test_2nd_task.effective_effort(
         reporting_period=None)).__str__(), "12.0")
     work_can_be_deleted.delete()
     self.assertEqual((self.test_1st_task.effective_effort(
         reporting_period=None)).__str__(), "3.5")
     self.assertEqual((self.test_2nd_task.effective_effort(
         reporting_period=None)).__str__(), "5.75")
     status_done = DoneReportingPeriodStatusFactory.create()
     self.test_reporting_period.status = status_done
     with pytest.raises(ReportingPeriodDoneDeleteNotPossible):
         work_cannot_be_deleted.delete()
     with pytest.raises(ReportingPeriodDoneDeleteNotPossible):
         work_cannot_be_deleted.stop_time = self.datetime_later_3
         work_cannot_be_deleted.save()
예제 #3
0
 def test_task_effective_costs_no_agreement(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual(
         (self.test_1st_task.planned_duration()).__str__(), "60")
     self.assertEqual(
         (self.test_1st_task.planned_costs()).__str__(), "0")
     self.assertEqual(
         (self.test_2nd_task.planned_duration()).__str__(), "90")
     self.assertEqual(
         (self.test_2nd_task.planned_costs()).__str__(), "0")
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_1,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_later_1,
         stop_time=datetime_later_2,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_3,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_4,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     self.assertEqual(
         (self.test_1st_task.effective_effort(reporting_period=None)).__str__(), "3.5")
     self.assertEqual(
         (self.test_1st_task.effective_costs(reporting_period=None)).__str__(), "420.00")
     self.assertEqual(
         (self.test_2nd_task.effective_effort(reporting_period=None)).__str__(), "12.0")
     self.assertEqual(
         (self.test_2nd_task.effective_costs(reporting_period=None)).__str__(), "1440.0")
 def test_task_effective_costs_with_agreement(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual(
         (self.test_1st_task.planned_duration()).__str__(), "60")
     self.assertEqual(
         (self.test_1st_task.planned_costs()).__str__(), "2400.0")
     self.assertEqual(
         (self.test_2nd_task.planned_duration()).__str__(), "90")
     self.assertEqual(
         (self.test_2nd_task.planned_costs()).__str__(), "3600.0")
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_1,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_later_1,
         stop_time=datetime_later_2,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_3,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_4,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     self.assertEqual(
         (self.test_1st_task.effective_effort(reporting_period=None)).__str__(), "3.5")
     self.assertEqual(
         (self.test_1st_task.effective_costs(reporting_period=None)).__str__(), "315.00")
     self.assertEqual(
         (self.test_2nd_task.effective_effort(reporting_period=None)).__str__(), "12.0")
     self.assertEqual(
         (self.test_2nd_task.effective_costs(reporting_period=None)).__str__(), "1440.0")
예제 #5
0
class HighPriceFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ProductPrice

    product_type = factory.SubFactory(StandardProductFactory)
    unit = factory.SubFactory(StandardUnitFactory)
    currency = factory.SubFactory(StandardCurrencyFactory)
    customer_group = factory.SubFactory(StandardCustomerGroupFactory)
    price = "250.50"
    valid_from = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    valid_until = make_date_utc(datetime.datetime(2024, 6, 15, 00))
예제 #6
0
class StandardEstimationToTaskFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Estimation

    amount = "112.50"
    task = factory.SubFactory(StandardTaskFactory)
    resource = factory.SubFactory(StandardResourceFactory)
    date_from = make_date_utc(datetime.datetime(2018, 5, 2, 00))
    date_until = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    status = factory.SubFactory(StartedEstimationStatusFactory)
    reporting_period = factory.SubFactory(StandardReportingPeriodFactory)
예제 #7
0
class StandardResourcePriceFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ResourcePrice

    resource = factory.SubFactory(StandardResourceFactory)
    unit = factory.SubFactory(StandardUnitFactory)
    currency = factory.SubFactory(StandardCurrencyFactory)
    customer_group = factory.SubFactory(StandardCustomerGroupFactory)
    price = "100.50"
    valid_from = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    valid_until = make_date_utc(datetime.datetime(2024, 6, 15, 00))
예제 #8
0
class StandardTaskFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Task

    title = 'This is a test Task'
    planned_start_date = make_date_utc(datetime.datetime(2018, 5, 2, 00))
    planned_end_date = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    project = factory.SubFactory(StandardProjectFactory)
    description = "This is a description"
    status = factory.SubFactory(StartedTaskStatusFactory)
    last_status_change = make_date_utc(datetime.datetime(2018, 6, 15, 00))
예제 #9
0
class HighResourcePriceFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ResourcePrice
        django_get_or_create = ('product',
                                'price')

    resource = factory.SubFactory(StandardResourceFactory)
    unit = factory.SubFactory(StandardUnitFactory)
    currency = factory.SubFactory(StandardCurrencyFactory)
    customer_group = factory.SubFactory(StandardCustomerGroupFactory)
    price = "250.50"
    valid_from = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    valid_until = make_date_utc(datetime.datetime(2024, 6, 15, 00))
예제 #10
0
class StandardAgreementToTaskFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Agreement

    date_from = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    date_until = make_date_utc(datetime.datetime(2024, 6, 15, 00))
    amount = "112.50"
    task = factory.SubFactory(StandardTaskFactory)
    resource = factory.SubFactory(StandardResourceFactory)
    unit = factory.SubFactory(StandardUnitFactory)
    status = factory.SubFactory(AgreedAgreementStatusFactory)
    costs = factory.SubFactory(StandardResourcePriceFactory)
    type = factory.SubFactory(StandardAgreementTypeFactory)
예제 #11
0
class StandardProductTypeFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ProductType
        django_get_or_create = ('product_type_identifier',)

    title = "This is a test Product"
    description = "This is a test Product"
    product_type_identifier = "123456"
    default_unit = factory.SubFactory(StandardUnitFactory)
    date_of_creation = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    last_modification = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    last_modified_by = factory.SubFactory(StaffUserFactory)
    tax = factory.SubFactory(StandardTaxFactory)
예제 #12
0
class StandardPriceFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ProductPrice
        django_get_or_create = ('product_type', 'unit', 'currency',
                                'customer_group', 'price', 'valid_from',
                                'valid_until')

    product_type = factory.SubFactory(StandardProductFactory)
    unit = factory.SubFactory(StandardUnitFactory)
    currency = factory.SubFactory(StandardCurrencyFactory)
    customer_group = factory.SubFactory(StandardCustomerGroupFactory)
    price = "100.50"
    valid_from = make_date_utc(datetime.datetime(2018, 6, 15, 00))
    valid_until = make_date_utc(datetime.datetime(2024, 6, 15, 00))
예제 #13
0
    def setUp(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        start_date = (datetime_now - datetime.timedelta(days=30)).date()
        end_date_first_task = (datetime_now +
                               datetime.timedelta(days=30)).date()
        end_date_second_task = (datetime_now +
                                datetime.timedelta(days=60)).date()

        self.test_billing_cycle = StandardCustomerBillingCycleFactory.create()
        self.test_user = AdminUserFactory.create()
        self.test_customer_group = StandardCustomerGroupFactory.create()
        self.test_customer = StandardCustomerFactory.create(
            is_member_of=(self.test_customer_group, ))
        self.test_currency = StandardCurrencyFactory.create()
        self.human_resource = StandardHumanResourceFactory.create()
        self.test_reporting_period = StandardReportingPeriodFactory.create()
        self.test_1st_task = StandardTaskFactory.create(
            title="1st Test Task", project=self.test_reporting_period.project)
        self.estimation_1st_task = StandardHumanResourceEstimationToTaskFactory(
            task=self.test_1st_task,
            date_from=start_date,
            date_until=end_date_first_task)
        self.test_2nd_task = StandardTaskFactory.create(
            title="2nd Test Task", project=self.test_reporting_period.project)
        self.estimation_2nd_task = StandardHumanResourceEstimationToTaskFactory(
            task=self.test_2nd_task,
            date_from=start_date,
            date_until=end_date_second_task)
예제 #14
0
 def test_planned_effort(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     self.assertEqual((self.test_1st_task.planned_duration()).__str__(),
                      "60")
     self.assertEqual((self.test_1st_task.planned_effort()).__str__(), "0")
     self.assertEqual((self.test_2nd_task.planned_duration()).__str__(),
                      "90")
     self.assertEqual((self.test_2nd_task.planned_effort()).__str__(), "0")
     StandardEmployeeAssignmentToTaskFactory.create(
         employee=self.test_user_extension,
         planned_effort="2.00",
         task=self.test_1st_task)
     StandardEmployeeAssignmentToTaskFactory.create(
         employee=self.test_user_extension,
         planned_effort="1.50",
         task=self.test_1st_task)
     StandardEmployeeAssignmentToTaskFactory.create(
         employee=self.test_user_extension,
         planned_effort="4.75",
         task=self.test_2nd_task)
     StandardEmployeeAssignmentToTaskFactory.create(
         employee=self.test_user_extension,
         planned_effort="3.25",
         task=self.test_2nd_task)
     self.assertEqual((self.test_1st_task.planned_effort()).__str__(),
                      "3.50")
     self.assertEqual((self.test_1st_task.effective_effort(
         reporting_period=None)).__str__(), "0.0")
     self.assertEqual((self.test_2nd_task.planned_effort()).__str__(),
                      "8.00")
     self.assertEqual((self.test_2nd_task.effective_effort(
         reporting_period=None)).__str__(), "0.0")
 def setUp(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     start_date = (datetime_now - datetime.timedelta(days=30)).date()
     end_date = (datetime_now + datetime.timedelta(days=30)).date()
     self.tax = StandardTaxFactory.create(tax_rate=10)
     self.test_currency_with_rounding = StandardCurrencyFactory.create(rounding=1)
     self.test_currency_without_rounding = StandardCurrencyFactory.create(
         rounding=None,
         description='Euro',
         short_name='EUR'
     )
     self.alternative_currency = self.test_currency_without_rounding
     self.customer_group = StandardCustomerGroupFactory.create()
     self.alternative_customer_group = AdvancedCustomerGroupFactory.create()
     self.customer = StandardCustomerFactory.create()
     self.customer.is_member_of.add(self.customer_group)
     self.customer.save()
     self.unit = StandardUnitFactory.create()
     self.alternative_unit = SmallUnitFactory.create()
     self.product_without_dates = StandardProductTypeFactory.create(
         product_type_identifier="A",
         tax=self.tax
     )
     self.price_without_customer_group = StandardPriceFactory.create(
         product_type=self.product_without_dates,
         customer_group=None,
         price=100,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         valid_from=start_date,
         valid_until=end_date
     )
    def setUp(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        start_date = (datetime_now - datetime.timedelta(days=30)).date()
        end_date_first_task = (datetime_now + datetime.timedelta(days=30)).date()
        end_date_second_task = (datetime_now + datetime.timedelta(days=60)).date()

        self.test_billing_cycle = StandardCustomerBillingCycleFactory.create()
        self.test_user = AdminUserFactory.create()
        self.test_unit = StandardUnitFactory.create()
        self.test_customer_group = StandardCustomerGroupFactory.create()
        self.test_customer = StandardCustomerFactory.create(is_member_of=(self.test_customer_group,))
        self.test_currency = StandardCurrencyFactory.create(
            rounding="0.05"
        )
        self.human_resource = StandardHumanResourceFactory.create()
        self.human_resource_two = StandardHumanResourceFactory.create()
        self.resource_price = StandardResourcePriceFactory.create(
            resource=self.human_resource,
            unit=self.test_unit,
            currency=self.test_currency,
            customer_group=self.test_customer_group,
            price="120",
        )
        self.resource_price_agreement = StandardResourcePriceFactory.create(
            resource=self.human_resource_two,
            unit=self.test_unit,
            currency=self.test_currency,
            customer_group=self.test_customer_group,
            price="90",
        )
        self.test_reporting_period = StandardReportingPeriodFactory.create()
        self.test_1st_task = StandardTaskFactory.create(
            title="1st Test Task",
            project=self.test_reporting_period.project
        )
        self.agreement_1st_task = StandardAgreementToTaskFactory(
            amount="3.50",
            task=self.test_1st_task,
            resource=self.human_resource,
            unit=self.test_unit,
            costs=self.resource_price_agreement
        )
        self.estimation_1st_task = StandardHumanResourceEstimationToTaskFactory(
            resource=self.human_resource,
            task=self.test_1st_task,
            date_from=start_date,
            date_until=end_date_first_task,
            amount=20
        )
        self.test_2nd_task = StandardTaskFactory.create(
            title="2nd Test Task",
            project=self.test_reporting_period.project
        )
        self.estimation_2nd_task = StandardHumanResourceEstimationToTaskFactory(
            resource=self.human_resource,
            task=self.test_2nd_task,
            date_from=start_date,
            date_until=end_date_second_task,
            amount=30
        )
예제 #17
0
    def setUp(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        start_date = (datetime_now - datetime.timedelta(days=30)).date()
        end_date_first_task = (datetime_now +
                               datetime.timedelta(days=30)).date()
        end_date_second_task = (datetime_now +
                                datetime.timedelta(days=60)).date()

        self.test_billing_cycle = StandardCustomerBillingCycleFactory.create()
        self.test_user = AdminUserFactory.create()
        self.test_customer_group = StandardCustomerGroupFactory.create()
        self.test_customer = StandardCustomerFactory.create(
            is_member_of=(self.test_customer_group, ))
        self.test_currency = StandardCurrencyFactory.create()
        self.test_user_extension = StandardUserExtensionFactory.create(
            user=self.test_user)
        self.test_reporting_period = StandardReportingPeriodFactory.create()
        self.test_1st_task = StandardTaskFactory.create(
            title="1st Test Task",
            planned_start_date=start_date,
            planned_end_date=end_date_first_task,
            project=self.test_reporting_period.project)
        self.test_2nd_task = StandardTaskFactory.create(
            title="2nd Test Task",
            planned_start_date=start_date,
            planned_end_date=end_date_second_task,
            project=self.test_reporting_period.project)
예제 #18
0
    def setUp(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        start_date = (datetime_now - datetime.timedelta(days=30)).date()
        end_date_first_task = (datetime_now +
                               datetime.timedelta(days=30)).date()
        end_date_second_task = (datetime_now +
                                datetime.timedelta(days=60)).date()

        self.test_billing_cycle = StandardCustomerBillingCycleFactory.create()
        self.test_user = AdminUserFactory.create()
        self.test_unit = StandardUnitFactory.create()
        self.test_customer_group = StandardCustomerGroupFactory.create()
        self.test_customer = StandardCustomerFactory.create(
            is_member_of=(self.test_customer_group, ))
        self.test_currency = StandardCurrencyFactory.create(rounding="0.05")
        self.human_resource = StandardHumanResourceFactory.create()
        self.human_resource_two = StandardHumanResourceFactory.create()
        self.resource_price = StandardResourcePriceFactory.create(
            resource=self.human_resource,
            unit=self.test_unit,
            currency=self.test_currency,
            customer_group=self.test_customer_group,
            price="120",
        )
        self.resource_price_agreement = StandardResourcePriceFactory.create(
            resource=self.human_resource_two,
            unit=self.test_unit,
            currency=self.test_currency,
            customer_group=self.test_customer_group,
            price="90",
        )
        self.test_project = StandardProjectFactory.create()
        self.test_reporting_period = StandardReportingPeriodFactory.create(
            project=self.test_project)
        self.test_1st_task = StandardTaskFactory.create(
            title="1st Test Task", project=self.test_project)
        self.agreement_1st_task = StandardAgreementToTaskFactory(
            amount="3.50",
            task=self.test_1st_task,
            resource=self.human_resource,
            unit=self.test_unit,
            costs=self.resource_price_agreement)
        self.estimation_1st_task = StandardHumanResourceEstimationToTaskFactory(
            resource=self.human_resource,
            task=self.test_1st_task,
            date_from=start_date,
            date_until=end_date_first_task,
            amount=20)
        self.test_2nd_task = StandardTaskFactory.create(
            title="2nd Test Task", project=self.test_project)
        self.estimation_2nd_task = StandardHumanResourceEstimationToTaskFactory(
            resource=self.human_resource,
            task=self.test_2nd_task,
            date_from=start_date,
            date_until=end_date_second_task,
            amount=30)
 def test_project_effective_costs(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual(
         (self.test_project.planned_costs()).__str__(), "6000.0")
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_1,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_later_1,
         stop_time=datetime_later_2,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_3,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_4,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     self.assertEqual(
         (self.test_project.effective_costs(reporting_period=None)).__str__(), "1755.0")
예제 #20
0
 def test_effective_effort(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual((self.test_1st_task.planned_duration()).__str__(),
                      "60")
     self.assertEqual((self.test_1st_task.planned_effort()).__str__(), "0")
     self.assertEqual((self.test_2nd_task.planned_duration()).__str__(),
                      "90")
     self.assertEqual((self.test_2nd_task.planned_effort()).__str__(), "0")
     StandardWorkFactory.create(employee=self.test_user_extension,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_1,
                                task=self.test_1st_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(employee=self.test_user_extension,
                                date=date_now,
                                start_time=datetime_later_1,
                                stop_time=datetime_later_2,
                                task=self.test_1st_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(employee=self.test_user_extension,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_3,
                                task=self.test_2nd_task,
                                reporting_period=self.test_reporting_period)
     StandardWorkFactory.create(employee=self.test_user_extension,
                                date=date_now,
                                start_time=datetime_now,
                                stop_time=datetime_later_4,
                                task=self.test_2nd_task,
                                reporting_period=self.test_reporting_period)
     self.assertEqual((self.test_1st_task.effective_effort(
         reporting_period=None)).__str__(), "3.5")
     self.assertEqual((self.test_2nd_task.effective_effort(
         reporting_period=None)).__str__(), "12.0")
예제 #21
0
 def test_project_planned_costs(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     start_date = (datetime_now - datetime.timedelta(days=30)).date()
     end_date_first_task = (datetime_now + datetime.timedelta(days=30)).date()
     end_date_second_task = (datetime_now + datetime.timedelta(days=60)).date()
     self.assertEqual(
         (self.test_project.planned_costs()).__str__(), "0")
     self.test_reporting_period = StandardReportingPeriodFactory.create(
         project=self.test_project
     )
     self.assertEqual(
         (self.test_project.planned_costs()).__str__(), "0")
     self.test_1st_task = StandardTaskFactory.create(title="1st Test Task",
                                                     project=self.test_project)
     self.test_2nd_task = StandardTaskFactory.create(title="2nd Test Task",
                                                     project=self.test_project)
     self.assertEqual(
         (self.test_project.planned_costs()).__str__(), "0")
     self.estimation_1st_task = StandardHumanResourceEstimationToTaskFactory(task=self.test_1st_task,
                                                                             date_from=start_date,
                                                                             date_until=end_date_first_task,
                                                                             amount=0)
     self.estimation_2nd_task = StandardHumanResourceEstimationToTaskFactory(task=self.test_2nd_task,
                                                                             date_from=start_date,
                                                                             date_until=end_date_second_task,
                                                                             amount=0)
     self.resource_price = StandardResourcePriceFactory.create(
         resource=self.test_human_resource,
         unit=self.test_unit,
         currency=self.test_currency,
         customer_group=self.test_customer_group,
         price="120",
     )
     self.assertEqual(
         (self.test_project.planned_costs()).__str__(), "0")
     StandardEstimationToTaskFactory.create(resource=self.test_human_resource,
                                            amount="2.00",
                                            task=self.test_1st_task,
                                            reporting_period=self.test_reporting_period)
     StandardEstimationToTaskFactory.create(resource=self.test_human_resource,
                                            amount="1.50",
                                            task=self.test_1st_task,
                                            reporting_period=self.test_reporting_period)
     StandardEstimationToTaskFactory.create(resource=self.test_human_resource,
                                            amount="4.75",
                                            task=self.test_2nd_task,
                                            reporting_period=self.test_reporting_period)
     StandardEstimationToTaskFactory.create(resource=self.test_human_resource,
                                            amount="3.25",
                                            task=self.test_2nd_task,
                                            reporting_period=self.test_reporting_period)
     self.assertEqual(
         (self.test_project.planned_costs(reporting_period=self.test_reporting_period)).__str__(), "1380.0")
예제 #22
0
class StandardWorkFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Work

    human_resource = factory.SubFactory(StandardUserExtensionFactory)
    date = make_date_utc(datetime.datetime(2018, 5, 1, 0, 00))
    start_time = None
    stop_time = None
    worked_hours = "1.50"
    short_description = "The employee did some work"
    description = "And here he describes some more about his work"
    task = factory.SubFactory(StandardTaskFactory)
    reporting_period = factory.SubFactory(StandardReportingPeriodFactory)
예제 #23
0
 def test_calculate_document_price_without_date_until(self):
     quote_3 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_without_date_until,
         overwrite_product_price=False,
         sales_document=quote_3)
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(document=quote_3,
                                           pricing_date=date_now)
     self.assertEqual(quote_3.last_calculated_price.__str__(), "117.00")
     self.assertEqual(quote_3.last_calculated_tax.__str__(), "13.00")
예제 #24
0
 def test_calculate_document_with_unit_transform(self):
     quote_10 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_with_alternative_unit,
         overwrite_product_price=False,
         sales_document=quote_10)
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(document=quote_10,
                                           pricing_date=date_now)
     self.assertEqual(quote_10.last_calculated_price.__str__(), "36.00")
     self.assertEqual(quote_10.last_calculated_tax.__str__(), "4.00")
예제 #25
0
 def test_calculate_document_price_with_currency_rounding(self):
     quote_5 = StandardQuoteFactory.create(
         customer=self.customer, currency=self.test_currency_with_rounding)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=7.5,
         unit=self.unit,
         product_type=self.product_with_currency_rounding,
         overwrite_product_price=False,
         sales_document=quote_5)
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(document=quote_5,
                                           pricing_date=date_now)
     self.assertEqual(quote_5.last_calculated_price.__str__(), "27")
     self.assertEqual(quote_5.last_calculated_tax.__str__(), "3")
 def test_calculate_document_with_unit_transform(self):
     quote_10 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_with_alternative_unit,
         overwrite_product_price=False,
         sales_document=quote_10
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_10,
         pricing_date=date_now)
     self.assertEqual(
         quote_10.last_calculated_price.__str__(), "36.00")
     self.assertEqual(
         quote_10.last_calculated_tax.__str__(), "4.00")
 def test_calculate_document_price_without_date_until(self):
     quote_3 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         unit=self.unit,
         product_type=self.product_without_date_until,
         overwrite_product_price=False,
         sales_document=quote_3
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_3,
         pricing_date=date_now)
     self.assertEqual(
         quote_3.last_calculated_price.__str__(), "117.00")
     self.assertEqual(
         quote_3.last_calculated_tax.__str__(), "13.00")
 def test_calculate_document_price_overwritten(self):
     quote_1 = StandardQuoteFactory.create(customer=self.customer)
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=0,
         product_type=self.product_without_dates,
         overwrite_product_price=True,
         position_price_per_unit=90,
         unit=self.unit,
         sales_document=quote_1
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_1,
         pricing_date=date_now)
     self.assertEqual(
         quote_1.last_calculated_price.__str__(), "81.00")
     self.assertEqual(
         quote_1.last_calculated_tax.__str__(), "9.00")
    def setUp(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        start_date = (datetime_now - datetime.timedelta(days=30))
        end_date_first_task = (datetime_now + datetime.timedelta(days=30))
        end_date_second_task = (datetime_now + datetime.timedelta(days=60))

        self.test_billing_cycle = StandardCustomerBillingCycleFactory.create()
        self.test_customer_group = StandardCustomerGroupFactory.create()
        self.test_customer = StandardCustomerFactory.create(is_member_of=(self.test_customer_group,))
        self.test_currency = StandardCurrencyFactory.create()
        self.human_resource = StandardHumanResourceFactory.create()
        self.test_reporting_period = StandardReportingPeriodFactory.create()
        self.test_1st_task = StandardTaskFactory.create(title="1st Test Task",
                                                        project=self.test_reporting_period.project)
        self.estimation_1st_task = StandardHumanResourceEstimationToTaskFactory(task=self.test_1st_task,
                                                                                date_from=start_date,
                                                                                date_until=end_date_first_task)
        self.test_2nd_task = StandardTaskFactory.create(title="2nd Test Task",
                                                        project=self.test_reporting_period.project)
        self.estimation_2nd_task = StandardHumanResourceEstimationToTaskFactory(task=self.test_2nd_task,
                                                                                date_from=start_date,
                                                                                date_until=end_date_second_task)
 def test_calculate_document_price_without_currency_rounding(self):
     quote_6 = StandardQuoteFactory.create(
         customer=self.customer,
         currency=self.test_currency_without_rounding
     )
     StandardSalesDocumentPositionFactory.create(
         quantity=1,
         discount=7.5,
         unit=self.unit,
         product_type=self.product_without_currency_rounding,
         overwrite_product_price=False,
         sales_document=quote_6
     )
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     date_now = datetime_now.date()
     Calculations.calculate_document_price(
         document=quote_6,
         pricing_date=date_now)
     self.assertEqual(
         quote_6.last_calculated_price.__str__(), "20.80")
     self.assertEqual(
         quote_6.last_calculated_tax.__str__(), "2.30")
    def test_effective_duration(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 2, 2, 00))
        datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 2, 3, 30))
        datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 4, 5, 45))
        datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 4, 6, 15))
        self.assertEqual(
            (self.test_1st_task.planned_duration()).__str__(), "60")
        self.assertEqual(
            (self.test_1st_task.effective_duration()).__str__(), "0")
        self.assertEqual(
            (self.test_2nd_task.planned_duration()).__str__(), "90")
        self.assertEqual(
            (self.test_2nd_task.effective_duration()).__str__(), "0")

        new_status = DoneTaskStatusFactory.create()
        self._freeze.freeze(datetime.date(2024, 2, 2))
        self.test_1st_task.status = new_status
        self.test_1st_task.save()
        self._freeze.freeze(datetime.date(2024, 2, 5))
        self.test_2nd_task.status = new_status
        self.test_2nd_task.save()

        self.assertEqual(
            (self.test_1st_task.planned_duration()).__str__(), "60")
        self.assertEqual(
            (self.test_1st_task.effective_duration()).__str__(), "62")
        self.assertEqual(
            (self.test_2nd_task.planned_duration()).__str__(), "90")
        self.assertEqual(
            (self.test_2nd_task.effective_duration()).__str__(), "65")

        StandardWorkFactory.create(
            human_resource=self.human_resource,
            date=datetime_now,
            start_time=datetime_now,
            stop_time=datetime_later_1,
            task=self.test_1st_task,
            reporting_period=self.test_reporting_period
        )
        StandardWorkFactory.create(
            human_resource=self.human_resource,
            date=datetime_later_2,
            start_time=datetime_later_1,
            stop_time=datetime_later_2,
            task=self.test_1st_task,
            reporting_period=self.test_reporting_period
        )
        StandardWorkFactory.create(
            human_resource=self.human_resource,
            date=datetime_now,
            start_time=datetime_now,
            stop_time=datetime_later_3,
            task=self.test_2nd_task,
            reporting_period=self.test_reporting_period
        )
        StandardWorkFactory.create(
            human_resource=self.human_resource,
            date=datetime_later_4,
            start_time=datetime_now,
            stop_time=datetime_later_4,
            task=self.test_2nd_task,
            reporting_period=self.test_reporting_period
        )

        self.assertEqual(
            (self.test_1st_task.planned_duration()).__str__(), "60")
        self.assertEqual(
            (self.test_1st_task.effective_duration()).__str__(), "1")
        self.assertEqual(
            (self.test_2nd_task.planned_duration()).__str__(), "90")
        self.assertEqual(
            (self.test_2nd_task.effective_duration()).__str__(), "3")
    def test_effective_duration(self):
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 2, 2, 00))
        datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 2, 3, 30))
        datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 4, 5, 45))
        datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 4, 6, 15))
        self.assertEqual((self.test_1st_task.planned_duration()).__str__(),
                         "60")
        self.assertEqual((self.test_1st_task.effective_duration()).__str__(),
                         "0")
        self.assertEqual((self.test_2nd_task.planned_duration()).__str__(),
                         "90")
        self.assertEqual((self.test_2nd_task.effective_duration()).__str__(),
                         "0")

        new_status = DoneTaskStatusFactory.create()
        self._freeze.freeze(datetime.date(2024, 2, 2))
        self.test_1st_task.status = new_status
        self.test_1st_task.save()
        self._freeze.freeze(datetime.date(2024, 2, 5))
        self.test_2nd_task.status = new_status
        self.test_2nd_task.save()

        self.assertEqual((self.test_1st_task.planned_duration()).__str__(),
                         "60")
        self.assertEqual((self.test_1st_task.effective_duration()).__str__(),
                         "62")
        self.assertEqual((self.test_2nd_task.planned_duration()).__str__(),
                         "90")
        self.assertEqual((self.test_2nd_task.effective_duration()).__str__(),
                         "65")

        StandardWorkFactory.create(human_resource=self.human_resource,
                                   date=datetime_now,
                                   start_time=datetime_now,
                                   stop_time=datetime_later_1,
                                   task=self.test_1st_task,
                                   reporting_period=self.test_reporting_period)
        StandardWorkFactory.create(human_resource=self.human_resource,
                                   date=datetime_later_2,
                                   start_time=datetime_later_1,
                                   stop_time=datetime_later_2,
                                   task=self.test_1st_task,
                                   reporting_period=self.test_reporting_period)
        StandardWorkFactory.create(human_resource=self.human_resource,
                                   date=datetime_now,
                                   start_time=datetime_now,
                                   stop_time=datetime_later_3,
                                   task=self.test_2nd_task,
                                   reporting_period=self.test_reporting_period)
        StandardWorkFactory.create(human_resource=self.human_resource,
                                   date=datetime_later_4,
                                   start_time=datetime_now,
                                   stop_time=datetime_later_4,
                                   task=self.test_2nd_task,
                                   reporting_period=self.test_reporting_period)

        self.assertEqual((self.test_1st_task.planned_duration()).__str__(),
                         "60")
        self.assertEqual((self.test_1st_task.effective_duration()).__str__(),
                         "1")
        self.assertEqual((self.test_2nd_task.planned_duration()).__str__(),
                         "90")
        self.assertEqual((self.test_2nd_task.effective_duration()).__str__(),
                         "3")
예제 #33
0
 def setUp(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     start_date = (datetime_now - datetime.timedelta(days=30)).date()
     end_date = (datetime_now + datetime.timedelta(days=30)).date()
     self.tax = StandardTaxFactory.create(tax_rate=10)
     self.test_currency_with_rounding = StandardCurrencyFactory.create(
         rounding=1)
     self.test_currency_without_rounding = StandardCurrencyFactory.create(
         rounding=None, description='Euro', short_name='EUR')
     self.alternative_currency = self.test_currency_without_rounding
     self.customer_group = StandardCustomerGroupFactory.create()
     self.alternative_customer_group = AdvancedCustomerGroupFactory.create()
     self.customer = StandardCustomerFactory.create()
     self.customer.is_member_of.add(self.customer_group)
     self.customer.save()
     self.unit = StandardUnitFactory.create()
     self.alternative_unit = SmallUnitFactory.create()
     self.product_without_dates = StandardProductTypeFactory.create(
         product_type_identifier="A", tax=self.tax)
     self.product_without_date_from = StandardProductTypeFactory.create(
         product_type_identifier="B", tax=self.tax)
     self.product_without_date_until = StandardProductTypeFactory.create(
         product_type_identifier="C", tax=self.tax)
     self.product_without_customer_group = StandardProductTypeFactory.create(
         product_type_identifier="D", tax=self.tax)
     self.product_with_currency_rounding = StandardProductTypeFactory.create(
         product_type_identifier="E", tax=self.tax)
     self.product_without_currency_rounding = StandardProductTypeFactory.create(
         product_type_identifier="F", tax=self.tax)
     self.product_with_alternative_customer_group = StandardProductTypeFactory.create(
         product_type_identifier="G", tax=self.tax)
     self.product_with_alternative_unit = StandardProductTypeFactory.create(
         product_type_identifier="H", tax=self.tax)
     self.product_with_alternative_currency = StandardProductTypeFactory.create(
         product_type_identifier="I", tax=self.tax)
     self.price_without_customer_group = StandardPriceFactory.create(
         product_type=self.product_without_customer_group,
         customer_group=None,
         price=100,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         valid_from=start_date,
         valid_until=end_date)
     self.price_without_dates = StandardPriceFactory.create(
         product_type=self.product_without_dates,
         customer_group=self.customer_group,
         valid_from=None,
         valid_until=None,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=80)
     self.price_without_date_to = StandardPriceFactory.create(
         product_type=self.product_without_date_until,
         customer_group=self.customer_group,
         valid_from=start_date,
         valid_until=None,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=130)
     self.price_without_date_from = StandardPriceFactory.create(
         product_type=self.product_without_date_from,
         customer_group=self.customer_group,
         valid_from=None,
         valid_until=end_date,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=50)
     self.price_without_date_from = StandardPriceFactory.create(
         product_type=self.product_without_currency_rounding,
         currency=self.test_currency_without_rounding,
         customer_group=self.customer_group,
         price=25,
         unit=self.unit,
         valid_from=start_date,
         valid_until=end_date)
     self.price_without_date_from = StandardPriceFactory.create(
         product_type=self.product_with_currency_rounding,
         currency=self.test_currency_with_rounding,
         customer_group=self.customer_group,
         price=33,
         unit=self.unit,
         valid_from=start_date,
         valid_until=end_date)
     self.price_with_alternative_customer_group = StandardPriceFactory.create(
         product_type=self.product_with_alternative_customer_group,
         customer_group=self.alternative_customer_group,
         valid_from=start_date,
         valid_until=end_date,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=80)
     self.customer_group_transform = StandardCustomerGroupTransformFactory.create(
         from_customer_group=self.alternative_customer_group,
         to_customer_group=self.customer_group,
         product_type=self.product_with_alternative_customer_group,
         factor=0.50)
     self.price_with_alternative_currency = StandardPriceFactory.create(
         product_type=self.product_with_alternative_currency,
         customer_group=self.customer_group,
         valid_from=start_date,
         valid_until=end_date,
         unit=self.unit,
         currency=self.alternative_currency,
         price=80)
     self.currency_transform = StandardCurrencyTransformFactory.create(
         from_currency=self.alternative_currency,
         to_currency=self.test_currency_with_rounding,
         product_type=self.product_with_alternative_currency,
         factor=0.50)
     self.price_with_alternative_unit = StandardPriceFactory.create(
         product_type=self.product_with_alternative_unit,
         customer_group=self.customer_group,
         valid_from=start_date,
         valid_until=end_date,
         unit=self.alternative_unit,
         currency=self.test_currency_with_rounding,
         price=80)
     self.currency_transform = StandardUnitTransformFactory.create(
         from_unit=self.alternative_unit,
         to_unit=self.unit,
         product_type=self.product_with_alternative_unit,
         factor=0.50)
예제 #34
0
 def setUp(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     valid_from = (datetime_now - datetime.timedelta(days=30)).date()
     valid_until = (datetime_now + datetime.timedelta(days=30)).date()
     date_now = datetime_now.date()
     test_billing_cycle = CustomerBillingCycle.objects.create(
         name="30 days to pay",
         time_to_payment_date=30,
         payment_reminder_time_to_payment=10)
     test_user = User.objects.create(username='******',
                                     password="******")
     test_customer_group = CustomerGroup.objects.create(name="Tripple A")
     test_customer = Customer.objects.create(
         name="John Smith",
         last_modified_by=test_user,
         default_customer_billing_cycle=test_billing_cycle,
     )
     test_customer.is_member_of = [test_customer_group]
     test_customer.save()
     test_currency = Currency.objects.create(
         description="Swiss Francs",
         short_name="CHF",
         rounding=0.05,
     )
     test_contract = Contract.objects.create(
         staff=test_user,
         description="This is a test contract",
         default_customer=test_customer,
         default_currency=test_currency,
         last_modification=date_now,
         last_modified_by=test_user)
     test_unit = Unit.objects.create(
         description="Kilogram",
         short_name="kg",
     )
     test_tax = Tax.objects.create(tax_rate=7.7, name="MwSt 7.7%")
     test_quote = Quote.objects.create(
         valid_until=valid_until,
         status="C",
         contract=test_contract,
         external_reference="ThisIsAnExternalReference",
         discount="11.23",
         description="ThisIsATestOffer",
         customer=test_customer,
         staff=test_user,
         currency=test_currency,
         date_of_creation=date_now,
         last_modified_by=test_user,
     )
     for i in range(10):
         test_product = Product.objects.create(
             description="This is a test product " + i.__str__(),
             title="This is a test product " + i.__str__(),
             product_number=12334235 + i,
             default_unit=test_unit,
             last_modification=date_now,
             last_modified_by=test_user,
             tax=test_tax,
         )
         Price.objects.create(
             product=test_product,
             unit=test_unit,
             currency=test_currency,
             customer_group=test_customer_group,
             price=i * 100,
             valid_from=valid_from,
             valid_until=valid_until,
         )
         SalesDocumentPosition.objects.create(
             sales_document=test_quote,
             position_number=i * 10,
             quantity=0.333 * i,
             description="This is a Testposition " + i.__str__(),
             discount=i * 5,
             product=test_product,
             unit=test_unit,
             overwrite_product_price=False,
         )
예제 #35
0
    def setUp(self):
        user = User.objects.create(username='******', password="******")

        cash = Account.objects.create(account_number="1000",
                                      title="Cash",
                                      account_type="A",
                                      description="Highest liquid asset",
                                      is_open_interest_account=False,
                                      is_open_reliabilities_account=False,
                                      is_product_inventory_activa=False,
                                      is_a_customer_payment_account=True)
        bank_account = Account.objects.create(
            account_number="1300",
            title="Bank Account",
            account_type="A",
            description="Moderate liquid asset",
            is_open_interest_account=False,
            is_open_reliabilities_account=False,
            is_product_inventory_activa=False,
            is_a_customer_payment_account=True)
        bank_loan = Account.objects.create(account_number="2000",
                                           title="Shortterm bankloans",
                                           account_type="L",
                                           description="Shortterm loan",
                                           is_open_interest_account=False,
                                           is_open_reliabilities_account=False,
                                           is_product_inventory_activa=False,
                                           is_a_customer_payment_account=False)
        investment_capital = Account.objects.create(
            account_number="2900",
            title="Investment capital",
            account_type="L",
            description="Very longterm  loan",
            is_open_interest_account=False,
            is_open_reliabilities_account=False,
            is_product_inventory_activa=False,
            is_a_customer_payment_account=False)
        spendings = Account.objects.create(account_number="3000",
                                           title="Spendings",
                                           account_type="S",
                                           description="Purchase spendings",
                                           is_open_interest_account=False,
                                           is_open_reliabilities_account=False,
                                           is_product_inventory_activa=False,
                                           is_a_customer_payment_account=False)
        earnings = Account.objects.create(account_number="4000",
                                          title="Earnings",
                                          account_type="E",
                                          description="Sales account",
                                          is_open_interest_account=False,
                                          is_open_reliabilities_account=False,
                                          is_product_inventory_activa=False,
                                          is_a_customer_payment_account=False)
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        from_date = datetime_now.date()
        to_date = (datetime_now + datetime.timedelta(days=365)).date()
        accounting_period_2024 = AccountingPeriod.objects.create(
            title="Fiscal year 2024", begin=from_date, end=to_date)
        from_date = (datetime_now + datetime.timedelta(days=(365 + 1))).date()
        to_date = (datetime_now + datetime.timedelta(days=(365 * 2))).date()
        accounting_period_2025 = AccountingPeriod.objects.create(
            title="Fiscal year 2025", begin=from_date, end=to_date)
        from_date = (datetime_now +
                     datetime.timedelta(days=(365 * 2 + 1))).date()
        to_date = (datetime_now + datetime.timedelta(days=(365 * 3))).date()
        AccountingPeriod.objects.create(title="Fiscal year 2026",
                                        begin=from_date,
                                        end=to_date)
        Booking.objects.create(from_account=cash,
                               to_account=spendings,
                               amount="1000",
                               description="This is the first booking",
                               booking_date=make_date_utc(
                                   datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2025,
                               staff=user,
                               last_modified_by=user)

        Booking.objects.create(from_account=earnings,
                               to_account=cash,
                               amount="500",
                               description="This is the first booking",
                               booking_date=make_date_utc(
                                   datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2025,
                               staff=user,
                               last_modified_by=user)

        Booking.objects.create(from_account=bank_loan,
                               to_account=cash,
                               amount="5000",
                               description="This is the first booking",
                               booking_date=make_date_utc(
                                   datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2025,
                               staff=user,
                               last_modified_by=user)

        Booking.objects.create(from_account=investment_capital,
                               to_account=bank_account,
                               amount="490000",
                               description="This is the first booking",
                               booking_date=make_date_utc(
                                   datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2024,
                               staff=user,
                               last_modified_by=user)
예제 #36
0
    def setUp(self):
        user = User.objects.create(username='******',
                                   password="******")

        cash = Account.objects.create(account_number="1000",
                                      title="Cash",
                                      account_type="A",
                                      description="Highest liquid asset",
                                      is_open_interest_account=False,
                                      is_open_reliabilities_account=False,
                                      is_product_inventory_activa=False,
                                      is_a_customer_payment_account=True)
        bank_account = Account.objects.create(account_number="1300",
                                              title="Bank Account",
                                              account_type="A",
                                              description="Moderate liquid asset",
                                              is_open_interest_account=False,
                                              is_open_reliabilities_account=False,
                                              is_product_inventory_activa=False,
                                              is_a_customer_payment_account=True)
        bank_loan = Account.objects.create(account_number="2000",
                                      title="Shortterm bankloans",
                                      account_type="L",
                                      description="Shortterm loan",
                                      is_open_interest_account=False,
                                      is_open_reliabilities_account=False,
                                      is_product_inventory_activa=False,
                                      is_a_customer_payment_account=False)
        investment_capital = Account.objects.create(account_number="2900",
                                      title="Investment capital",
                                      account_type="L",
                                      description="Very longterm  loan",
                                      is_open_interest_account=False,
                                      is_open_reliabilities_account=False,
                                      is_product_inventory_activa=False,
                                      is_a_customer_payment_account=False)
        spendings = Account.objects.create(account_number="3000",
                                           title="Spendings",
                                           account_type="S",
                                           description="Purchase spendings",
                                           is_open_interest_account=False,
                                           is_open_reliabilities_account=False,
                                           is_product_inventory_activa=False,
                                           is_a_customer_payment_account=False)
        earnings = Account.objects.create(account_number="4000",
                                          title="Earnings",
                                          account_type="E",
                                          description="Sales account",
                                          is_open_interest_account=False,
                                          is_open_reliabilities_account=False,
                                          is_product_inventory_activa=False,
                                          is_a_customer_payment_account=False)
        datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
        from_date = datetime_now.date()
        to_date = (datetime_now + datetime.timedelta(days=365)).date()
        accounting_period_2024 = AccountingPeriod.objects.create(title="Fiscal year 2024",
                                                                 begin=from_date,
                                                                 end=to_date)
        from_date = (datetime_now + datetime.timedelta(days=(365+1))).date()
        to_date = (datetime_now + datetime.timedelta(days=(365*2))).date()
        accounting_period_2025 = AccountingPeriod.objects.create(title="Fiscal year 2025",
                                        begin=from_date,
                                        end=to_date)
        from_date = (datetime_now + datetime.timedelta(days=(365*2+1))).date()
        to_date = (datetime_now + datetime.timedelta(days=(365*3))).date()
        AccountingPeriod.objects.create(title="Fiscal year 2026",
                                        begin=from_date,
                                        end=to_date)
        Booking.objects.create(from_account=cash,
                               to_account=spendings,
                               amount="1000",
                               description="This is the first booking",
                               booking_date=make_date_utc(datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2025,
                               staff=user,
                               last_modified_by=user)

        Booking.objects.create(from_account=earnings,
                               to_account=cash,
                               amount="500",
                               description="This is the first booking",
                               booking_date=make_date_utc(datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2025,
                               staff=user,
                               last_modified_by=user)

        Booking.objects.create(from_account=bank_loan,
                               to_account=cash,
                               amount="5000",
                               description="This is the first booking",
                               booking_date=make_date_utc(datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2025,
                               staff=user,
                               last_modified_by=user)

        Booking.objects.create(from_account=investment_capital,
                               to_account=bank_account,
                               amount="490000",
                               description="This is the first booking",
                               booking_date=make_date_utc(datetime.datetime(2025, 1, 1, 0, 00)),
                               accounting_period=accounting_period_2024,
                               staff=user,
                               last_modified_by=user)
예제 #37
0
 def test_work_delete(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     datetime_later_1 = make_date_utc(datetime.datetime(2024, 1, 1, 2, 00))
     datetime_later_2 = make_date_utc(datetime.datetime(2024, 1, 1, 3, 30))
     self.datetime_later_3 = make_date_utc(datetime.datetime(2024, 1, 1, 5, 45))
     datetime_later_4 = make_date_utc(datetime.datetime(2024, 1, 1, 6, 15))
     date_now = datetime_now.date()
     self.assertEqual(
         (self.test_1st_task.planned_duration()).__str__(), "60")
     self.assertEqual(
         (self.test_1st_task.planned_costs()).__str__(), "0")
     self.assertEqual(
         (self.test_2nd_task.planned_duration()).__str__(), "90")
     self.assertEqual(
         (self.test_2nd_task.planned_costs()).__str__(), "0")
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_1,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_later_1,
         stop_time=datetime_later_2,
         task=self.test_1st_task,
         reporting_period=self.test_reporting_period
     )
     work_cannot_be_deleted = StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=self.datetime_later_3,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     work_can_be_deleted = StandardWorkFactory.create(
         human_resource=self.human_resource,
         date=date_now,
         start_time=datetime_now,
         stop_time=datetime_later_4,
         task=self.test_2nd_task,
         reporting_period=self.test_reporting_period
     )
     self.assertEqual(
         (self.test_1st_task.effective_effort(reporting_period=None)).__str__(), "3.5")
     self.assertEqual(
         (self.test_2nd_task.effective_effort(reporting_period=None)).__str__(), "12.0")
     work_can_be_deleted.delete()
     self.assertEqual(
         (self.test_1st_task.effective_effort(reporting_period=None)).__str__(), "3.5")
     self.assertEqual(
         (self.test_2nd_task.effective_effort(reporting_period=None)).__str__(), "5.75")
     status_done = DoneReportingPeriodStatusFactory.create()
     self.test_reporting_period.status = status_done
     with pytest.raises(ReportingPeriodDoneDeleteNotPossible):
         work_cannot_be_deleted.delete()
     with pytest.raises(ReportingPeriodDoneDeleteNotPossible):
         work_cannot_be_deleted.stop_time = self.datetime_later_3
         work_cannot_be_deleted.save()
 def setUp(self):
     datetime_now = make_date_utc(datetime.datetime(2024, 1, 1, 0, 00))
     start_date = (datetime_now - datetime.timedelta(days=30)).date()
     end_date = (datetime_now + datetime.timedelta(days=30)).date()
     self.tax = StandardTaxFactory.create(tax_rate=10)
     self.test_currency_with_rounding = StandardCurrencyFactory.create(rounding=1)
     self.test_currency_without_rounding = StandardCurrencyFactory.create(
         rounding=None,
         description='Euro',
         short_name='EUR'
     )
     self.alternative_currency = self.test_currency_without_rounding
     self.customer_group = StandardCustomerGroupFactory.create()
     self.alternative_customer_group = AdvancedCustomerGroupFactory.create()
     self.customer = StandardCustomerFactory.create()
     self.customer.is_member_of.add(self.customer_group)
     self.customer.save()
     self.unit = StandardUnitFactory.create()
     self.alternative_unit = SmallUnitFactory.create()
     self.product_without_dates = StandardProductTypeFactory.create(
         product_type_identifier="A",
         tax=self.tax
     )
     self.product_without_date_from = StandardProductTypeFactory.create(
         product_type_identifier="B",
         tax=self.tax
     )
     self.product_without_date_until = StandardProductTypeFactory.create(
         product_type_identifier="C",
         tax=self.tax
     )
     self.product_without_customer_group = StandardProductTypeFactory.create(
         product_type_identifier="D",
         tax=self.tax
     )
     self.product_with_currency_rounding = StandardProductTypeFactory.create(
         product_type_identifier="E",
         tax=self.tax
     )
     self.product_without_currency_rounding = StandardProductTypeFactory.create(
         product_type_identifier="F",
         tax=self.tax
     )
     self.product_with_alternative_customer_group = StandardProductTypeFactory.create(
         product_type_identifier="G",
         tax=self.tax
     )
     self.product_with_alternative_unit = StandardProductTypeFactory.create(
         product_type_identifier="H",
         tax=self.tax
     )
     self.product_with_alternative_currency = StandardProductTypeFactory.create(
         product_type_identifier="I",
         tax=self.tax
     )
     self.price_without_customer_group = StandardPriceFactory.create(
         product_type=self.product_without_customer_group,
         customer_group=None,
         price=100,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         valid_from=start_date,
         valid_until=end_date
     )
     self.price_without_dates = StandardPriceFactory.create(
         product_type=self.product_without_dates,
         customer_group=self.customer_group,
         valid_from=None,
         valid_until=None,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=80
     )
     self.price_without_date_to = StandardPriceFactory.create(
         product_type=self.product_without_date_until,
         customer_group=self.customer_group,
         valid_from=start_date,
         valid_until=None,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=130
     )
     self.price_without_date_from = StandardPriceFactory.create(
         product_type=self.product_without_date_from,
         customer_group=self.customer_group,
         valid_from=None,
         valid_until=end_date,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=50
     )
     self.price_without_date_from = StandardPriceFactory.create(
         product_type=self.product_without_currency_rounding,
         currency=self.test_currency_without_rounding,
         customer_group=self.customer_group,
         price=25,
         unit=self.unit,
         valid_from=start_date,
         valid_until=end_date
     )
     self.price_without_date_from = StandardPriceFactory.create(
         product_type=self.product_with_currency_rounding,
         currency=self.test_currency_with_rounding,
         customer_group=self.customer_group,
         price=33,
         unit=self.unit,
         valid_from=start_date,
         valid_until=end_date
     )
     self.price_with_alternative_customer_group = StandardPriceFactory.create(
         product_type=self.product_with_alternative_customer_group,
         customer_group=self.alternative_customer_group,
         valid_from=start_date,
         valid_until=end_date,
         unit=self.unit,
         currency=self.test_currency_with_rounding,
         price=80
     )
     self.customer_group_transform = StandardCustomerGroupTransformFactory.create(
         from_customer_group=self.alternative_customer_group,
         to_customer_group=self.customer_group,
         product_type=self.product_with_alternative_customer_group,
         factor=0.50
     )
     self.price_with_alternative_currency = StandardPriceFactory.create(
         product_type=self.product_with_alternative_currency,
         customer_group=self.customer_group,
         valid_from=start_date,
         valid_until=end_date,
         unit=self.unit,
         currency=self.alternative_currency,
         price=80
     )
     self.currency_transform = StandardCurrencyTransformFactory.create(
         from_currency=self.alternative_currency,
         to_currency=self.test_currency_with_rounding,
         product_type=self.product_with_alternative_currency,
         factor=0.50
     )
     self.price_with_alternative_unit = StandardPriceFactory.create(
         product_type=self.product_with_alternative_unit,
         customer_group=self.customer_group,
         valid_from=start_date,
         valid_until=end_date,
         unit=self.alternative_unit,
         currency=self.test_currency_with_rounding,
         price=80
     )
     self.currency_transform = StandardUnitTransformFactory.create(
         from_unit=self.alternative_unit,
         to_unit=self.unit,
         product_type=self.product_with_alternative_unit,
         factor=0.50
     )