forked from twothreenine/krautkoopf_lieferscraping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoodsoft_article.py
36 lines (32 loc) · 1.44 KB
/
foodsoft_article.py
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
class Article:
def __init__(self, order_number, name, unit, price_net, available=True, note="", manufacturer="", origin="", vat=0, deposit=0, unit_quantity=1, category="", ignore=False, orig_unit=""):
self.available = available
self.order_number = order_number
self.name = name
self.note = note
self.manufacturer = manufacturer
self.origin = origin
self.unit = unit
self.price_net = price_net
self.vat = vat
self.deposit = deposit
self.unit_quantity = unit_quantity
self.category = category
self.ignore = ignore # if True, the article will not be imported
self.orig_unit = orig_unit # Short form of article's unit, used for distinguishing duplicates, not loaded into Foodsoft
def suffix(suffix, suffix_type=""):
word = ""
if suffix_type:
if suffix_type == "manufacturer":
word = "von "
elif suffix_type == "origin":
word = "aus "
return " (" + word + str(suffix) + ")"
def read_articles_from_csv(csv):
articles = []
articles_from_csv = list(csv)
if len(articles_from_csv) > 1:
for row in articles_from_csv[1:]:
article = Article(order_number=row[1], name=row[2], note=row[3], manufacturer=row[4], origin=row[5], unit=row[6], price_net=row[7], vat=row[8], deposit=row[9], unit_quantity=row[10], category=row[13])
articles.append(article)
return articles