Skip to content

Commit

Permalink
Merge pull request #59 from beckf/excel
Browse files Browse the repository at this point in the history
update notes and excel
  • Loading branch information
beckf authored Dec 21, 2021
2 parents 73e796e + f99b365 commit 38d374f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.31
1.32
46 changes: 19 additions & 27 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import datetime
import pytz
import config
import csv
import pandas
from decimal import Decimal, ROUND_HALF_UP
import images
import logging
Expand Down Expand Up @@ -247,9 +247,11 @@ def __init__(self):
# Check for Updates
try:
if self.version.update_avail():
self.debug_append_log("Updated Version Available! "
"Download at https://github.com/beckf/lightspeed-vc-connector/releases/latest",
"window,info")
self.debug_append_log("Updated Version Available!", "window,info")
self.debug_append_log("Latest Description:", "info,window")
self.debug_append_log(self.version.latest_description(), "window,info")
self.debug_append_log("Download at "
"https://github.com/beckf/lightspeed-vc-connector/releases/latest", "window,info")
except:
self.debug_append_log("Error checking for updates.", "window,debug")

Expand Down Expand Up @@ -833,25 +835,18 @@ def export_charge_balance(self):
try:
filename = str(self.ui.line_ExportFolder.text())
filename = filename + '/lightspeed_salelines_export_' + \
str(ct) + \
"_" + \
datetime.datetime.now().strftime('%m-%d-%Y') + '.csv'
datetime.datetime.now().strftime('%m%d%Y-%H%m%S') + '.xlsx'
self.debug_append_log(str(filename), "info")
except:
self.debug_append_log("Unable to determine export file.", "window,info")

try:
with open(filename, 'w', encoding='utf-8') as file:
salelines_writer = csv.writer(file, dialect='excel', quoting=csv.QUOTE_ALL, quotechar='"')

for row in saleline_export_data:
try:
salelines_writer.writerow(row)
except:
self.debug_append_log("Failed to write row %s" % str(row), "info")

writer = pandas.ExcelWriter(filename, engine='xlsxwriter')
panda_data = pandas.DataFrame(saleline_export_data)
panda_data.to_excel(writer, sheet_name='Sheet1', header=False, index=False)
writer.save()
except:
self.debug_append_log("Failed to format CSV SaleLine data.", "window,info")
self.debug_append_log("Failed to format XLSX SaleLine data.", "window,info")
return None

# !! Account Balance Export !!
Expand Down Expand Up @@ -902,17 +897,14 @@ def export_charge_balance(self):
try:
filename = str(self.ui.line_ExportFolder.text())
filename = filename + '/lightspeed_balance_export_' + \
str(ct) +\
"_" +\
datetime.datetime.now().strftime('%m-%d-%Y') + '.csv'

filepath = open(filename, 'w', encoding='utf-8')
with filepath:
writer = csv.writer(filepath, dialect='excel', quoting=csv.QUOTE_ALL, quotechar="'")
for row in export_data:
writer.writerow(row)
datetime.datetime.now().strftime('%m%d%Y-%H%m%S') + '.xlsx'

writer = pandas.ExcelWriter(filename, engine='xlsxwriter')
panda_data = pandas.DataFrame(export_data)
panda_data.to_excel(writer, sheet_name='Sheet1', header=False, index=False)
writer.save()
except:
self.debug_append_log("Failed to export CSV balance data.", "window,info")
self.debug_append_log("Failed to export XLSX balance data.", "window,info")
return None

# Finish of progress bar
Expand Down
16 changes: 16 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,20 @@ def update_avail(self):
except:
return False

def latest_description(self):
"""
Return description of latest release
:return: String Text
"""
try:
r = requests.get(self.project_url + '/releases/latest')

if r.status_code == 200:
d = r.json()
if "body" in d:
return d["body"]
else:
return ""
except:
return ""

0 comments on commit 38d374f

Please sign in to comment.