@@ -47,12 +47,21 @@ def validateprot(value):
47
47
try :
48
48
if len (value ) <= 11 and len (value .split ('/' )) == 2 \
49
49
and value .split ('/' )[0 ].isdigit () \
50
- and value .split ('/' )[1 ].isdigit ():
50
+ and value .split ('/' )[1 ].isdigit () and len ( value . split ( '/' )[ 1 ]) == 4 :
51
51
return True
52
52
except :
53
53
return False
54
54
return False
55
55
56
+ def fillprot (value ):
57
+
58
+ if value :
59
+ part1 = '%06d' % int (value .split ('/' )[0 ])
60
+ return part1 + '/' + value .split ('/' )[1 ]
61
+ else :
62
+ return value
63
+
64
+
56
65
57
66
def is_number (s ):
58
67
try :
@@ -66,7 +75,7 @@ def validate(value):
66
75
67
76
err = ''
68
77
69
- if 'beneficiario' not in value :
78
+ if 'beneficiario' not in value or value [ 'beneficiario' ] is None :
70
79
err = err + 'Volore errato per beneficiario '
71
80
elif 'tipopagamento' not in value or value ['tipopagamento' ] not in TP :
72
81
err = err + 'Volore errato per tipopagamento '
@@ -118,7 +127,7 @@ def _siam_serialize(value):
118
127
"{:%Y-%m-%dT%H:%M:%S}" .format (value ['datainizioprestazione' ])
119
128
(etree .SubElement (intercettazioni , 'DATAFINEPRESTAZIONE' )).text = \
120
129
"{:%Y-%m-%dT%H:%M:%S}" .format (value ['datafineprestazione' ])
121
- (etree .SubElement (intercettazioni , 'NR_RG' )).text = value ['nr_rg' ] if 'nr_rg' in value else None
130
+ (etree .SubElement (intercettazioni , 'NR_RG' )).text = fillprot ( value ['nr_rg' ]) if 'nr_rg' in value else None
122
131
(etree .SubElement (intercettazioni , 'REGISTRO' )).text = value ['registro' ].upper ()
123
132
(etree .SubElement (intercettazioni , 'SEDE' )).text = value ['sede' ].upper ()
124
133
(etree .SubElement (intercettazioni , 'IMPORTOTOTALE' )).text = \
@@ -130,7 +139,7 @@ def _siam_serialize(value):
130
139
"{:%Y-%m-%dT%H:%M:%S}" .format (value ['datafattura' ])
131
140
if not value ['tipointercettazione' ] == 'GPS' :
132
141
(etree .SubElement (intercettazioni , 'NUMEROMODELLO37' )).text = \
133
- value ['numeromodello37' ] if 'numeromodello37' in value else None
142
+ fillprot ( value ['numeromodello37' ]) if 'numeromodello37' in value else None
134
143
(etree .SubElement (intercettazioni , 'TIPOINTERCETTAZIONE' )).text = value ['tipointercettazione' ].upper ()
135
144
(etree .SubElement (intercettazioni , 'NOMEMAGISTRATO' )).text = unicode (value ['nomemagistrato' ]).upper ()
136
145
(etree .SubElement (intercettazioni , 'COGNOMEMAGISTRATO' )).text = unicode (value ['cognomemagistrato' ]).upper ()
0 commit comments