adding freed-time per day and reduce rental-history to max 1 month

This commit is contained in:
ragu 2023-04-14 18:08:14 +02:00
parent 91e41f109e
commit 9b05eed19b
5 changed files with 11 additions and 10 deletions

View file

@ -1041,7 +1041,7 @@ sub count_freedrental {
my $mon = strftime "%m", localtime;
my $year = strftime "%Y", localtime;
my ($nyear,$nmon,$nday) = Add_Delta_YMD($year,$mon,$day, 0,0,1);
$pref_pos->{time_range} = "(start_time >= '$year-$mon-$day' and start_time < '$nyear-$nmon-$nday' OR int10=3)";
$pref_pos->{time_range} = "((start_time >= '$year-$mon-$day' and start_time < '$nyear-$nmon-$nday' and start_time != end_time) OR int10=3)";
}
my $record_pos = $dbt->fetch_tablerecord($dbh,$pref_pos);
@ -1257,9 +1257,6 @@ sub booking_update(){
$update_pos->{txt11} = "$sig_book->{rentalId}" if($sig_book->{rentalId});
$update_pos->{txt22} = "$sig_book->{bikeId}" if($sig_book->{bikeId});
#on occupied, we don't really know if will be a accountable rental, we try it
$self->count_freedrental($q,$varenv,$auth,0,$update_pos);
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
if($rows > 0){
@ -1815,8 +1812,11 @@ sub rentals(){
#$pricing
(my $return_counting->{$id}, my $counting) = $pri->counting_rental(\%varenv,$record->{$id},"");
#adjusting freed time rental by often called bikes_occupied, only viewable after second call
#adjusting freed time rental by often called bikes_occupied
$self->count_freedrental("rentals by user_bikes_occupied",\%varenv,$auth,$return_counting->{$id}->{rentalog}->{rental_minute_all},$record->{$id});
#yes once again to get the counted freedrental
(my $return_counting->{$id}, my $counting) = $pri->counting_rental(\%varenv,$record->{$id},"");
#$bw->log("rentals-rentalog",$return_counting->{$id}->{rentalog},"");
$return_counting->{$id}->{rentalog} = "";#just for debuggiog, removed to reduce data in json
my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id},$return_counting->{$id});
@ -2003,7 +2003,7 @@ sub bikes_available(){
$return->{$id}->{rental_description}->{tarif_elements}->{$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}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
$time_unit .= " / Tag" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz");
$return->{$id}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"];
}
}#end new rental_description

View file

@ -275,7 +275,7 @@ sub sig_available {
$response_out->{$bike}->{rental_description}->{tarif_elements}->{$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});
$response_out->{$bike}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"];
$response_out->{$bike}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
}
}#end new rental_description

View file

@ -957,7 +957,7 @@ sub update_record(){
$set .= " $key='$value',";
}
}
if($key =~ /^(barcode|contentadr_id|int\d+|time\d+|owner|start_at\d+|end_at\d+)$/){
if($key =~ /^(barcode|contentadr_id|int\d+|time\d+|owner|owner_end|start_at\d+|end_at\d+)$/){
$value =~ s/,/\./ if($value);
if($key =~ /int\d+|time\d+|start_at\d+|end_at\d+/ && $value && $value =~ /\d+:\d+/){#azn time format
$set .= " $key='$value',";

View file

@ -366,6 +366,7 @@ sub fetch_rentalfeed {
$return->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{int17}","$ctpos->{int17} € / Tag"];
}elsif($td_template->{$td}->{time02} && $ctpos->{time02} =~ /[1-9]/){
$time_unit = $dbt->time_format($ctpos->{time02});
$time_unit .= " / Tag" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz");
$return->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"];
}elsif($td_template->{$td}->{xduration} && $returned_counting->{real_clock} && $returned_counting->{real_clock} =~ /[1-9]/){
$time_unit = $dbt->time_format($returned_counting->{real_clock});

View file

@ -97,7 +97,7 @@ Weitere Personen aus Ihrem Haushalt profitieren jedoch ebenfalls, falls Sie weit
$ctrel = $users_sharee if(ref($users_sharee) eq "HASH" && $users_sharee->{c_id});
#
#collect rentals on operators and get operator hash with dbname->uri_operator
#$q->param(-name=>'month',-value=>"18");#disabled because changing to not invoiced positions
$q->param(-name=>'month',-value=>"1");
my ($cttpos,$operator_hash) = $apif->user_rentals_history($q,$ctrel);
#print Dumper($cttpos);
@ -344,7 +344,7 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
}elsif($key =~ /barcode/){
if($cttpos_count){
print $q->div({-style=>'padding-top:1.5em;font-weight:bold;'},"Folgende Positionen liegen zur nächsten Abbuchung vor"),"\n";
print $q->div({-style=>'padding-top:1.5em;font-weight:bold;'},"Folgende Positionen liegen zur nächsten Abbuchung vor (max. 1 Monat)"),"\n";
my @tpl_posorder = ("txt01=Beschreibung","int04=Station","ct_name=(Rad) Nummer","int26=CO2","int02=Betrag");