Fix codice a barre + fix fornitore + fix codice alternativo
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
myenv
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
main.spec
|
||||||
|
.idea
|
||||||
@ -1 +0,0 @@
|
|||||||
,pc-sviluppo1,pcsviluppo1,13.12.2024 10:29,file:///home/pc-sviluppo1/.config/libreoffice/4;
|
|
||||||
34
main.py
34
main.py
@ -1,19 +1,13 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import mysql.connector
|
|
||||||
import math
|
import math
|
||||||
import xlsxwriter
|
from utils.connection import create_connection
|
||||||
import tkinter as tk
|
from utils.connection import close_connection
|
||||||
from tkinter import filedialog,messagebox
|
from utils.search import search_article
|
||||||
from datetime import datetime
|
from utils.update import update_records
|
||||||
from mysql.connector import Error
|
from utils.insert import insert_records
|
||||||
from connection import create_connection
|
from utils.write import write_excel
|
||||||
from connection import close_connection
|
from utils.write_excel_insert import write_excel_insert
|
||||||
from search import search_article
|
from utils.upload import upload_excel
|
||||||
from update import update_records
|
|
||||||
from insert import insert_records
|
|
||||||
from write import write_excel
|
|
||||||
from write_excel_insert import write_excel_insert
|
|
||||||
from upload import upload_excel
|
|
||||||
|
|
||||||
|
|
||||||
host = "62.86.98.170"
|
host = "62.86.98.170"
|
||||||
@ -26,7 +20,7 @@ port = 3307
|
|||||||
conn = create_connection(host, user, password, database, port)
|
conn = create_connection(host, user, password, database, port)
|
||||||
#leggo il file excel
|
#leggo il file excel
|
||||||
file_input = upload_excel()
|
file_input = upload_excel()
|
||||||
df = pd.read_excel(file_input, usecols='A:O')
|
df = pd.read_excel(file_input, usecols='A:O', dtype={'FORNITORE': str, 'CODICE ALTERNATIVO': str})
|
||||||
|
|
||||||
#leggo le colonne del file excel
|
#leggo le colonne del file excel
|
||||||
for index, row in df.iterrows():
|
for index, row in df.iterrows():
|
||||||
@ -84,9 +78,9 @@ for index, row in df.iterrows():
|
|||||||
len_descrizione = len(descrizione)
|
len_descrizione = len(descrizione)
|
||||||
if len_descrizione > 40 :
|
if len_descrizione > 40 :
|
||||||
descrizione1 = descrizione [: 40]
|
descrizione1 = descrizione [: 40]
|
||||||
print(descrizione1)
|
#print(descrizione1)
|
||||||
descrizione2 = descrizione [40 :]
|
descrizione2 = descrizione [40 :]
|
||||||
print(descrizione2)
|
#print(descrizione2)
|
||||||
descrizione = descrizione1
|
descrizione = descrizione1
|
||||||
|
|
||||||
if conn :
|
if conn :
|
||||||
@ -122,13 +116,13 @@ for index, row in df.iterrows():
|
|||||||
sc2 = ' '
|
sc2 = ' '
|
||||||
if math.isnan(ricarica):
|
if math.isnan(ricarica):
|
||||||
ricarica = ' '
|
ricarica = ' '
|
||||||
if not pd.isna(codice_alternativo):
|
if pd.isna(codice_alternativo):
|
||||||
codice_alternativo = ' '
|
codice_alternativo = ' '
|
||||||
if not pd.isna(codice_barre):
|
if pd.isna(codice_barre):
|
||||||
codice_barre = '0000000000000'
|
codice_barre = '0000000000000'
|
||||||
if math.isnan(tsa_codice):
|
if math.isnan(tsa_codice):
|
||||||
tsa_codice = '0'
|
tsa_codice = '0'
|
||||||
if not pd.isna(frn):
|
if pd.isna(frn):
|
||||||
frn = ' '
|
frn = ' '
|
||||||
|
|
||||||
value_insert = insert_records(conn,codice,descrizione,descrizione2,um,prezzo,sc1,sc2,ricarica,listino,codice_alternativo,codice_barre,art,tsa_codice,frn)
|
value_insert = insert_records(conn,codice,descrizione,descrizione2,um,prezzo,sc1,sc2,ricarica,listino,codice_alternativo,codice_barre,art,tsa_codice,frn)
|
||||||
|
|||||||
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
@ -1,7 +1,4 @@
|
|||||||
import mysql.connector
|
|
||||||
from mysql.connector import Error
|
from mysql.connector import Error
|
||||||
import pandas as pd
|
|
||||||
import math
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
@ -1,11 +1,4 @@
|
|||||||
import pandas as pd
|
|
||||||
import mysql.connector
|
|
||||||
import math
|
|
||||||
import xlsxwriter
|
|
||||||
import tkinter as tk
|
|
||||||
from tkinter import filedialog,messagebox
|
|
||||||
from datetime import datetime
|
|
||||||
from mysql.connector import Error
|
|
||||||
|
|
||||||
def search_article(connection, codice, listino):
|
def search_article(connection, codice, listino):
|
||||||
cursor_1 = connection.cursor(buffered=True)
|
cursor_1 = connection.cursor(buffered=True)
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import mysql.connector
|
|
||||||
from mysql.connector import Error
|
from mysql.connector import Error
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import math
|
import math
|
||||||
@ -37,13 +37,13 @@ def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barr
|
|||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
result.append(count)
|
result.append(count)
|
||||||
|
|
||||||
if codice_barre is not None:
|
if len(codice_barre.strip()) > 0:
|
||||||
query_bar = "UPDATE bar SET CODICE_BARRE = %s WHERE ART_CODICE = %s"
|
query_bar = "UPDATE bar SET CODICE_BARRE = %s WHERE ART_CODICE = %s"
|
||||||
cursor.execute(query_bar, (codice_barre, codice))
|
cursor.execute(query_bar, (codice_barre, codice))
|
||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
result.append(count)
|
result.append(count)
|
||||||
|
|
||||||
if not pd.isna(codice_alternativo):
|
if len(codice_alternativo.strip()) > 0:
|
||||||
query_alt = "UPDATE art SET CODICE_ALTERNATIVO = %s WHERE codice = %s"
|
query_alt = "UPDATE art SET CODICE_ALTERNATIVO = %s WHERE codice = %s"
|
||||||
cursor.execute(query_alt, (codice_alternativo, codice))
|
cursor.execute(query_alt, (codice_alternativo, codice))
|
||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
@ -55,7 +55,7 @@ def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barr
|
|||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
result.append(count)
|
result.append(count)
|
||||||
|
|
||||||
if frn is not None and math.isnan(frn):
|
if len(frn.strip()) > 0:
|
||||||
query_art = "UPDATE art SET FRN_CODICE = %s WHERE codice = %s"
|
query_art = "UPDATE art SET FRN_CODICE = %s WHERE codice = %s"
|
||||||
cursor.execute(query_art, (frn, codice))
|
cursor.execute(query_art, (frn, codice))
|
||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
@ -1,11 +1,6 @@
|
|||||||
import pandas as pd
|
|
||||||
import mysql.connector
|
|
||||||
import math
|
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog,messagebox
|
from tkinter import filedialog
|
||||||
from datetime import datetime
|
|
||||||
from mysql.connector import Error
|
|
||||||
|
|
||||||
def upload_excel():
|
def upload_excel():
|
||||||
# Crea una finestra di dialogo per selezionare il file
|
# Crea una finestra di dialogo per selezionare il file
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import pandas as pd
|
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import pandas as pd
|
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
Reference in New Issue
Block a user