i've an issue with my script in python. i'm using it to read an xml for e-invoice, and works fine for 99% of the field. (i' grab information from xml and put it on xls file) however, i have an issue with this part of the script. If the script find the node no issue, it will report correctly. but if not, i want the script to check the second part, of the node, and grab the information from an other field(the first field is expire date) the second field in case the first is n/a is Days for payment.
for scadenza in obj.iterfind('FatturaElettronicaBody/DatiPagamento/DettaglioPagamento/DataScadenzaPagamento'):
print(scadenza.text) #print thee expiration date
if (not scadenza.text):
for scadenza1 in obj.iterfind('FatturaElettronicaBody/DatiPagamento/DettaglioPagamento/GiorniTerminiPagamento'):
from datetime import timedelta, date
d1 = datem + timedelta(days=int(scadenza1.text))
print(f'New Expire {d1}')
scadenza.text = d1
i did by myself.
if len(obj.findall('FatturaElettronicaBody/DatiPagamento/DettaglioPagamento/DataScadenzaPagamento')):
for scadenza in obj.iterfind('FatturaElettronicaBody/DatiPagamento/DettaglioPagamento/DataScadenzaPagamento'):
from datetime import datetime
print(scadenza.text)
self.worksheet.write(row, column + 8, scadenza.text)
newscad = scadenza.text[0:10]
scad1 = datetime.strptime(newscad, "%Y-%m-%d")
else:
for scadenza1 in obj.iterfind('FatturaElettronicaBody/DatiPagamento/DettaglioPagamento/GiorniTerminiPagamento'):
from datetime import timedelta, date, datetime
scad1= datem + timedelta(days=int(scadenza1.text))
print(f'New Expire {scad1}')
newdate = datetime.strftime(scad1, "%Y-%m-%d")
self.worksheet.write(row, column + 8, newdate)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.