riempimento campi secondari
This commit is contained in:
parent
1a6053e2cd
commit
fafd5cca18
@ -3,3 +3,7 @@ VERSIONE = "1.0.0"
|
||||
DEFAULT_CODICE_CLIENTE = "000000"
|
||||
MESSAGGIO_SUCCESSO = "Operazione completata con successo"
|
||||
API_SECRET_KEY = "Z9KPT3QD2MAVNX81HJRY"
|
||||
VALUTA = "EUR"
|
||||
FL_SCOR = "N"
|
||||
TIPO_RIGA_ART="R"
|
||||
FL_OMAG="X"
|
||||
54
main.py
54
main.py
@ -9,7 +9,8 @@ from models import (
|
||||
MetodoPagamento, DisponibilitaArticolo,
|
||||
OrdineTestata, OrdineRiga,Magazzini
|
||||
)
|
||||
from contants import NOME_PROGETTO, MESSAGGIO_SUCCESSO,API_SECRET_KEY
|
||||
from contants import NOME_PROGETTO, MESSAGGIO_SUCCESSO,API_SECRET_KEY,VALUTA,FL_SCOR,TIPO_RIGA_ART,FL_OMAG
|
||||
from datetime import datetime
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@ -17,6 +18,10 @@ def genera_codice_random(lunghezza: int = 50) -> str:
|
||||
caratteri = string.ascii_letters + string.digits # a-z A-Z 0-9
|
||||
return ''.join(random.choices(caratteri, k=lunghezza))
|
||||
|
||||
def genera_cpccchk(lunghezza: int = 10) -> str:
|
||||
lettere = string.ascii_uppercase # solo lettere maiuscole A-Z
|
||||
return ''.join(random.choices(lettere, k=lunghezza))
|
||||
|
||||
def genera_nuovo_codice_cliente():
|
||||
conn = None
|
||||
try:
|
||||
@ -70,7 +75,7 @@ def get_sedi_consegna(codice_cliente: str,secret: str = Depends(verifica_secret_
|
||||
def get_articoli(secret: str = Depends(verifica_secret_key)):
|
||||
conn = get_connection()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("select ARCODART, ARDESART,ARDESSUP,ARUNMIS1 from MANGAART_ICOL where ardtobso is null")
|
||||
cursor.execute("select ARCODART, ARDESART,ARDESSUP,ARUNMIS1,ARCODIVA from MANGAART_ICOL where ardtobso is null")
|
||||
rows = cursor.fetchall()
|
||||
return [Articolo(arcodart=r[0], ardesart=r[1], ardessup=r[2], arunmis1=r[3]) for r in rows]
|
||||
|
||||
@ -139,10 +144,14 @@ def crea_ordine(ordine: OrdineTestata):
|
||||
# Genera codice ordine
|
||||
seriale_ordine = genera_codice_random()
|
||||
ordine.orserial = seriale_ordine
|
||||
cpccchk=genera_cpccchk()
|
||||
data_ora_corrente = datetime.now()
|
||||
ordine.or_stato=0 #stato iniziale
|
||||
|
||||
cursor.execute("""
|
||||
INSERT INTO MANGAZORDWEBM (orserial, or_stato, ortipdoc, ornumdoc, oralfdoc, ortipcon, orcodcon, orcodage, orcodpag, ortotord, ordatdoc)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO MANGAZORDWEBM (orserial, or_stato, ortipdoc, ornumdoc, oralfdoc, ortipcon, orcodcon, orcodage, orcodpag,
|
||||
ortotord, ordatdoc,cpccchk,orcodval,orflscor,oralfest,utdc,utdv,orcodpor,or__note,orrifest,orvalnaz,orcaoval,orvalacc)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
ordine.orserial,
|
||||
ordine.or_stato,
|
||||
@ -154,17 +163,32 @@ def crea_ordine(ordine: OrdineTestata):
|
||||
ordine.orcodage,
|
||||
ordine.orcodpag,
|
||||
ordine.ortotord,
|
||||
ordine.ordatdoc
|
||||
ordine.ordatdoc,
|
||||
cpccchk,
|
||||
VALUTA,
|
||||
FL_SCOR,
|
||||
" ",
|
||||
data_ora_corrente,
|
||||
data_ora_corrente,
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
1,
|
||||
" "
|
||||
))
|
||||
conn.commit()
|
||||
#conn.commit()
|
||||
cursor.execute("SELECT SCOPE_IDENTITY()")
|
||||
id_ordine = cursor.fetchone()[0]
|
||||
|
||||
# Inserisce righe ordine
|
||||
for riga in ordine.righe:
|
||||
cproword=riga.cprownum * 10
|
||||
cursor.execute("""
|
||||
INSERT INTO MANGAZORDWEBD (orserial, cprownum, ordesart, ordessup, orqtamov, orcodart,orcodice)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO MANGAZORDWEBD (orserial, cprownum, ordesart, ordessup, orqtamov, orcodart,orcodice,
|
||||
cproword,ortiprig,orcodvar,orunimis,orcodiva,orflomag,orcodlis,orcontra,
|
||||
orscolis,orprolis,orprosco,cpccchk)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
ordine.orserial,
|
||||
riga.cprownum,
|
||||
@ -172,7 +196,19 @@ def crea_ordine(ordine: OrdineTestata):
|
||||
riga.ordessup,
|
||||
riga.orqtamov,
|
||||
riga.orcodart,
|
||||
riga.orcodice
|
||||
riga.orcodice,
|
||||
cproword,
|
||||
TIPO_RIGA_ART,
|
||||
" ",
|
||||
riga.orunimis,
|
||||
riga.orcodiva,
|
||||
FL_OMAG,
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
genera_cpccchk()
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ class Articolo(BaseModel):
|
||||
ardesart: Optional[str]= Field(None, description="Descrizione articolo")
|
||||
ardessup: Optional[str]= Field(None, description="Descrizione supplementare")
|
||||
arunmis1: Optional[str]= Field(None, description="Unità di misura")
|
||||
arcodiva: Optional[str]= Field(None, description="Codice Iva articolo")
|
||||
|
||||
class CodiceRicerca(BaseModel):
|
||||
cacodice: str = Field(..., description="Chiave primaria")
|
||||
@ -54,6 +55,8 @@ class OrdineRiga(BaseModel):
|
||||
ordessup: str = Field(..., description="descrizione suppl. articolo")
|
||||
orqtamov: int = Field(..., description="quantità")
|
||||
orcodice: str = Field(..., description="chiave di ricerca articolo")
|
||||
orunimis: str = Field(..., description="unità di misura")
|
||||
orcodiva: str = Field(..., description="codice iva articolo")
|
||||
|
||||
|
||||
class OrdineTestata(BaseModel):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user