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});