Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

# -*- coding: UTF-8 -*- 

# Copyright 2009-2014 Luc Saffre 

# License: BSD (see file COPYING for details) 

 

""" 

Loads a series of default :class:`ml.contacts.CompanyType`. 

 

.. django2rst:: 

 

  rt.show('contacts.CompanyTypes') 

 

See also :srcref:`docs/tickets/108`. 

""" 

 

from __future__ import unicode_literals 

from builtins import filter 

 

 

from django.db import models 

from django.conf import settings 

 

from django.utils.translation import ugettext as _ 

 

from lino.api.dd import babel_values 

 

from lino.core.utils import resolve_model 

from lino.utils.instantiator import Instantiator 

 

 

companyType = Instantiator('contacts.CompanyType', "abbr name").build 

roletype = Instantiator('contacts.RoleType', "name").build 

 

# thanks to http://belgium.angloinfo.com/countries/belgium/businesses.asp 

# see also http://en.wikipedia.org/wiki/Types_of_business_entity 

 

COMPANY_TYPES_FORMAT = 'en nl fr de' 

COMPANY_TYPES_TEXT = u""" 

Public Limited Company    | NV (Naamloze Vennootschap)   | SA (Société Anonyme) |  AG (Aktiengesellschaft) 

Limited Liability Company | BVBA (Besloten Vennootschap met Beperkte Aansprakelijkheid)  | SPRL (Société Privée à Responsabilité Limitée) | PGmbH (Private Gesellschaft mit beschränkter Haft) 

One-person Private Limited Company | EBVBA (Eenpersoons Beslotenvennootschap met Beperkte Aansprakelijkheid) | SPRLU (Société d'Une Personne à Responsabilité Limitée) | EGmbH (Einpersonengesellschaft mit beschränkter Haft) 

Cooperative Company with Limited Liability | CVBA (Cooperatieve Vennootschap met Beperkte Aansprakelijkheid) | SCRL (Société Coopérative à Responsabilité Limitée) | Kooperative mit beschränkter Haft 

Cooperative Company with Unlimited Liability | CVOA (Cooperatieve Vennootschap met Onbeperkte Aansprakelijkheid) | SCRI (Société Coopérative à Responsabilité Illimitée) | Kooperative mit unbeschränkter Haft 

General Partnership | Comm VA (Commanditaire Vennootschap op Aandelen | SNC (Société en Nom Collectif) | 

Limited Partnership | Comm V (Gewone Commanditaire Vennootschap) | SCS (Société en Commandite Simple) | 

Non-stock Corporation | Maatschap | Société de Droit Commun | Gesellschaft öffentlichen Rechts 

Charity/Company established for social purposes | VZW (Vereniging Zonder Winstoogmerk) | ASBL (Association sans But Lucratif) | V.o.G. (Vereinigung ohne Gewinnabsicht) 

 

Cooperative Company | CV (Cooperatieve Vennootschap) | SC (Société Coopérative) | Genossenschaft 

Company | Firma | Société | Firma 

Public service |  | Service Public | Öffentlicher Dienst 

Ministry |  | Ministère | Ministerium 

School |  | école | Schule 

Freelancer | Freelacer | Travailleur libre | Freier Mitarbeiter 

Sole proprietorship | Eenmanszaak | Entreprise individuelle | Einzelunternehmen 

""" 

COMPANY_TYPES = [] 

 

 

def parse(s): 

    a = s.split("(", 1) 

    if len(a) == 2: 

        name = a[1].strip() 

        if name.endswith(")"): 

            return dict(abbr=a[0].strip(), name=name[:-1]) 

    s = s.strip() 

    if not s: 

        return {} 

    return dict(name=s) 

 

LANGS = {} 

 

for i, lang in enumerate(COMPANY_TYPES_FORMAT.split()): 

    li = settings.SITE.get_language_info(lang) 

    if li is not None: 

        LANGS[li.index] = i 

 

#~ print LANGS 

 

for ln in COMPANY_TYPES_TEXT.splitlines(): 

    if ln and ln[0] != "#": 

        a = ln.split('|') 

        if len(a) != 4: 

            raise Exception("Line %r has %d fields (expected 4)" % len(a)) 

        d = dict() 

        for index, i in list(LANGS.items()): 

            kw = parse(a[i]) 

            if index == 0: 

                d.update(kw) 

            else: 

                for k, v in list(kw.items()): 

                    d[k + settings.SITE.languages[index].suffix] = v 

 

        def not_empty(x): 

            return x 

        #~ print d 

        if 'name' in d: 

            # if there's at least one non-empty value 

            if list(filter(not_empty, list(d.values()))): 

                COMPANY_TYPES.append(d) 

 

 

def objects(): 

 

    #~ yield companyType('Firma','Firma') 

    #~ yield companyType('asbl','asbl') 

    #~ yield companyType('A.S.B.L.','A.S.B.L.') 

    #~ yield companyType('sprl','sprl') 

    #~ yield companyType('GmbH','GmbH') 

    #~ yield companyType('AG','AG') 

    #~ yield companyType('S.A.','S.A.') 

    #~ yield companyType('S.C.','S.C.') 

    #~ yield companyType('V.o.G.','V.o.G.') 

    #~ yield companyType('G.o.E.','G.o.E.') 

    #~ yield companyType('A.S.B.L.','Association sans but lucratif') 

    #~ yield companyType('Maison','Maison') 

    #~ yield companyType('Fachklinik','Fachklinik') 

    #~ yield companyType("Centre d'Accueil d'Urgence","Centre d'Accueil d'Urgence") 

 

    #~ yield companyType(**babel_values('name', 

        #~ en=u"Public Limited Company", 

        #~ nl=u'NV (Naamloze Vennootschap)', 

        #~ fr=u'SA (Société Anonyme)', 

        #~ de=u"AG (Aktiengesellschaft)")) 

 

    for ct in COMPANY_TYPES: 

        yield companyType(**ct) 

 

    yield roletype(**babel_values('name', en="Manager", fr='Gérant', de="Geschäftsführer", et="Tegevjuht")) 

    yield roletype(**babel_values('name', en="Director", fr='Directeur', de="Direktor", et="Direktor")) 

    yield roletype(**babel_values('name', en="Secretary", fr='Secrétaire', de="Sekretär", et="Sekretär")) 

    yield roletype(**babel_values('name', en="IT Manager", fr='Gérant informatique', de="EDV-Manager", et="IT manager")) 

    yield roletype(**babel_values('name', en="President", fr='Président', de="Präsident", et="President")) 

 

    if settings.SITE.is_installed('contenttypes'): 

 

        from django.contrib.contenttypes.models import ContentType 

 

        I = Instantiator('gfks.HelpText', 

                         'content_type field help_text').build 

 

        Person = resolve_model("contacts.Person") 

        t = ContentType.objects.get_for_model(Person) 

 

        #~ yield I(t,'birth_date',u"""\ 

    #~ Unkomplette Geburtsdaten sind erlaubt, z.B. 

    #~ <ul> 

    #~ <li>00.00.1980 : irgendwann in 1980</li> 

    #~ <li>00.07.1980 : im Juli 1980</li> 

    #~ <li>23.07.0000 : Geburtstag am 23. Juli, Alter unbekannt</li> 

    #~ </ul> 

    #~ """) 

 

        Partner = resolve_model('contacts.Partner') 

        t = ContentType.objects.get_for_model(Partner) 

        yield I(t, 'language', u"""\ 

    Die Sprache, in der Dokumente ausgestellt werden sollen. 

    """)