|
@@ -22,19 +22,26 @@ def parse_order_confirmation_mail(mail):
|
|
|
# )
|
|
|
|
|
|
order_match = re.search(
|
|
|
- ur'Booking code:\s+(?P<order_id>[\d ]+)\s+'
|
|
|
- + ur'Customer number:\s+(?P<customer_id>PV\d+)\s+'
|
|
|
- + ur'Booking date:\s+(?P<order_date>.* \d{4})\s',
|
|
|
+ ur'(?P<order_id_label>Booking code|Buchungscode):\s+(?P<order_id>[\d ]+)\s+'
|
|
|
+ + ur'(Customer number|Kundennummer):\s+(?P<customer_id>PV\d+)\s+'
|
|
|
+ + ur'(Booking date|Buchungsdatum):\s+(?P<order_date>.* \d{4})\s',
|
|
|
msg_text,
|
|
|
re.MULTILINE | re.UNICODE
|
|
|
)
|
|
|
order_match_groups = order_match.groupdict()
|
|
|
|
|
|
- with ioex.setlocale('en_US.UTF-8'):
|
|
|
- order_date = datetime.datetime.strptime(
|
|
|
- order_match_groups['order_date'],
|
|
|
- '%b %d, %Y',
|
|
|
- )
|
|
|
+ if order_match_groups['order_id_label'] == 'Buchungscode':
|
|
|
+ with ioex.setlocale('de_AT.UTF-8'):
|
|
|
+ order_date = datetime.datetime.strptime(
|
|
|
+ order_match_groups['order_date'],
|
|
|
+ '%d. %b %Y',
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ with ioex.setlocale('en_US.UTF-8'):
|
|
|
+ order_date = datetime.datetime.strptime(
|
|
|
+ order_match_groups['order_date'],
|
|
|
+ '%b %d, %Y',
|
|
|
+ )
|
|
|
|
|
|
order = dingguo.Order(
|
|
|
u'oebb',
|
|
@@ -44,9 +51,9 @@ def parse_order_confirmation_mail(mail):
|
|
|
)
|
|
|
|
|
|
item_match = re.search(
|
|
|
- ur'(?P<price_brutto_currency>.)(?P<price_brutto>\d+\.\d+)'
|
|
|
+ ur'(?P<price_brutto_currency>.) ?(?P<price_brutto>\d+(\.|,)\d+)'
|
|
|
+ ur'[\W\w]+'
|
|
|
- + ur'Your Bookings?\s+'
|
|
|
+ + ur'(Your Bookings?|Ihre Buchung)\s+'
|
|
|
+ ur'(?P<departure_point>.*)\s+>\s+(?P<destination_point>.*)',
|
|
|
msg_text,
|
|
|
re.MULTILINE | re.UNICODE
|
|
@@ -55,7 +62,7 @@ def parse_order_confirmation_mail(mail):
|
|
|
order.items.append(dingguo.Transportation(
|
|
|
name = u'Train Ticket',
|
|
|
price_brutto = dingguo.Sum(
|
|
|
- float(item['price_brutto']),
|
|
|
+ float(item['price_brutto'].replace(',', '.')),
|
|
|
item['price_brutto_currency'],
|
|
|
),
|
|
|
departure_point = item['departure_point'],
|