File inventory_synchronisation.py changed (mode: 100644) (index ab66838..f1c7df8) |
... |
... |
from tkinter.filedialog import askopenfilename, askdirectory |
3 |
3 |
import sys |
import sys |
4 |
4 |
import os |
import os |
5 |
5 |
import re |
import re |
|
6 |
|
import chardet |
6 |
7 |
from packages.syncfile import importAmazonOrder, importNewOrder |
from packages.syncfile import importAmazonOrder, importNewOrder |
7 |
8 |
#from packages.excelfile import createExcelSheet |
#from packages.excelfile import createExcelSheet |
8 |
9 |
|
|
|
... |
... |
def main(): |
16 |
17 |
|
|
17 |
18 |
use_current_dir = 'x' |
use_current_dir = 'x' |
18 |
19 |
newpath = '' |
newpath = '' |
|
20 |
|
export_file = {"filepath":"", |
|
21 |
|
"encoding":""} |
|
22 |
|
shipment_file = {"filepath":"", |
|
23 |
|
"encoding":""} |
19 |
24 |
# Check if there is already a Report folder for the Amazon report files, if not create a new one. |
# Check if there is already a Report folder for the Amazon report files, if not create a new one. |
20 |
25 |
reportpath = os.getcwd() + '/Report' |
reportpath = os.getcwd() + '/Report' |
21 |
26 |
if not os.path.exists(reportpath): |
if not os.path.exists(reportpath): |
|
... |
... |
def main(): |
108 |
113 |
|
|
109 |
114 |
# Ask the user if the task is to import received items at amazon or to |
# Ask the user if the task is to import received items at amazon or to |
110 |
115 |
# create a new order for production |
# create a new order for production |
111 |
|
line = chr(171) * 70 |
|
112 |
|
altline = chr(187) * 70 |
|
|
116 |
|
line = "#" * 70 |
|
117 |
|
altline = "|" * 70 |
113 |
118 |
print("{0}\n".format(line)) |
print("{0}\n".format(line)) |
114 |
|
print(" "+chr(420)+"reparation for the Script / Vorbereitung für den Script\n") |
|
|
119 |
|
print(" Preparation for the Script / Vorbereitung für den Script\n") |
115 |
120 |
print("{0}\n".format(line)) |
print("{0}\n".format(line)) |
116 |
121 |
print(" Get a export of all variations from plentymarkets\n & save it in Report\n") |
print(" Get a export of all variations from plentymarkets\n & save it in Report\n") |
117 |
122 |
print(" Lade einen Export von allen Varianten in Plentymarkets\n & speichere diesen in Report\n") |
print(" Lade einen Export von allen Varianten in Plentymarkets\n & speichere diesen in Report\n") |
|
... |
... |
def main(): |
138 |
143 |
root.withdraw() |
root.withdraw() |
139 |
144 |
print("\n{0}\n".format(line)) |
print("\n{0}\n".format(line)) |
140 |
145 |
print("Open the export file of all items, to get the Variation ID which is needed for the Upload.\n") |
print("Open the export file of all items, to get the Variation ID which is needed for the Upload.\n") |
141 |
|
export = askopenfilename(initialdir=reportpath |
|
|
146 |
|
export_file['filepath'] = askopenfilename(initialdir=reportpath |
142 |
147 |
, title="Export from Plentymarkets" |
, title="Export from Plentymarkets" |
143 |
148 |
, filetypes=[ ("csv files" ,"*.csv" ) ] ) |
, filetypes=[ ("csv files" ,"*.csv" ) ] ) |
|
149 |
|
# detect the encoding of the file |
|
150 |
|
with open(export_file['filepath'], mode='rb') as item: |
|
151 |
|
raw_data = item.read() |
|
152 |
|
export_file['encoding'] = chardet.detect(raw_data)['encoding'] |
144 |
153 |
|
|
145 |
154 |
# AMAZON RECEIVED PART |
# AMAZON RECEIVED PART |
146 |
155 |
if(task.lower() == 'amazon'): |
if(task.lower() == 'amazon'): |
147 |
156 |
print("Open the report file of the recent delivered FBA packages,\nthis will contain the amount of items that amazon received.\n") |
print("Open the report file of the recent delivered FBA packages,\nthis will contain the amount of items that amazon received.\n") |
148 |
157 |
print("\n{0}\n".format(line)) |
print("\n{0}\n".format(line)) |
149 |
|
report = askopenfilename(initialdir=reportpath |
|
|
158 |
|
shipment_file['filepath'] = askopenfilename(initialdir=reportpath |
150 |
159 |
, title="FBA-Report" |
, title="FBA-Report" |
151 |
160 |
, filetypes=[ ("csv files" ,"*.csv" ) ] ) |
, filetypes=[ ("csv files" ,"*.csv" ) ] ) |
|
161 |
|
# detect the encoding of the file |
|
162 |
|
with open(shipment_file['filepath'], mode='rb') as item: |
|
163 |
|
raw_data = item.read() |
|
164 |
|
shipment_file['encoding'] = chardet.detect(raw_data)['encoding'] |
152 |
165 |
|
|
153 |
166 |
try: |
try: |
154 |
|
importAmazonOrder(export=export, folder=uploadpath, orderid=order, |
|
155 |
|
plentyid=configid, report=report |
|
|
167 |
|
importAmazonOrder(export=export_file, folder=uploadpath, orderid=order, |
|
168 |
|
plentyid=configid, report=shipment_file |
156 |
169 |
) |
) |
157 |
170 |
except Exception as Err: |
except Exception as Err: |
158 |
171 |
print("Something went terribly wrong...") |
print("Something went terribly wrong...") |
|
... |
... |
def main(): |
162 |
175 |
if(task.lower() == 'order'): |
if(task.lower() == 'order'): |
163 |
176 |
print("Open the Excel list of items to be ordered.\n") |
print("Open the Excel list of items to be ordered.\n") |
164 |
177 |
print("\n{0}\n".format(line)) |
print("\n{0}\n".format(line)) |
165 |
|
neworder = askopenfilename(initialdir=reportpath |
|
|
178 |
|
shipment_file['filepath'] = askopenfilename(initialdir=reportpath |
166 |
179 |
, title="Order list for production" |
, title="Order list for production" |
167 |
180 |
, filetypes=[ ("csv files" ,"*.csv" ) ] ) |
, filetypes=[ ("csv files" ,"*.csv" ) ] ) |
|
181 |
|
# detect the encoding of the file |
|
182 |
|
with open(shipment_file['filepath'], mode='rb') as item: |
|
183 |
|
raw_data = item.read() |
|
184 |
|
shipment_file['encoding'] = chardet.detect(raw_data)['encoding'] |
168 |
185 |
|
|
169 |
186 |
try: |
try: |
170 |
|
order = importNewOrder(export=export, folder=uploadpath, orderlist=neworder, |
|
|
187 |
|
order = importNewOrder(export=export_file, folder=uploadpath, orderlist=shipment_file, |
171 |
188 |
orderid=order, producerlist=producer, |
orderid=order, producerlist=producer, |
172 |
189 |
plentyid=configid) |
plentyid=configid) |
173 |
190 |
except Exception as Err: |
except Exception as Err: |
|
... |
... |
def main(): |
178 |
195 |
if(task.lower() == 'fba'): |
if(task.lower() == 'fba'): |
179 |
196 |
print("Open the stock report with the calculated shipment.\n") |
print("Open the stock report with the calculated shipment.\n") |
180 |
197 |
print("\n{0}\n".format(line)) |
print("\n{0}\n".format(line)) |
181 |
|
newshipment = askopenfilename(initialdir=reportpath, |
|
|
198 |
|
shipment_file['filepath'] = askopenfilename(initialdir=reportpath, |
182 |
199 |
title="Latest stock report from Amazon", |
title="Latest stock report from Amazon", |
183 |
200 |
filetypes=[ ("csv files", "*.csv") ]) |
filetypes=[ ("csv files", "*.csv") ]) |
184 |
|
importAmazonOrder(export=export, reportfolder=reportpath, folder=uploadpath, |
|
185 |
|
orderid=order, plentyid=configid, stockreport=newshipment |
|
|
201 |
|
|
|
202 |
|
# detect the encoding of the file |
|
203 |
|
with open(shipment_file['filepath'], mode='rb') as item: |
|
204 |
|
raw_data = item.read() |
|
205 |
|
shipment_file['encoding'] = chardet.detect(raw_data)['encoding'] |
|
206 |
|
|
|
207 |
|
importAmazonOrder(export=export_file, reportfolder=reportpath, folder=uploadpath, |
|
208 |
|
orderid=order, plentyid=configid, stockreport=shipment_file |
186 |
209 |
) |
) |
187 |
210 |
#try: |
#try: |
188 |
211 |
#print("here will be the function for the ExcelSheet") |
#print("here will be the function for the ExcelSheet") |
File packages/picklist_creation.py changed (mode: 100644) (index 5e48b4c..3a84ec5) |
1 |
1 |
from tkinter import Tk |
from tkinter import Tk |
2 |
2 |
import csv |
import csv |
|
3 |
|
import chardet |
3 |
4 |
from tkinter.filedialog import askopenfilename |
from tkinter.filedialog import askopenfilename |
4 |
5 |
from packages import syncfile |
from packages import syncfile |
5 |
6 |
|
|
6 |
7 |
def picklist_creation(shipmentlist, folder, uploadfolder): |
def picklist_creation(shipmentlist, folder, uploadfolder): |
7 |
8 |
|
|
|
9 |
|
location_file = {"filepath": "", |
|
10 |
|
"encoding": ""} |
8 |
11 |
# Get the path of the locationlist |
# Get the path of the locationlist |
9 |
|
locationlist = askopenfilename(initialdir=folder, |
|
|
12 |
|
location_file['filepath'] = askopenfilename(initialdir=folder, |
10 |
13 |
title="Locationlist", |
title="Locationlist", |
11 |
14 |
filetypes=[ ("csv files", "*.csv") ]) |
filetypes=[ ("csv files", "*.csv") ]) |
12 |
15 |
|
|
|
16 |
|
# check the encoding of the file |
|
17 |
|
with open(location_file['filepath'], mode = 'rb') as item: |
|
18 |
|
raw_data = item.read() |
|
19 |
|
location_file['encoding'] = chardet.detect(raw_data)['encoding'] |
|
20 |
|
|
13 |
21 |
# The headers of the outputfile |
# The headers of the outputfile |
14 |
22 |
column_names = ['Sku', 'location', 'Barcode', '@location', 'Shipment'] |
column_names = ['Sku', 'location', 'Barcode', '@location', 'Shipment'] |
15 |
23 |
|
|
|
... |
... |
def picklist_creation(shipmentlist, folder, uploadfolder): |
20 |
28 |
shipping_items = [] |
shipping_items = [] |
21 |
29 |
|
|
22 |
30 |
# Open the locationlist and gather all locations for each sku |
# Open the locationlist and gather all locations for each sku |
23 |
|
with open(locationlist, mode = 'r') as item: |
|
|
31 |
|
with open(location_file['filepath'], mode = 'r', encoding = location_file['encoding']) as item: |
24 |
32 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
25 |
33 |
|
|
26 |
34 |
for row in reader: |
for row in reader: |
File packages/syncfile.py changed (mode: 100644) (index 633782f..a61e4fd) |
... |
... |
from os.path import isfile |
7 |
7 |
from packages import picklist_creation |
from packages import picklist_creation |
8 |
8 |
|
|
9 |
9 |
# Define and initialize the line seperators |
# Define and initialize the line seperators |
10 |
|
line = chr(171)*70 |
|
11 |
|
altline = chr(187)*70 |
|
|
10 |
|
line = "#"*70 |
|
11 |
|
altline = "|"*70 |
12 |
12 |
|
|
13 |
13 |
def writeNewCsv(dataset, path, header, name): |
def writeNewCsv(dataset, path, header, name): |
14 |
14 |
'''Write Data into new CSV for Upload |
'''Write Data into new CSV for Upload |
|
... |
... |
def importAmazonOrder(export, reportfolder, folder, orderid, plentyid, report='' |
72 |
72 |
# initialize a dictionary to save the necessary data |
# initialize a dictionary to save the necessary data |
73 |
73 |
Data = {} |
Data = {} |
74 |
74 |
syncname = 'fba-received' |
syncname = 'fba-received' |
75 |
|
with open(report, mode='r') as item: |
|
|
75 |
|
with open(report['filepath'], mode='r', encoding=report['encoding']) as item: |
76 |
76 |
reader = csv.DictReader(item, delimiter="\t") |
reader = csv.DictReader(item, delimiter="\t") |
77 |
77 |
|
|
78 |
78 |
for position, row in enumerate( reader ): |
for position, row in enumerate( reader ): |
|
... |
... |
def importAmazonOrder(export, reportfolder, folder, orderid, plentyid, report='' |
125 |
125 |
town = towns[0] |
town = towns[0] |
126 |
126 |
countryid = countryids[0] |
countryid = countryids[0] |
127 |
127 |
|
|
128 |
|
with open(stockreport, mode = 'r') as item: |
|
|
128 |
|
with open(stockreport['filepath'], mode = 'r', encoding=stockreport['encoding']) as item: |
129 |
129 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
130 |
130 |
|
|
131 |
131 |
for row in reader: |
for row in reader: |
|
... |
... |
def importAmazonOrder(export, reportfolder, folder, orderid, plentyid, report='' |
156 |
156 |
position += 1 |
position += 1 |
157 |
157 |
|
|
158 |
158 |
# Open the Export file to get the right Variation ID for each SKU on the List |
# Open the Export file to get the right Variation ID for each SKU on the List |
159 |
|
with open(export, mode='r') as item: |
|
|
159 |
|
with open(export['filepath'], mode='r', encoding=export['encoding']) as item: |
160 |
160 |
reader = csv.DictReader(item, delimiter=";") |
reader = csv.DictReader(item, delimiter=";") |
161 |
161 |
|
|
162 |
162 |
for row in reader: |
for row in reader: |
|
... |
... |
def importNewOrder(export, folder, orderlist, orderid, producerlist, plentyid): |
183 |
183 |
producer_set = set() |
producer_set = set() |
184 |
184 |
producer_dict = dict() |
producer_dict = dict() |
185 |
185 |
order_amount = int() |
order_amount = int() |
186 |
|
with open(orderlist, mode='r') as item: |
|
|
186 |
|
with open(orderlist['filepath'], mode='r', encoding=orderlist['encoding']) as item: |
187 |
187 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
188 |
188 |
|
|
189 |
189 |
for row in reader: |
for row in reader: |
|
... |
... |
def importNewOrder(export, folder, orderlist, orderid, producerlist, plentyid): |
222 |
222 |
print(err) |
print(err) |
223 |
223 |
sys.exit() |
sys.exit() |
224 |
224 |
|
|
225 |
|
with open(export, mode='r') as item: |
|
|
225 |
|
with open(export['filepath'], mode='r', encoding=export['encoding']) as item: |
226 |
226 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
227 |
227 |
|
|
228 |
228 |
# Get the variation id and the price |
# Get the variation id and the price |
|
... |
... |
def importNewOrder(export, folder, orderlist, orderid, producerlist, plentyid): |
261 |
261 |
orderid = int( orderid ) + 1 |
orderid = int( orderid ) + 1 |
262 |
262 |
|
|
263 |
263 |
# Open the orderlist again, to fill in the producer details |
# Open the orderlist again, to fill in the producer details |
264 |
|
with open(orderlist, mode = 'r') as item: |
|
|
264 |
|
with open(orderlist['filepath'], mode = 'r', encoding=orderlist['encoding']) as item: |
265 |
265 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
266 |
266 |
|
|
267 |
267 |
for row in reader: |
for row in reader: |
|
... |
... |
def createInboundPlan(folder, shipmentlist, deliverydata): |
314 |
314 |
|
|
315 |
315 |
inboundplan = tkinter.filedialog.askopenfilename(initialdir=folder, |
inboundplan = tkinter.filedialog.askopenfilename(initialdir=folder, |
316 |
316 |
title="Inbound-plan Template file") |
title="Inbound-plan Template file") |
317 |
|
|
|
318 |
|
|
|