import datetime

import factory
import factory.fuzzy

from pytz import UTC


class ContractFactory(factory.django.DjangoModelFactory):

    no = factory.fuzzy.FuzzyText(length=12)
    amount = factory.fuzzy.FuzzyDecimal(1.11,999999.99,2)
    sicet_type = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])
    sub_sicet_type = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])
    service_amount = factory.fuzzy.FuzzyDecimal(1.11,999999.99,2)
    material_amount = factory.fuzzy.FuzzyDecimal(1.11,999999.99,2)
    start_date = factory.fuzzy.FuzzyDateTime(datetime.datetime(2008, 1, 1, tzinfo=UTC),
                                               datetime.datetime(2009, 1, 1, tzinfo=UTC))
    system_type = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])
    network_type = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])

    class Meta:
        model = 'contract_mgt.Contract'

class ContractorFactory(factory.django.DjangoModelFactory):
    #contacts

    contract = factory.SubFactory(ContractFactory)

    full_name = factory.fuzzy.FuzzyText(length=12)
    short_name = factory.fuzzy.FuzzyText(length=12)
    profile =  factory.fuzzy.FuzzyText(length=12)
    remarks =  factory.fuzzy.FuzzyText(length=12)

    class Meta:
        model = 'contract_mgt.Contractor'

class ContractorContactFactory(factory.django.DjangoModelFactory):

    contractor = factory.SubFactory(ContractorFactory)

    first_name = factory.fuzzy.FuzzyText(length=12)
    last_name = factory.fuzzy.FuzzyText(length=12)
    position = factory.fuzzy.FuzzyText(length=12)
    email = '--@--.com'
    mobile_no = factory.fuzzy.FuzzyText(length=12)
    office_no = factory.fuzzy.FuzzyText(length=12)
    fax_no = factory.fuzzy.FuzzyText(length=12)
    remarks = factory.fuzzy.FuzzyText(length=12)
    authority_level = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])

    class Meta:
        model = 'contract_mgt.ContractorContact'

class ContractChangeFactory(factory.django.DjangoModelFactory):

    contract = factory.SubFactory(ContractFactory)

    type = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])
    version = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])
    end_date = factory.fuzzy.FuzzyDateTime(datetime.datetime(2008, 1, 1, tzinfo=UTC),
                                               datetime.datetime(2009, 1, 1, tzinfo=UTC))
    remarks = factory.fuzzy.FuzzyText(length=12)

    class Meta:
        model = 'contract_mgt.ContractChange'

class SupportContractFactory(factory.django.DjangoModelFactory):

    contract = factory.SubFactory(ContractFactory)

    no = factory.fuzzy.FuzzyText(length=12)
    amount = factory.fuzzy.FuzzyDecimal(1.11,999999.99,2)
    start_date = factory.fuzzy.FuzzyDateTime(datetime.datetime(2008, 1, 1, tzinfo=UTC),
                                           datetime.datetime(2009, 1, 1, tzinfo=UTC))
    end_date = factory.fuzzy.FuzzyDateTime(datetime.datetime(2008, 1, 1, tzinfo=UTC),
                                           datetime.datetime(2009, 1, 1, tzinfo=UTC))
    status = factory.Iterator(['Freight', 'Customs Duty', 'Staff Cost'])
    class Meta:
        model = 'contract_mgt.SupportContract'
