-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue #174] started to add a few more factories for testing in the a…
…rea of product and customer groups. Added a new entity "Estimation of ressource consumption" removed the employee assignment to task instead
- Loading branch information
Showing
19 changed files
with
433 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
koalixcrm/crm/factories/factory_customer_group_transformk.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import factory | ||
from koalixcrm.crm.product.customer_group_transform import CustomerGroupTransform | ||
from koalixcrm.crm.factories.factory_product import StandardProductFactory | ||
from koalixcrm.crm.factories.factory_customer_group import AdvancedCustomerGroupFactory | ||
from koalixcrm.crm.factories.factory_customer_group import StandardCustomerGroupFactory | ||
|
||
|
||
class StandardCustomerGroupTransformFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = CustomerGroupTransform | ||
from_customer_group = factory.SubFactory(AdvancedCustomerGroupFactory) | ||
to_customer_group = factory.SubFactory(StandardCustomerGroupFactory) | ||
product = factory.SubFactory(StandardProductFactory) | ||
factor = "10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import factory | ||
from koalixcrm.crm.models import Project | ||
from koalixcrm.crm.factories.factory_unit import StandardUnitFactory | ||
from koalixcrm.djangoUserExtension.factories.factory_template_set import StandardTemplateSetFactory | ||
from koalixcrm.crm.factories.factory_user import StaffUserFactory | ||
|
||
|
||
class StandardProductFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = Project | ||
django_get_or_create = ('project_name',) | ||
|
||
description = models.TextField(verbose_name=_("Description"), | ||
null=True, | ||
blank=True) | ||
title = "This is a test Product" | ||
product_number = "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(StandardUnitFactory) | ||
accounting_product_categorie = models.ForeignKey('accounting.ProductCategorie', | ||
verbose_name=_("Accounting Product Categorie"), | ||
null=True, | ||
blank="True") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.db import models | ||
from django.utils.translation import ugettext as _ | ||
|
||
|
||
class CustomerGroupTransform(models.Model): | ||
from_customer_group = models.ForeignKey('CustomerGroup', | ||
verbose_name=_("From Unit"), | ||
related_name="db_reltransfromfromcustomergroup", | ||
blank=False, | ||
null=False) | ||
to_customer_group = models.ForeignKey('CustomerGroup', | ||
verbose_name=_("To Unit"), | ||
related_name="db_reltransfromtocustomergroup", | ||
blank=False, | ||
null=False) | ||
product = models.ForeignKey('Product', | ||
verbose_name=_("Product"), | ||
blank=False, | ||
null=False) | ||
factor = models.IntegerField(verbose_name=_("Factor between From and To Customer Group"), | ||
blank=True, | ||
null=True) | ||
|
||
def transform(self, customer_group): | ||
"""The transform function verifies whether the provided argument customer_group | ||
is corresponding with the "from_customer_group" variable of the CustomerGroupTransform class | ||
When this is ok, the function returns the "to_customer_group". When the provided customer_group | ||
argument is not corresponding, the function returns a "None" | ||
Args: | ||
customer_group: CustomerGroup object | ||
Returns: | ||
CustomerGroup object or None | ||
Raises: | ||
No exceptions planned""" | ||
if self.from_customer_group == customer_group: | ||
return self.to_customer_group | ||
else: | ||
return None | ||
|
||
def __str__(self): | ||
return "From " + self.from_customer_group.name + " to " + self.to_customer_group.name | ||
|
||
class Meta: | ||
app_label = "crm" | ||
verbose_name = _('Customer Group Price Transform') | ||
verbose_name_plural = _('Customer Group Price Transforms') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.