From c6fedf71c5b531ade136a0b49ccfbf9a7a82a0f1 Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Wed, 5 Feb 2020 19:08:49 +0100 Subject: [PATCH] [trainline] handle carrier_invoice as a purchase carrier_invoice comes along with another "proof", a purchase, but the CapDocument model doesn't exactly fit the trainline model. So we make it a Bill, in order to be able to download the pdf. --- modules/trainline/pages.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/trainline/pages.py b/modules/trainline/pages.py index f63bf13b5b..baf8c9e294 100644 --- a/modules/trainline/pages.py +++ b/modules/trainline/pages.py @@ -62,10 +62,14 @@ def build_doc(self, text): 'currency': pnr['currency'] or '', # because pnr['currency'] can be None } - assert proof['type'] in ('purchase', 'refund'), proof['type'] - if proof['type'] == 'purchase': + assert proof['type'] in ('purchase', 'refund', 'carrier_invoice'), proof['type'] + if proof['type'] in ('purchase', 'carrier_invoice'): # pnr['cents'] is 0 if this purchase has a refund, but there is nowhere to take it # except make an addition, but we don't do that + + # carrier_invoice comes along with a purchase + # typically when travel is in a foreign country + bill['price'] = pnr['cents'] bills.append(bill) else: # proof['type'] == 'refund' -- GitLab