30marzo2023

SyncUpdate2IONOS
Luis Angel Rendon Arrazola 2 years ago
parent 09b1b5b945
commit f1efbd589a
  1. 23
      SyncReferences2IONOS.py
  2. 1
      log/Referencias.txt
  3. 1
      log/fechayHora.txt

@ -102,10 +102,16 @@ def CreateFolderContent():
cursor.execute("""SELECT P.sReferencia, p.Archivo, P.Aduana, P.Patente, P.Pedimento, P.[Pedimento Fecha Pago], Peds.nTipoCambio, cursor.execute("""SELECT P.sReferencia, p.Archivo, P.Aduana, P.Patente, P.Pedimento, P.[Pedimento Fecha Pago], Peds.nTipoCambio,
P.Clave, P.Cliente FROM SIR.Admin.SIR_VT_PedimPagados P P.Clave, P.Cliente FROM SIR.Admin.SIR_VT_PedimPagados P
INNER JOIN SIR.SIR.SIR_149_PEDIMENTO AS Peds ON Peds.nIdPedimento149=ID INNER JOIN SIR.SIR.SIR_149_PEDIMENTO AS Peds ON Peds.nIdPedimento149=ID
WHERE P.ClienteClave=2096 and p.[Pedimento FechaPago]>=CAST( GETDATE()-2 AS Date )""") WHERE P.ClienteClave=2096 and p.[Pedimento FechaPago]>=CAST( GETDATE()-5 AS Date )""")
for row in cursor: for row in cursor:
referencia = row[0] referencia = row[0]
archivoM = row[1] archivoM = row[1]
aduana = row[2]
patente = row[3]
pedimento = row[4]
fPago = row[5]
tipoCambio = row[6]
clave = row[7]
cliente = row [8] cliente = row [8]
referenceFolder = TempFolder + referencia referenceFolder = TempFolder + referencia
if os.path.exists(referenceFolder): if os.path.exists(referenceFolder):
@ -130,15 +136,26 @@ def CreateFolderContent():
# Procesar archivo # Procesar archivo
if WriteToLog(reference): if WriteToLog(reference):
processed_references.append(reference) processed_references.append(reference)
URL = 'http://localhost:5000/api/AmazonInvoice/UploadSIRReference?ArchivoM='+archivoM URL = 'http://localhost:5000/api/AmazonInvoice/UploadSIRReference?ArchivoM=' +\
archivoM+'&aduana='+aduana+'&patente='+patente + \
'&pedimento='+pedimento+'&fPago=' + \
str(fPago)+'&TipoCambio='+str(tipoCambio)+'&clave='+clave
multiple_files = [] multiple_files = []
multiple_files.append(('files', (file.replace(TempFolder,''), open(file, 'rb'), 'application/zip'))) multiple_files.append(('files', (file.replace(TempFolder,''), open(file, 'rb'), 'application/zip')))
data = { data = {
"ArchivoM": archivoM "ArchivoM": archivoM,
'aduana': aduana,
'patente': patente,
'pedimento': pedimento,
'fPago' : str(fPago),
'tipoCambio' : str(tipoCambio),
'clave': clave
} }
r = requests.post(url=URL,files=multiple_files, verify=False, timeout=30) r = requests.post(url=URL,files=multiple_files, verify=False, timeout=30)
except Exception as e: except Exception as e:
print("Error: %s" % e) print("Error: %s" % e)
# WriteToLog(r.text)
''' contents = [os.path.join(TempFolder, i) for i in os.listdir(TempFolder)] ''' contents = [os.path.join(TempFolder, i) for i in os.listdir(TempFolder)]
[shutil.rmtree(i) if os.path.isdir(i) and not os.path.islink(i) else os.remove(i) for i in contents] ''' [shutil.rmtree(i) if os.path.isdir(i) and not os.path.islink(i) else os.remove(i) for i in contents] '''

@ -1 +0,0 @@
23-00401I

@ -1 +0,0 @@
2023-03-30 14:15:40 - 23-00401I
Loading…
Cancel
Save