-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvnUpdate.py
More file actions
49 lines (37 loc) · 1.02 KB
/
InvnUpdate.py
File metadata and controls
49 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import csv
import datetime
import requests
from grabsku import bcinvn
from bcorders import order_inventory
from sprdshtimprt import rpinvn
old_product = {}
new_product = {}
update_invn = {}
rpinvnSet = set(rpinvn.keys())
bcinvnSet = set(bcinvn.keys())
d = datetime.date.today()
for sku in rpinvnSet.intersection(bcinvnSet):
update_invn[sku] = rpinvn[sku]
if sku in order_inventory:
update_invn[sku] = update_invn[sku] - order_inventory[sku]
for sku in bcinvnSet.difference(rpinvnSet):
old_product[sku] = bcinvn[sku]
for sku in rpinvnSet.difference(bcinvnSet):
new_product[sku] = rpinvn[sku]
with open('%s.csv' % (d), 'w+') as f:
w = csv.writer(f)
headers = ['Product SKU', 'Stock Level']
w.writerow(headers)
for row in update_invn.iteritems():
w.writerow(row)
f.close()
with open('oldproduct.csv', 'w+') as f:
w = csv.writer(f)
for row in old_product.iteritems():
w.writerow(row)
f.close()
with open('newproduct.csv', 'w+') as f:
w = csv.writer(f)
for row in new_product.iteritems():
w.writerow(row)
f.close()