From 9b05eed19b55a20c9e44687236b99da030330571 Mon Sep 17 00:00:00 2001 From: ragu Date: Fri, 14 Apr 2023 18:08:14 +0200 Subject: [PATCH] adding freed-time per day and reduce rental-history to max 1 month --- copri4/main/src/Mod/APIfunc.pm | 12 ++++++------ copri4/main/src/Mod/APIsigclient.pm | 2 +- copri4/main/src/Mod/DBtank.pm | 2 +- copri4/main/src/Mod/Pricing.pm | 1 + copri4/shareeapp-operator/src/Tpl/FormEdit.pm | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index ad58d47..dbccc1e 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -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 diff --git a/copri4/main/src/Mod/APIsigclient.pm b/copri4/main/src/Mod/APIsigclient.pm index 59ccbfc..61774b4 100755 --- a/copri4/main/src/Mod/APIsigclient.pm +++ b/copri4/main/src/Mod/APIsigclient.pm @@ -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 diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm index 5879780..e631cd5 100755 --- a/copri4/main/src/Mod/DBtank.pm +++ b/copri4/main/src/Mod/DBtank.pm @@ -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',"; diff --git a/copri4/main/src/Mod/Pricing.pm b/copri4/main/src/Mod/Pricing.pm index 1b632e4..5b461d2 100755 --- a/copri4/main/src/Mod/Pricing.pm +++ b/copri4/main/src/Mod/Pricing.pm @@ -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}); diff --git a/copri4/shareeapp-operator/src/Tpl/FormEdit.pm b/copri4/shareeapp-operator/src/Tpl/FormEdit.pm index 60ba3dc..492f73b 100755 --- a/copri4/shareeapp-operator/src/Tpl/FormEdit.pm +++ b/copri4/shareeapp-operator/src/Tpl/FormEdit.pm @@ -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");