Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ root = ET.fromstring(response.content)
|
|
36 |
|
37 |
products = []
|
38 |
for item in root.findall('item'):
|
39 |
-
|
40 |
name_words = item.find('rootlabel').text.lower().split()
|
41 |
name = name_words[0]
|
42 |
full_name = ' '.join(name_words)
|
@@ -48,13 +48,13 @@ for item in root.findall('item'):
|
|
48 |
# Normal fiyat bilgisini al
|
49 |
price_str = item.find('priceTaxWithCur').text if item.find('priceTaxWithCur') is not None else "Fiyat bilgisi yok"
|
50 |
|
51 |
-
# EFT fiyatını al
|
52 |
price_eft_str = item.find('priceEft').text if item.find('priceEft') is not None else ""
|
53 |
|
54 |
-
# İndirimli fiyatı al
|
55 |
price_rebate_str = item.find('priceRebateWithTax').text if item.find('priceRebateWithTax') is not None else ""
|
56 |
|
57 |
-
# Havale indirimi fiyatını al
|
58 |
price_rebate_money_order_str = item.find('priceRebateWithMoneyOrderWithTax').text if item.find('priceRebateWithMoneyOrderWithTax') is not None else ""
|
59 |
|
60 |
# Normal fiyatı yuvarla
|
@@ -72,9 +72,9 @@ for item in root.findall('item'):
|
|
72 |
except (ValueError, TypeError):
|
73 |
price = price_str # Sayıya dönüştürülemezse olduğu gibi bırak
|
74 |
|
75 |
-
#
|
76 |
-
|
77 |
-
|
78 |
price_eft_float = float(price_eft_str)
|
79 |
if 1000 <= price_eft_float < 10000: # 4 basamaklı
|
80 |
price_eft = str(round(price_eft_float / 10) * 10)
|
@@ -84,10 +84,22 @@ for item in root.findall('item'):
|
|
84 |
price_eft = str(round(price_eft_float / 1000) * 1000)
|
85 |
else:
|
86 |
price_eft = price_eft_str
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
price_eft = ""
|
89 |
-
except (ValueError, TypeError):
|
90 |
-
price_eft = price_eft_str
|
91 |
|
92 |
# İndirimli fiyatı yuvarla
|
93 |
try:
|
@@ -106,7 +118,7 @@ for item in root.findall('item'):
|
|
106 |
except (ValueError, TypeError):
|
107 |
price_rebate = price_rebate_str
|
108 |
|
109 |
-
# Havale indirimi
|
110 |
try:
|
111 |
if price_rebate_money_order_str:
|
112 |
price_rebate_money_order_float = float(price_rebate_money_order_str)
|
@@ -288,6 +300,7 @@ def chatbot_fn(user_message, history):
|
|
288 |
]
|
289 |
|
290 |
|
|
|
291 |
# Döküman verilerini sistem mesajlarına ekle
|
292 |
if document_content:
|
293 |
system_messages.append({"role": "system", "content": f"Dökümanlardan gelen bilgiler: {document_content}"})
|
|
|
36 |
|
37 |
products = []
|
38 |
for item in root.findall('item'):
|
39 |
+
# Tüm ürünleri al, sonra stokta olma durumunu kontrol et
|
40 |
name_words = item.find('rootlabel').text.lower().split()
|
41 |
name = name_words[0]
|
42 |
full_name = ' '.join(name_words)
|
|
|
48 |
# Normal fiyat bilgisini al
|
49 |
price_str = item.find('priceTaxWithCur').text if item.find('priceTaxWithCur') is not None else "Fiyat bilgisi yok"
|
50 |
|
51 |
+
# EFT fiyatını al (havale indirimli orijinal fiyat)
|
52 |
price_eft_str = item.find('priceEft').text if item.find('priceEft') is not None else ""
|
53 |
|
54 |
+
# İndirimli fiyatı al (kampanyalı fiyat)
|
55 |
price_rebate_str = item.find('priceRebateWithTax').text if item.find('priceRebateWithTax') is not None else ""
|
56 |
|
57 |
+
# Havale indirimi fiyatını al (havale indirimli kampanyalı fiyat)
|
58 |
price_rebate_money_order_str = item.find('priceRebateWithMoneyOrderWithTax').text if item.find('priceRebateWithMoneyOrderWithTax') is not None else ""
|
59 |
|
60 |
# Normal fiyatı yuvarla
|
|
|
72 |
except (ValueError, TypeError):
|
73 |
price = price_str # Sayıya dönüştürülemezse olduğu gibi bırak
|
74 |
|
75 |
+
# Havale indirimli orijinal fiyatı yuvarla (varsa)
|
76 |
+
if price_eft_str:
|
77 |
+
try:
|
78 |
price_eft_float = float(price_eft_str)
|
79 |
if 1000 <= price_eft_float < 10000: # 4 basamaklı
|
80 |
price_eft = str(round(price_eft_float / 10) * 10)
|
|
|
84 |
price_eft = str(round(price_eft_float / 1000) * 1000)
|
85 |
else:
|
86 |
price_eft = price_eft_str
|
87 |
+
except (ValueError, TypeError):
|
88 |
+
price_eft = price_eft_str
|
89 |
+
else:
|
90 |
+
# Havale indirimli fiyat verilmemişse, orijinal fiyattan %2.5 indirim hesapla
|
91 |
+
try:
|
92 |
+
price_eft_float = price_float * 0.975 # %2.5 indirim
|
93 |
+
if 1000 <= price_eft_float < 10000: # 4 basamaklı
|
94 |
+
price_eft = str(round(price_eft_float / 10) * 10)
|
95 |
+
elif 10000 <= price_eft_float < 100000: # 5 basamaklı
|
96 |
+
price_eft = str(round(price_eft_float / 100) * 100)
|
97 |
+
elif price_eft_float >= 100000: # 6 basamaklı
|
98 |
+
price_eft = str(round(price_eft_float / 1000) * 1000)
|
99 |
+
else:
|
100 |
+
price_eft = str(round(price_eft_float))
|
101 |
+
except (ValueError, TypeError):
|
102 |
price_eft = ""
|
|
|
|
|
103 |
|
104 |
# İndirimli fiyatı yuvarla
|
105 |
try:
|
|
|
118 |
except (ValueError, TypeError):
|
119 |
price_rebate = price_rebate_str
|
120 |
|
121 |
+
# Havale indirimi kampanyalı fiyatı yuvarla
|
122 |
try:
|
123 |
if price_rebate_money_order_str:
|
124 |
price_rebate_money_order_float = float(price_rebate_money_order_str)
|
|
|
300 |
]
|
301 |
|
302 |
|
303 |
+
|
304 |
# Döküman verilerini sistem mesajlarına ekle
|
305 |
if document_content:
|
306 |
system_messages.append({"role": "system", "content": f"Dökümanlardan gelen bilgiler: {document_content}"})
|