VK Terminal with tariff_description2

This commit is contained in:
ragu 2022-04-26 20:57:13 +02:00
parent 4108673ef1
commit e6ca75a66a
10 changed files with 338 additions and 176 deletions

View file

@ -1167,9 +1167,12 @@ sub booking_update(){
#return after booking_update
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
#new sharee_pricing
my $pricing = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
$update_pos->{int10} = "$state_key";
$update_pos->{txt11} = "$rentalid";
@ -1222,9 +1225,13 @@ sub booking_update(){
#return after booking_update
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
#new sharee_pricing
my $pricing = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
if($rows > 0){
@ -1254,9 +1261,13 @@ sub booking_update(){
#return after booking_update
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
#new sharee_pricing
my $pricing = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
$geo_debug .= "Out of station distance: $stations_raw->{$id}->{barcode}|$latitude,$longitude,$latitude_station,$longitude_station --> $geo_distance_next Meter ($geo_distance_next <= $geo_distance) station_next: $station_next\n";
@ -1665,8 +1676,8 @@ sub rentals(){
#$return->{$id} = $pri->sharee_pricing($record->{$id},"readonly");
#new sharee_pricing
my $return_counting->{$id} = $pri->counting_rental(\%varenv,$record->{$id},"readonly");
my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id});
(my $return_counting->{$id}, my $counting) = $pri->counting_rental(\%varenv,$record->{$id},"readonly");
my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id},$return_counting->{$id});
$return->{$id} = { %{ $return_counting->{$id} }, %{ $return_feed->{$id} } };
my $bike_id = $return->{$id}->{bike};
@ -1794,24 +1805,24 @@ sub bikes_available(){
$return->{$id}->{tariff_description2}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
my $i = 0;
foreach my $td (keys (%$td_template)){
foreach my $td (sort keys (%$td_template)){
my $time_unit = "";
$tariff_content->{$tid}->{$td} =~ s/\./,/ if($td =~ /int\d+/);
if($td eq "int02" && $tariff_content->{$tid}->{int02} && $tariff_content->{$tid}->{int02} > 0){
$i++;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / $time_unit"];
}elsif($td eq "int15" && $tariff_content->{$tid}->{int15} && $tariff_content->{$tid}->{int15} > 0){
$i++;
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}", "$tariff_content->{$tid}->{$td} € / Std"];
}elsif($td eq "int17" && $tariff_content->{$tid}->{int17} && $tariff_content->{$tid}->{int17} > 0){
$i++;
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / Tag"];
}elsif($td eq "time02" && $tariff_content->{$tid}->{time02}){
$i++;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time02});
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}","$time_unit / Tag"];
}
if($td_template->{$td}->{int35} && $tariff_content->{$tid}->{int35} && $tariff_content->{$tid}->{int35} > 0){
$tariff_content->{$tid}->{int35} =~ s/\./,/;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int35}","$tariff_content->{$tid}->{int35} € / $time_unit"];
}elsif($td_template->{$td}->{int36} && $tariff_content->{$tid}->{int36} && $tariff_content->{$tid}->{int36} > 0){
$tariff_content->{$tid}->{int36} =~ s/\./,/;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int36}", "$tariff_content->{$tid}->{int36} € / $time_unit"];
}elsif($td_template->{$td}->{int17} && $tariff_content->{$tid}->{int17} && $tariff_content->{$tid}->{int17} > 0){
$tariff_content->{$tid}->{int17} =~ s/\./,/;
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int17}","$tariff_content->{$tid}->{int17} € / Tag"];
}elsif($td_template->{$td}->{time02} && $tariff_content->{$tid}->{time02} =~ /[1-9]/){
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time02});
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
}
}#end new tariff_description2
}