@@ -47,12 +47,21 @@ def validateprot(value):
4747 try :
4848 if len (value ) <= 11 and len (value .split ('/' )) == 2 \
4949 and value .split ('/' )[0 ].isdigit () \
50- and value .split ('/' )[1 ].isdigit ():
50+ and value .split ('/' )[1 ].isdigit () and len ( value . split ( '/' )[ 1 ]) == 4 :
5151 return True
5252 except :
5353 return False
5454 return False
5555
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+
5665
5766def is_number (s ):
5867 try :
@@ -66,7 +75,7 @@ def validate(value):
6675
6776 err = ''
6877
69- if 'beneficiario' not in value :
78+ if 'beneficiario' not in value or value [ 'beneficiario' ] is None :
7079 err = err + 'Volore errato per beneficiario '
7180 elif 'tipopagamento' not in value or value ['tipopagamento' ] not in TP :
7281 err = err + 'Volore errato per tipopagamento '
@@ -118,7 +127,7 @@ def _siam_serialize(value):
118127 "{:%Y-%m-%dT%H:%M:%S}" .format (value ['datainizioprestazione' ])
119128 (etree .SubElement (intercettazioni , 'DATAFINEPRESTAZIONE' )).text = \
120129 "{:%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
122131 (etree .SubElement (intercettazioni , 'REGISTRO' )).text = value ['registro' ].upper ()
123132 (etree .SubElement (intercettazioni , 'SEDE' )).text = value ['sede' ].upper ()
124133 (etree .SubElement (intercettazioni , 'IMPORTOTOTALE' )).text = \
@@ -130,7 +139,7 @@ def _siam_serialize(value):
130139 "{:%Y-%m-%dT%H:%M:%S}" .format (value ['datafattura' ])
131140 if not value ['tipointercettazione' ] == 'GPS' :
132141 (etree .SubElement (intercettazioni , 'NUMEROMODELLO37' )).text = \
133- value ['numeromodello37' ] if 'numeromodello37' in value else None
142+ fillprot ( value ['numeromodello37' ]) if 'numeromodello37' in value else None
134143 (etree .SubElement (intercettazioni , 'TIPOINTERCETTAZIONE' )).text = value ['tipointercettazione' ].upper ()
135144 (etree .SubElement (intercettazioni , 'NOMEMAGISTRATO' )).text = unicode (value ['nomemagistrato' ]).upper ()
136145 (etree .SubElement (intercettazioni , 'COGNOMEMAGISTRATO' )).text = unicode (value ['cognomemagistrato' ]).upper ()
0 commit comments