List of commits:
Subject Hash Author Date (UTC)
first Version of the Sync Upload de9ea87dff9ced84f635dd05d5ae039be870ae8a Basti 2019-03-19 16:32:44
First commit including Readme and folder structure 7e77aa7abd6013ce56d6878c7004973e32011a13 Basti 2019-03-19 10:44:36
Commit de9ea87dff9ced84f635dd05d5ae039be870ae8a - first Version of the Sync Upload
Author: Basti
Author date (UTC): 2019-03-19 16:32
Committer name: Basti
Committer date (UTC): 2019-03-19 16:32
Parent(s): 7e77aa7abd6013ce56d6878c7004973e32011a13
Signing key:
Tree: 17c37c44e1695bb6efb8876504dbd11e8858a298
File Lines added Lines deleted
inventory_synchronisation.py 55 0
packages/__pycache__/syncfile.cpython-37.pyc 0 0
packages/syncfile.py 65 0
File inventory_synchronisation.py added (mode: 100644) (index 0000000..d6a982e)
1 from tkinter import Tk
2 from tkinter.filedialog import askopenfilename
3 import os
4 from packages.syncfile import createSyncFile
5 #from packages.excelfile import createExcelSheet
6
7 def main():
8
9 # Check if there is already a Report folder for the Amazon report files, if not create a new one.
10 reportpath = os.getcwd() + '/Report'
11 if not os.path.exists(reportpath):
12 os.makedirs(reportpath)
13
14 # Check if there is already a Upload folder if not create a new one.
15 uploadpath = os.getcwd() + '/Upload'
16 if not os.path.exists(uploadpath):
17 os.makedirs(uploadpath)
18
19 # Ask the User to enter the ID of the order that he wants to change
20 order = ''
21
22 while(not(order.isdigit())):
23 order = input('Please enter the ID of the Plentymarkets Order: ')
24
25 if(not(order.isdigit())):
26 print("Please enter a valid Order ID which only consists of numbers...")
27
28 # A filedialog for the export and the report file
29 root = Tk()
30 root.withdraw()
31 print("Open the export file of all items, to get the Variation ID which is needed for the Upload.\n")
32 export = askopenfilename(initialdir="/Report"
33 , title="Export from Plentymarkets"
34 , filetypes=[ ("csv files" ,"*.csv" ) ] )
35
36 print("Open the report file of the recent delivered FBA packages,\nthis will contain the amount of items that amazon received.\n")
37 report = askopenfilename(initialdir="/Report"
38 , title="FBA-Report"
39 , filetypes=[ ("csv files" ,"*.csv" ) ] )
40
41 try:
42 createSyncFile(export=export, report=report, orderid=order)
43 except Exception as Err:
44 print("Something went terribly wrong...")
45 print(Err)
46
47 try:
48 print("here will be the function for the ExcelSheet")
49 #createExcelSheet(export, report)
50 except Exception as Err:
51 print("Something went terribly wrong...")
52 print(Err)
53
54 if __name__ == '__main__':
55 main()
File packages/__pycache__/syncfile.cpython-37.pyc added (mode: 100644) (index 0000000..1c0cd29)
File packages/syncfile.py added (mode: 100644) (index 0000000..60ebb73)
1 import csv
2 from os.path import isfile
3
4 def writeNewCsv(dataset, header, name):
5 '''Write Data into new CSV for Upload
6 OUTPUT
7 '''''
8
9 output_path_number = 1
10 datatype = ".csv"
11 output_path = "Upload/" + name + "_upload_" + str(output_path_number) + datatype
12
13 while(isfile(output_path)):
14 output_path_number = int(output_path_number) + 1
15 output_path = "Upload/" + name + "_upload_" + str(output_path_number) + datatype
16
17 with open(output_path, mode='a') as item:
18 writer = csv.DictWriter(item, delimiter=";", fieldnames=header)
19 writer.writeheader()
20 for row in dataset:
21 if(dataset[row]['OrderItem.itemVariationId']):
22 writer.writerow(dataset[row])
23
24 if(isfile(output_path)):
25 print("Upload file successfully created under {0}".format(output_path))
26
27 return output_path
28
29
30 def createSyncFile(export, report, orderid):
31 # Define the headers of the new Sync File
32 column_names = ['OrderItem.itemVariationId','OrderItem.quantity'
33 , 'OrderItem.warehouseId', 'Order.id', 'Order.statusId']
34
35 # initialize a dictionary to save the necessary data
36 Data = {}
37
38 # Open the report file and scrape the SKU and the delivered amount
39 with open(report, mode='r') as item:
40 reader = csv.DictReader(item, delimiter="\t")
41
42 for row in reader:
43 # define the values for each column in this case the
44 # magic numbers are 104 (the id of our storage facility)
45 # and 3.1 which is the ID of the special FBA Status on Plenty
46 values = ['', row['quantity'], '104', orderid, '3.1']
47
48 # combine the values with the header names and name each dict key
49 # after the SKU, that way the sku can be used to get the right
50 # Variation ID
51 Data[row['sku']] = dict(zip(column_names, values))
52
53 # Open the Export file to get the right Variation ID for each SKU on the List
54 with open(export, mode='r') as item:
55 reader = csv.DictReader(item, delimiter=";")
56
57 for row in reader:
58 # Check if the row contains one of the SKU from the list
59 if(row['VariationNumber'] in [*Data] and row['VariationID']):
60 Data[row['VariationNumber']]['OrderItem.itemVariationId'] = row['VariationID']
61
62 # Write the finished Data dictionary into a new file
63
64 writeNewCsv(dataset=Data, header=column_names, name="Sync")
65
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/initBasti/Complete_Order_Plenty_Update

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/initBasti/Complete_Order_Plenty_Update

Clone this repository using git:
git clone git://git.rocketgit.com/user/initBasti/Complete_Order_Plenty_Update

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main