summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-01-19 00:15:53 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-01-19 00:15:53 +0100
commit33cc19fca4c95c58e067e8e2df9bdf427be434e4 (patch)
treec238fdd563e2288b637f4f4e98b3e23d8d5655a4 /lib/Travel/Routing/DE
parent5075461af23c7016f045450808b4302d4109934f (diff)
Add basic support for discounts (BahnCard 25 / 50 / 100)
Diffstat (limited to 'lib/Travel/Routing/DE')
-rw-r--r--lib/Travel/Routing/DE/DBRIS.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Travel/Routing/DE/DBRIS.pm b/lib/Travel/Routing/DE/DBRIS.pm
index aa4a476..4a984f3 100644
--- a/lib/Travel/Routing/DE/DBRIS.pm
+++ b/lib/Travel/Routing/DE/DBRIS.pm
@@ -81,6 +81,32 @@ sub new {
deutschlandTicketVorhanden => \0
};
+ if ( @{ $conf{discount} // [] } ) {
+ $req->{reisende}[0]{ermaessigungen} = [];
+ }
+ for my $discount ( @{ $conf{discounts} // [] } ) {
+ my ( $type, $class );
+ for my $num (qw(25 50 100)) {
+ if ( $discount eq "bc${num}" ) {
+ $type = "BAHNCARD${num}";
+ $class = 'KLASSE_2';
+ }
+ elsif ( $discount eq "bc${num}-first" ) {
+ $type = "BAHNCARD${num}";
+ $class = 'KLASSE_1';
+ }
+ }
+ if ($type) {
+ push(
+ @{ $req->{reisende}[0]{ermaessigungen} },
+ {
+ art => $type,
+ klasse => $class,
+ }
+ );
+ }
+ }
+
$self->{strptime_obj} //= DateTime::Format::Strptime->new(
pattern => '%Y-%m-%dT%H:%M:%S',
time_zone => 'Europe/Berlin',