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

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

# Copyright 2012 Luc Saffre 

# License: BSD (see file COPYING for details) 

 

u""" 

Tools for generating   

`Belgian Intervat declarations 

<http://minfin.fgov.be/portail2/fr/e-services/intervat/>`_ 

 

>>> vat_number = "0123456789" 

>>> def me(): 

...   return ( 

...      iic.Name("Foo, Bar & Baz"), 

...      iic.Street(u"rue de l'école 57"), 

...      iic.PostCode(u"4000"), 

...      iic.City(u"Liège"), 

...      iic.CountryCode("BE"), 

...      iic.EmailAddress("foo@barbaz.be"), 

...      iic.Phone("02345678") 

...   ) 

>>> root = clc.ClientListingConsignment( 

...   clc.Representative( 

...      iic.RepresentativeID(vat_number,issuedBy="BE",identificationType="TIN"), 

...      *me()), 

...   clc.ClientListing( 

...     clc.Declarant( 

...       iic.VATNumber(vat_number), 

...       *me()), 

...     clc.Period('2011'), 

...     SequenceNumber=1,ClientsNbr=1, 

...     TurnOverSum="1000.00",VATAmountSum="210.00"), 

...   ClientListingsNbr=1) 

 

>>> clc.validate_root(root) 

 

Note that it validates although there are no clients but a sum. 

That's because validate checks only the "syntax", not the "content". 

 

>>> print etree.tostring(root,pretty_print=True) #doctest: +ELLIPSIS 

<clc:ClientListingConsignment ... ClientListingsNbr="1"> 

  <clc:Representative> 

    <iic:RepresentativeID identificationType="TIN" issuedBy="BE">0123456789</iic:RepresentativeID> 

    <iic:Name>Foo, Bar &amp; Baz</iic:Name> 

    <iic:Street>rue de l'&#233;cole 57</iic:Street> 

    <iic:PostCode>4000</iic:PostCode> 

    <iic:City>Li&#232;ge</iic:City> 

    <iic:CountryCode>BE</iic:CountryCode> 

    <iic:EmailAddress>foo@barbaz.be</iic:EmailAddress> 

    <iic:Phone>02345678</iic:Phone> 

  </clc:Representative> 

  <clc:ClientListing TurnOverSum="1000.00" ClientsNbr="1" VATAmountSum="210.00" SequenceNumber="1"> 

    <clc:Declarant> 

      <iic:VATNumber>0123456789</iic:VATNumber> 

      <iic:Name>Foo, Bar &amp; Baz</iic:Name> 

      <iic:Street>rue de l'&#233;cole 57</iic:Street> 

      <iic:PostCode>4000</iic:PostCode> 

      <iic:City>Li&#232;ge</iic:City> 

      <iic:CountryCode>BE</iic:CountryCode> 

      <iic:EmailAddress>foo@barbaz.be</iic:EmailAddress> 

      <iic:Phone>02345678</iic:Phone> 

    </clc:Declarant> 

    <clc:Period>2011</clc:Period> 

  </clc:ClientListing> 

</clc:ClientListingConsignment> 

<BLANKLINE> 

 

""" 

 

 

import os 

 

try: 

    from lxml import etree 

except ImportError: 

    from lino.utils.xmlgen import etree 

 

SubElement = etree.SubElement 

 

from lino.utils import xmlgen as xg 

 

 

def xsdpath(*parts): 

    p1 = os.path.abspath(os.path.dirname(__file__)) 

    return os.path.join(p1, 'XSD', *parts) 

 

 

class IntervatInputCommon(xg.Namespace): 

    xsd_filename = xsdpath('IntervatInputCommon_v0_7.xsd') 

iic = IntervatInputCommon('iic') 

 

 

class ClientListingConsignment(xg.Namespace): 

    xsd_filename = xsdpath('NewLK-in_v0_7.xsd') 

    used_namespaces = [iic] 

clc = ClientListingConsignment('clc') 

 

 

class IntraConsignment(xg.Namespace): 

    xsd_filename = xsdpath('NewICO-in_v0_7.xsd') 

    used_namespaces = [iic] 

ico = IntraConsignment('ico') 

 

 

def _test(): 

    import doctest 

    doctest.testmod() 

 

if __name__ == "__main__": 

    _test()