@ -14,6 +14,7 @@ with open("settings.json") as s:
if settings [ " debug " ] :
if settings [ " debug " ] :
basicConfig ( filename = ' debug.log ' , encoding = ' utf-8 ' , level = DEBUG )
basicConfig ( filename = ' debug.log ' , encoding = ' utf-8 ' , level = DEBUG )
debug ( " \n \n \n ########################### VERSION = 3.10 ########################### \n \n \n " )
debug ( " Running main.py... " )
debug ( " Running main.py... " )
class MainWindow ( QtWidgets . QMainWindow , Ui_MainWindow ) :
class MainWindow ( QtWidgets . QMainWindow , Ui_MainWindow ) :
"""
"""
@ -104,7 +105,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
Launches the file selection dialog then inits the set_input function
Launches the file selection dialog then inits the set_input function
"""
"""
debug ( " Launching getfile. " )
debug ( " Launching getfile. " )
inFile = QtWidgets . QFileDialog . getOpenFileName ( self , ' Open file ' )
inFile = QtWidgets . QFileDialog . getOpenFileName ( self , ' Open file ' , directory = self . settings [ " defaultLocations " ] [ self . curReportType ] )
# If the user does not select a file we just exit and do not change anything
# If the user does not select a file we just exit and do not change anything
if inFile [ 0 ] == ' ' :
if inFile [ 0 ] == ' ' :
debug ( f " User did not select an input file! { inFile } " )
debug ( f " User did not select an input file! { inFile } " )
@ -178,6 +179,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
debug ( f " Process Selction | dataframe: \n { dataframe } " )
debug ( f " Process Selction | dataframe: \n { dataframe } " )
# The text preview box can have trouble loading the larger dataframes so
# The text preview box can have trouble loading the larger dataframes so
# they are trimmed to 500 so that the users can see if anything got messed up
# they are trimmed to 500 so that the users can see if anything got messed up
if dataframe . empty :
self . inputFilePreview . setText ( " Failed to create dataframe! " )
return None
smallDF = dataframe . iloc [ 0 : 500 , : ]
smallDF = dataframe . iloc [ 0 : 500 , : ]
self . inputFilePreview . setText ( smallDF . to_html ( index = False ) )
self . inputFilePreview . setText ( smallDF . to_html ( index = False ) )
# Enable the excel button so users can open the file
# Enable the excel button so users can open the file
@ -213,9 +217,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
Checks if a report type already has a default location
Checks if a report type already has a default location
If the default location is blank , the current inputFileLocation will be saved
If the default location is blank , the current inputFileLocation will be saved
"""
"""
if self . settings [ " defaultLocations " ] [ self . curReportType ] [ " dir " ] == ' ' :
if self . settings [ " defaultLocations " ] [ self . curReportType ] == ' ' :
self . settings [ " defaultLocations " ] [ self . curReportType ] [ " dir " ] = ( ' / ' ) . join ( self . inputFile . split ( ' / ' ) [ : - 1 ] )
self . settings [ " defaultLocations " ] [ self . curReportType ] = ( ' / ' ) . join ( self . inputFile . split ( ' / ' ) [ : - 1 ] )
debug ( f " checked_for_saved: saved new deafult location | { self . curReportType } | { self . settings [ ' defaultLocations ' ] [ self . curReportType ] [ ' dir ' ] } " )
debug ( f " checked_for_saved: saved new deafult location | { self . curReportType } | { self . settings [ ' defaultLocations ' ] [ self . curReportType ] } " )
with open ( ' settings.json ' , ' w ' ) as s :
with open ( ' settings.json ' , ' w ' ) as s :
# Save changes to the setting
# Save changes to the setting
json . dump ( self . settings , s )
json . dump ( self . settings , s )
@ -226,6 +230,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
# This will be used in settings the the extract function and determining file locations
# This will be used in settings the the extract function and determining file locations
# Disable the process report button since the input and output fields are now blank
# Disable the process report button since the input and output fields are now blank
self . processReportButton . setEnabled ( False )
self . processReportButton . setEnabled ( False )
self . openExcelButton . setEnabled ( False )
self . copyButton . setEnabled ( False )
self . openFolderButton . setEnabled ( False )
if self . reportTypeCB . currentText ( ) == " ACH " :
if self . reportTypeCB . currentText ( ) == " ACH " :
self . curReportType = " ach "
self . curReportType = " ach "
self . extract_function = ilx . ach
self . extract_function = ilx . ach
@ -269,32 +277,16 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self . curReportType = " pymt "
self . curReportType = " pymt "
self . extract_function = ilx . payment_transactions
self . extract_function = ilx . payment_transactions
# Replace the hard-coded dates in the default locations with the current date
self . inputFile = " "
inputRoot = self . settings [ " defaultLocations " ] [ self . curReportType ] [ " dir " ] \
. replace ( " {dd} " , dt . now ( ) . strftime ( ' %d ' ) ) \
. replace ( " {mm} " , dt . now ( ) . strftime ( ' % m ' ) ) \
. replace ( " {yyyy} " , dt . now ( ) . strftime ( ' % Y ' ) ) . replace ( " {yy} " , dt . now ( ) . strftime ( ' % y ' ) )
inputFile = self . settings [ " defaultLocations " ] [ self . curReportType ] [ " fn " ] \
. replace ( " {dd} " , dt . now ( ) . strftime ( ' %d ' ) ) \
. replace ( " {mm} " , dt . now ( ) . strftime ( ' % m ' ) ) \
. replace ( " {yyyy} " , dt . now ( ) . strftime ( ' % Y ' ) ) . replace ( " {yy} " , dt . now ( ) . strftime ( ' % y ' ) )
# If inputfile is blank, just leave the input root from settings
self . inputFile = f " { inputRoot } / { inputFile } " if ( inputFile != ' ' ) else inputRoot
self . inputFileLE . setText ( self . inputFile )
self . inputFileLE . setText ( self . inputFile )
# Automatically sets output to be in the same file as input, with a naming scheme
# Automatically sets output to be in the same file as input, with a naming scheme
# The report type selected in the combo box will dictate the naming
# The report type selected in the combo box will dictate the naming
if self . inputFile == " " :
outputroot = ( ' / ' ) . join ( self . inputFileLE . text ( ) . split ( ' / ' ) [ : - 1 ] )
else :
outputroot = inputRoot + ' / '
if self . curReportType == " minv " :
if self . curReportType == " minv " :
self . outputFile = f " { outputroot } { self . reportTypeCB . currentText ( ) } _ { dt . now ( ) . strftime ( ' % Y % m %d _ % H % M ' ) } .txt "
self . outputFile = f " { self . reportTypeCB . currentText ( ) } _ { dt . now ( ) . strftime ( ' % Y % m %d _ % H % M ' ) } .txt "
else :
else :
self . outputFile = f " { outputroot } { self . reportTypeCB . currentText ( ) . replace ( ' / ' , ' ' ) } _ { dt . now ( ) . strftime ( ' % Y % m %d _ % H % M ' ) } .xlsx "
self . outputFile = f " { self . reportTypeCB . currentText ( ) . replace ( ' / ' , ' ' ) } _ { dt . now ( ) . strftime ( ' % Y % m %d _ % H % M ' ) } .xlsx "
self . outputFileLE . setText ( self . outputFile )
self . outputFileLE . setText ( self . outputFile )
self . openExcelButton . setEnabled ( False )
self . copyButton . setEnabled ( False )
self . openFolderButton . setEnabled ( True )
debug ( f " report_type_change | inputFile: { self . inputFile } " )
debug ( f " report_type_change | inputFile: { self . inputFile } " )
debug ( f " report_type_change | outputFile: { self . outputFile } " )
debug ( f " report_type_change | outputFile: { self . outputFile } " )
self . check_ready_to_process ( )
self . check_ready_to_process ( )