mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 23:26:29 +02:00
VK Terminal with tariff_description2
This commit is contained in:
parent
4108673ef1
commit
e6ca75a66a
10 changed files with 338 additions and 176 deletions
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -132,14 +132,24 @@ sub handler {
|
|||
$ctt = $dbt->fetch_tablerecord($dbh,$fetch_ctt) if($txid);
|
||||
$ctadr->{c_id} = $ctt->{int10} if($ctt->{int10});
|
||||
|
||||
my $fetch_ctadr = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
c_id => $ctadr->{c_id},
|
||||
};
|
||||
$ctadr = $dbt->fetch_tablerecord($dbh,$fetch_ctadr) if($ctadr->{c_id});
|
||||
my $vde_on_fail = $ctadr->{int12} || 1;#keep last or set 1
|
||||
|
||||
if($ctt->{c_id} > 0){
|
||||
|
||||
#balance > 0 then payment fails
|
||||
if($update_ctt->{int16} && $update_ctt->{int16} > 0){
|
||||
$update_adr->{int12} = $vde_on_fail;
|
||||
$update_ctt->{int14} = 1;
|
||||
$update_ctt->{txt23} = "$now_dt $txaction\nSaldo > 0 Meldung, Rücklastschrift oder Mahnung?\n" . $ctt->{txt23} if($ctt->{txt23} !~ /0 Meldung,/);#only once;
|
||||
$update_ctt->{txt23} = "$now_dt $txaction\nSaldo > 0 Meldung\n" . $ctt->{txt23} if($ctt->{txt23} !~ /0 Meldung,/);#only once;
|
||||
}else{
|
||||
$update_ctt->{int14} = "=::null";
|
||||
$update_adr->{int12} = "null";
|
||||
$update_ctt->{int14} = "null";
|
||||
$update_ctt->{txt23} = "$now_dt $txaction\n" . $ctt->{txt23};
|
||||
}
|
||||
|
||||
|
@ -147,7 +157,7 @@ sub handler {
|
|||
print FILE Dumper($update_ctt) . "\n";
|
||||
|
||||
#set cardexpiredate
|
||||
if($update_adr->{int24} && $update_adr->{int24} > 0 && $ctadr->{c_id} > 0){
|
||||
if(($update_adr->{int24} && $update_adr->{int24} > 0 || $ctadr->{int12} ne $update_adr->{int12}) && $ctadr->{c_id} > 0){
|
||||
$dbt->update_record($dbh,$update_adr,$ctadr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,23 +204,22 @@ sub sigo_available {
|
|||
$response_out->{$bike}->{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++;
|
||||
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});
|
||||
$response_out->{$bike}->{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++;
|
||||
$response_out->{$bike}->{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++;
|
||||
$response_out->{$bike}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / Tag"];
|
||||
}elsif($td eq "time02" && $tariff_content->{$tid}->{time02}){
|
||||
$i++;
|
||||
$response_out->{$bike}->{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});
|
||||
$response_out->{$bike}->{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/\./,/;
|
||||
$response_out->{$bike}->{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});
|
||||
$response_out->{$bike}->{tariff_description2}->{$i} = ["$td_template->{$td}","$time_unit / Tag"];
|
||||
$response_out->{$bike}->{tariff_description2}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
|
||||
}
|
||||
}#end new tariff_description2
|
||||
|
||||
|
|
|
@ -528,6 +528,28 @@ sub select_worktime {
|
|||
return $record;
|
||||
}
|
||||
|
||||
#all position of contenttrans
|
||||
sub collect_contentpos(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my ($table,$c_id) = @_;
|
||||
my $tb = "contenttrans";
|
||||
my $tbpos = "contenttranspos";
|
||||
my $where = "where ctt.c_id=pos.ct_id and ctt.c_id='$c_id'";
|
||||
|
||||
if($c_id){
|
||||
my $sth = $dbh->prepare("SELECT pos.* FROM $tbpos pos, $tb ctt $where");
|
||||
my $rc = $sth->execute();
|
||||
my $cpos = $sth->fetchall_hashref("c_id");
|
||||
my $rows = $sth->rows;
|
||||
return ($cpos,$rows);
|
||||
}else{
|
||||
my $cpos = { c_id => 0 };
|
||||
my $rows = 0;
|
||||
return ($cpos,$rows);
|
||||
}
|
||||
}
|
||||
|
||||
#Collect table ...post
|
||||
sub collect_post(){
|
||||
my $self = shift;
|
||||
|
@ -1220,12 +1242,14 @@ sub get_freetpl(){
|
|||
sub tariff_description2_template {
|
||||
my $self = shift;
|
||||
my $tpl_order = {
|
||||
int02 => "Mietgebühr",
|
||||
int15 => "Mietgebühr ab 2. Tag",
|
||||
#int16 => "Grundgebühr",
|
||||
int17 => "Max Gebühr",
|
||||
time01 => "Zeiteinheit",
|
||||
time02 => "Gratis Mietzeit",
|
||||
1 => {int35 => "Mietgebühr"},#unit_price1
|
||||
2 => {int36 => "Mietgebühr ab 2. Tag"},#unit_price2
|
||||
#3 => {int37 => "Grundgebühr"},#startup_price
|
||||
4 => {int17 => "Max. Gebühr"},#max_fee/day
|
||||
5 => {time01 => "Zeiteinheit"},#unit_time
|
||||
6 => {time02 => "Gratis Mietzeit"},#free_time
|
||||
7 => {xduration => "Aktuelle Mietzeit"},
|
||||
8 => {xprice => "Aktuelle Mietkosten"},
|
||||
};
|
||||
return $tpl_order;
|
||||
}
|
||||
|
@ -1234,11 +1258,22 @@ sub time_format {
|
|||
my $self = shift;
|
||||
my $time = shift;
|
||||
my $time_unit = "";
|
||||
my $day = "";
|
||||
if($time =~ /(\d+) day/){
|
||||
$day = $1;
|
||||
if($1 > 0 && $1 <= 1){
|
||||
$day .= " Tag ";
|
||||
}else{
|
||||
$day .= " Tage ";
|
||||
}
|
||||
$time_unit .= $day;
|
||||
$time =~ s/\d+ day //;
|
||||
}
|
||||
my ($std,$min,$sec) = split(/:/,$time);
|
||||
$std =~ s/^0//;
|
||||
$min =~ s/^0//;
|
||||
$time_unit = "$std Std " if($std > 0);
|
||||
$time_unit .= "$min Min" if($min > 0);
|
||||
$time_unit .= "$std Std " if($std > 0);
|
||||
$time_unit .= "$min Min " if($min > 0);
|
||||
return $time_unit;
|
||||
}
|
||||
|
||||
|
@ -1294,33 +1329,40 @@ sub insert_pos(){
|
|||
my $from_main_id = $ct->{main_id} || 0;
|
||||
my $station = $ct->{int04} || 0;
|
||||
my $rabatt = 0;
|
||||
my $unit_price1 = 0;
|
||||
|
||||
my $unit_price1 = $ct->{int02} || 0;
|
||||
my $unit_price2 = 0;
|
||||
my $start_price = 0;
|
||||
my $daymax_price = 0;
|
||||
my $startup_price = 0;
|
||||
my $abo_price = 0;#not used
|
||||
my $unit_time = "00:00";
|
||||
my $free_time = "00:00";
|
||||
|
||||
my $tariff_nr = 0;
|
||||
my $tariff_desc;
|
||||
my $unit_time = "00:00";
|
||||
my $fee_time = "00:00";
|
||||
my $free_hours = 0;#old
|
||||
my $sharing_type = 0;
|
||||
my $menge = 0;
|
||||
if(ref($ct_tariff) eq "HASH" && $ct_tariff->{barcode}){
|
||||
$rabatt = $ctadr->{int07} || 0;
|
||||
$unit_price1 = $ct_tariff->{int02} || 0;
|
||||
$unit_price2 = $ct_tariff->{int15} || 0;
|
||||
$startup_price = $ct_tariff->{int16} || 0;#not yet implemented (OLD Gratis Std/Rad --> migrate to time02)
|
||||
$unit_price1 = $ct_tariff->{int35} || 0;
|
||||
$unit_price2 = $ct_tariff->{int36} || 0;
|
||||
$start_price = $ct_tariff->{int37} || 0;
|
||||
$abo_price = $ct_tariff->{int15} || 0;#not used
|
||||
$free_hours = $ct_tariff->{int16} || 0;#old
|
||||
$daymax_price = $ct_tariff->{int17} || 0;
|
||||
$tariff_nr = $ct_tariff->{barcode} || 0;
|
||||
$tariff_desc = $ct_tariff->{ct_name};
|
||||
$unit_time = $ct_tariff->{time01} || "00:00";
|
||||
$fee_time = $ct_tariff->{time02} || "00:00";
|
||||
$free_time = $ct_tariff->{time02} || "00:00";
|
||||
$sharing_type = $ct_tariff->{int18} || 0;
|
||||
}
|
||||
|
||||
my $sth;
|
||||
#Verleihräder
|
||||
if($ct->{template_id} && $ct->{template_id} == 205){#Leihrad_list
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int15,int16,int17,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}',now(),now(),'$endRental','$unit_price1','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$unit_price2','$startup_price','$daymax_price','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$ct->{txt22}','$reserveid','$unit_time','$fee_time') RETURNING c_id");
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}',now(),now(),'$endRental','$unit_price1','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$ct->{txt22}','$reserveid','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id");
|
||||
}else{
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int02,int03,txt01,txt06,txt07,int10,int12,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','0','$user_name','$ctadr->{txt09}',now(),'$unit_price1','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$owner') RETURNING c_id");
|
||||
}
|
||||
|
|
|
@ -96,11 +96,12 @@ sub counting_rental {
|
|||
my $todo = shift;
|
||||
my $today4db = strftime("%Y-%m-%d %H:%M:%S",localtime(time));
|
||||
my $return = {};
|
||||
my $counting = { c_id => $ctpos->{c_id} };
|
||||
|
||||
my $computed_end_time = $ctpos->{end_time} || $today4db;
|
||||
$computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3);
|
||||
|
||||
|
||||
#main counting rental time and convert it to minute
|
||||
my $dt0 = DateTime::Format::Pg->parse_datetime($ctpos->{start_time});
|
||||
my $dt1 = DateTime::Format::Pg->parse_datetime($computed_end_time);
|
||||
my $dur10 = $dt1->subtract_datetime($dt0);
|
||||
|
@ -116,13 +117,13 @@ sub counting_rental {
|
|||
my $total_price = 0;
|
||||
my $ctpos_freed = { c_id => 0 };
|
||||
|
||||
#Tariff unit by time
|
||||
#convert tariff unit by minute time
|
||||
my $tariff_unitbyminute = 60;#defaults to Stundentarif
|
||||
if($ctpos->{time01} && $ctpos->{time01} =~ /[1-9]/){
|
||||
$tariff_unitbyminute = $self->clock_minutes($ctpos->{time01});
|
||||
}
|
||||
|
||||
#fee if ex. 00:30 Min/Gratis
|
||||
#substract free time from rental time ex. 00:30 Min/Gratis
|
||||
if($ctpos->{time02} && $ctpos->{time02} =~ /[1-9]/){
|
||||
$ctpos_freed = $self->only_first_free($ctpos);
|
||||
if(!$ctpos_freed->{c_id}){
|
||||
|
@ -140,89 +141,121 @@ sub counting_rental {
|
|||
}
|
||||
}
|
||||
|
||||
my $hours = "";#old
|
||||
my $rental_units = 0;
|
||||
my $price_by_allunits = 0;
|
||||
my $rental_unit = 0;
|
||||
my $price_by_allunit = 0;
|
||||
my $max_daily_unit = 0;#how many rental_minute is one daily_unit
|
||||
my $fee_daily_minute = 0;
|
||||
my $max_fee_daily_minute = 0;
|
||||
my $rental_day_price = 0;
|
||||
my $restal_minute = 0;
|
||||
my $rental_time_price = 0;
|
||||
my $rental_units_rounded = 0;
|
||||
my $rental_unit_rounded = 0;
|
||||
my $used_max_fee = "off";
|
||||
my $used_methode = "";
|
||||
|
||||
#readonly if bike available then take saved $total_price
|
||||
if($ctpos->{int10} && $ctpos->{int10} == 1 && $todo eq "readonly"){
|
||||
if($ctpos->{int03} && $ctpos->{int03} > 0 && $ctpos->{int02} && $ctpos->{int02} > 0){
|
||||
$total_price = $ctpos->{int03} * $ctpos->{int02};
|
||||
}
|
||||
#if($ctpos->{int38} && $ctpos->{int38} > 0 && $ctpos->{int35} && $ctpos->{int35} > 0){
|
||||
# $total_price = $ctpos->{int38} * $ctpos->{int35};
|
||||
# $used_methode = "readonly $ctpos->{int38} pos.int38 * $ctpos->{int35} pos.int35";
|
||||
#}
|
||||
}
|
||||
#on time unit
|
||||
elsif($rental_minute && $rental_minute > 0 && $ctpos->{int02} && $ctpos->{int02} > 0){
|
||||
$rental_units = $rental_minute / $tariff_unitbyminute;
|
||||
$price_by_allunits = $rental_units * $ctpos->{int02};
|
||||
#on time unit (int35 keeps unit_price1)
|
||||
elsif($rental_minute && $rental_minute > 0 && $ctpos->{int35} && $ctpos->{int35} > 0){
|
||||
$rental_unit = $rental_minute / $tariff_unitbyminute;
|
||||
$price_by_allunit = $rental_unit * $ctpos->{int35};
|
||||
|
||||
#max fee per day (day = 1440 minutes)
|
||||
if($ctpos->{int17} && $price_by_allunits >= $ctpos->{int17}){
|
||||
$used_max_fee = "on";
|
||||
$max_daily_unit = $ctpos->{int17} / $ctpos->{int02};
|
||||
$fee_daily_minute = $max_daily_unit * $tariff_unitbyminute;
|
||||
#max_fee/day (day = 1440 minutes)
|
||||
#useless if time01 unit is set to 24:00
|
||||
if($ctpos->{int17} && $ctpos->{int17} > 0 && $price_by_allunit >= $ctpos->{int17} && $tariff_unitbyminute < 1440){
|
||||
$used_methode .= "max_fee/day";
|
||||
$used_max_fee = "ON $ctpos->{int17}";
|
||||
$max_daily_unit = $ctpos->{int17} / $ctpos->{int35};
|
||||
$max_fee_daily_minute = $max_daily_unit * $tariff_unitbyminute;
|
||||
|
||||
my $days_dec = $rental_minute / 1440;
|
||||
my ($days,$ddec) = split(/\./, $days_dec) if($days_dec =~ /\.\d/);
|
||||
$rental_day_price = $days * $ctpos->{int17} if($days > 0);
|
||||
if($days > 0){
|
||||
$rental_day_price = $days * $ctpos->{int17};
|
||||
$counting->{int39} = $days;#by day
|
||||
$used_methode .= " | rental_day_price: $days days * $ctpos->{int17} pos.int17";
|
||||
}
|
||||
$restal_minute = $rental_minute - $days * 1440;
|
||||
if($restal_minute >= $fee_daily_minute){
|
||||
if($restal_minute >= $max_fee_daily_minute){
|
||||
$rental_day_price += $ctpos->{int17};
|
||||
$counting->{int39} += 1;#by day
|
||||
$used_methode .= " | += $ctpos->{int17} pos.int17";
|
||||
}else{
|
||||
$rental_units = $rental_minute / $tariff_unitbyminute;
|
||||
$rental_units_rounded = $rental_units;
|
||||
if($rental_units =~ /(\d+)\.(\d+)/){
|
||||
$rental_units_rounded = $1 + 1;
|
||||
$rental_unit = $restal_minute / $tariff_unitbyminute;
|
||||
#
|
||||
$rental_unit = sprintf('%.2f', $rental_unit);
|
||||
$rental_unit_rounded = $rental_unit;
|
||||
if($rental_unit =~ /(\d+)\.(\d+)$/){
|
||||
$rental_unit_rounded = $1 + 1 if($2 != 0);
|
||||
}
|
||||
$rental_time_price = $rental_units_rounded * $ctpos->{int02};
|
||||
$rental_time_price = $rental_unit_rounded * $ctpos->{int35};
|
||||
$counting->{int38} = $rental_unit_rounded;#by time
|
||||
$used_methode .= " | $rental_unit_rounded rental_unit_rounded * $ctpos->{int35} int35";
|
||||
}
|
||||
#else if price by all unit < max_fee/day
|
||||
}else{
|
||||
$rental_units = $rental_minute / $tariff_unitbyminute;
|
||||
$rental_units_rounded = $rental_units;
|
||||
if($rental_units =~ /(\d+)\.(\d+)/){
|
||||
$rental_units_rounded = $1 + 1;
|
||||
$rental_unit = $rental_minute / $tariff_unitbyminute;
|
||||
$rental_unit = sprintf('%.2f', $rental_unit);
|
||||
$rental_unit_rounded = $rental_unit;
|
||||
if($rental_unit =~ /(\d+)\.(\d+)/){
|
||||
$rental_unit_rounded = $1 + 1 if($2 != 0);
|
||||
}
|
||||
if(!$ctpos->{int36} && $ctpos->{int17} && $ctpos->{int17} > 0){
|
||||
$counting->{int38} = $rental_unit_rounded;#count by time
|
||||
$rental_time_price = $rental_unit_rounded * $ctpos->{int35};
|
||||
$used_methode .= " | $rental_unit_rounded rental_unit_rounded * $ctpos->{int35} int35";
|
||||
}elsif($ctpos->{int36}){#if second unit_price2 defined
|
||||
$counting->{int40} = 1;#by day
|
||||
$rental_time_price = 1 * $ctpos->{int35};
|
||||
$used_methode .= " | 1 rental_unit_rounded * $ctpos->{int35} int35";
|
||||
|
||||
if($rental_unit_rounded >= 2 && $ctpos->{int36} && $ctpos->{int36} > 0){
|
||||
my $rental_unit_rounded2 = $rental_unit_rounded - 1;#by day
|
||||
$counting->{int41} = $rental_unit_rounded2;
|
||||
$rental_time_price += $rental_unit_rounded2 * $ctpos->{int36};
|
||||
$used_methode .= " | $rental_unit_rounded2 rental_unit_rounded * $ctpos->{int36} int36";
|
||||
}
|
||||
}
|
||||
$rental_time_price = $rental_units_rounded * $ctpos->{int02};
|
||||
}
|
||||
}
|
||||
|
||||
my $computed_hours = $rental_minute / 60;
|
||||
|
||||
$total_price = $rental_day_price + $rental_time_price;
|
||||
$used_methode .= " --> $total_price total_price = $rental_day_price rental_day_price + $rental_time_price rental_time_price";
|
||||
$total_price = sprintf('%.2f', $total_price);
|
||||
|
||||
$return->{start_time} = "$ctpos->{start_time}";
|
||||
$return->{end_time} = "$computed_end_time";
|
||||
#$return->{real_clock} = "$real_clock";
|
||||
#$return->{computed_clock} = "$computed_clock";
|
||||
$return->{computed_hours} = "$computed_hours";
|
||||
$return->{unit_price} = "$ctpos->{int02}";
|
||||
$return->{unit_price} = "$ctpos->{int35}";
|
||||
$return->{real_clock} = "$real_clock";
|
||||
$return->{total_price} = "$total_price";
|
||||
|
||||
$return->{rentalog}->{real_clock} = "$real_clock";
|
||||
$return->{rentalog}->{computed_clock} = "$computed_clock";
|
||||
$return->{rentalog}->{computed_hours} = "$computed_hours";
|
||||
$return->{rentalog}->{rental_minute} = "$rental_minute";
|
||||
$return->{rentalog}->{fee_daily_minute} = "$fee_daily_minute";
|
||||
$return->{rentalog}->{max_fee_daily_minute} = "$max_fee_daily_minute";
|
||||
$return->{rentalog}->{tariff_unitbyminute} = "$tariff_unitbyminute";
|
||||
$return->{rentalog}->{restal_minute} = "$restal_minute";
|
||||
$return->{rentalog}->{rental_units_rounded} = "$rental_units_rounded";
|
||||
$return->{rentalog}->{rental_units} = "$rental_units";
|
||||
$return->{rentalog}->{price_by_allunits} = "$price_by_allunits";
|
||||
$return->{rentalog}->{rental_unit_rounded} = "$rental_unit_rounded";
|
||||
$return->{rentalog}->{rental_unit} = "$rental_unit";
|
||||
$return->{rentalog}->{price_by_allunit} = "$price_by_allunit";
|
||||
$return->{rentalog}->{rental_day_price} = "$rental_day_price";
|
||||
$return->{rentalog}->{total_price} = "$total_price";
|
||||
$return->{rentalog}->{rental_time_price} = "$rental_time_price";
|
||||
$return->{rentalog}->{ctpos_freed} = "$ctpos_freed->{c_id}";
|
||||
$return->{rentalog}->{used_max_fee} = "$used_max_fee";
|
||||
$return->{rentalog}->{used_methode} = "$used_methode";
|
||||
$return->{rentalog}->{counting} = $counting;
|
||||
|
||||
$bw->log("Pricing counting_rental return:",$return,"");
|
||||
return $return;
|
||||
return ($return,$counting);
|
||||
}#end counting_rental
|
||||
|
||||
#all other values returned by user_bikes_occupied
|
||||
|
@ -230,6 +263,7 @@ sub fetch_rentalfeed {
|
|||
my $self = shift;
|
||||
my $varenv = shift;
|
||||
my $ctpos = shift;
|
||||
my $returned_counting = shift || {};
|
||||
|
||||
my $td_template = $dbt->tariff_description2_template();
|
||||
my $bike_group = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int12}" || "";
|
||||
|
@ -250,8 +284,9 @@ sub fetch_rentalfeed {
|
|||
($return->{gps}->{latitude},$return->{gps}->{longitude}) = split(/,/,$ctpos->{txt06});
|
||||
|
||||
#if($ctpos->{txt10} =~ /requested|occupied/)
|
||||
if($ctpos->{int10} == 2 || $ctpos->{int10} == 3){
|
||||
|
||||
#if($ctpos->{int10} == 2 || $ctpos->{int10} == 3){
|
||||
#2022-04-26 disabled condition
|
||||
if(1==1){
|
||||
#deprecated
|
||||
$return->{tariff_description}->{name} = "$ctpos->{txt04}";
|
||||
$return->{tariff_description}->{number} = "$ctpos->{int09}";
|
||||
|
@ -259,33 +294,33 @@ sub fetch_rentalfeed {
|
|||
$return->{tariff_description}->{max_eur_per_day} = "$ctpos->{int17}" || "0";
|
||||
$return->{tariff_description}->{free_hours} = "$ctpos->{int16}" if($ctpos->{int16} && $ctpos->{int16} > 0);
|
||||
$return->{tariff_description}->{abo_eur_per_month} = "$ctpos->{int15}" if($ctpos->{int15} && $ctpos->{int15} > 0);
|
||||
$return->{tariff_description}->{track_info} = "Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!" if($ctpos->{int25});
|
||||
$return->{tariff_description}->{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($ctpos->{ca_id} == 1842 || $ctpos->{ca_id} == 5781);
|
||||
|
||||
#new tariff_description2
|
||||
$return->{tariff_description2}->{name} = "$ctpos->{txt04}";
|
||||
$return->{tariff_description2}->{number} = "$ctpos->{int09}";
|
||||
$return->{tariff_description2}->{track_info} = "Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!" if($ctpos->{int25});
|
||||
$return->{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($ctpos->{ca_id} == 1842 || $ctpos->{ca_id} == 5781);
|
||||
|
||||
my $i = 0;
|
||||
foreach my $td (keys (%$td_template)){
|
||||
foreach my $td (sort keys (%$td_template)){
|
||||
my $time_unit = "";
|
||||
$ctpos->{$td} =~ s/\./,/ if($td =~ /int\d+/);
|
||||
if($td eq "int02" && $ctpos->{int02} && $ctpos->{int02} > 0){
|
||||
$i++;
|
||||
if($td_template->{$td}->{int35} && $ctpos->{int35} && $ctpos->{int35} > 0){
|
||||
$ctpos->{int35} =~ s/\./,/;
|
||||
$time_unit = $dbt->time_format($ctpos->{time01});
|
||||
$return->{tariff_description2}->{$i} = ["$td_template->{$td}","$ctpos->{$td} € / $time_unit"];
|
||||
}elsif($td eq "int15" && $ctpos->{int15} && $ctpos->{int15} > 0){
|
||||
$i++;
|
||||
$return->{tariff_description2}->{$i} = ["$td_template->{$td}", "$ctpos->{$td} € / Std"];
|
||||
}elsif($td eq "int17" && $ctpos->{int17} && $ctpos->{int17} > 0){
|
||||
$i++;
|
||||
$return->{tariff_description2}->{$i} = ["$td_template->{$td}","$ctpos->{$td} € / Tag"];
|
||||
}elsif($td eq "time02" && $ctpos->{time02}){
|
||||
$i++;
|
||||
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{int35}","$ctpos->{int35} € / $time_unit"];
|
||||
}elsif($td_template->{$td}->{int36} && $ctpos->{int36} && $ctpos->{int36} > 0){
|
||||
$ctpos->{int36} =~ s/\./,/;
|
||||
$time_unit = $dbt->time_format($ctpos->{time01});
|
||||
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{int36}", "$ctpos->{int36} € / $time_unit"];
|
||||
}elsif($td_template->{$td}->{int17} && $ctpos->{int17} && $ctpos->{int17} > 0){
|
||||
$ctpos->{int17} =~ s/\./,/;
|
||||
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{int17}","$ctpos->{int17} € / Tag"];
|
||||
}elsif($td_template->{$td}->{time02} && $ctpos->{time02} =~ /[1-9]/){
|
||||
$time_unit = $dbt->time_format($ctpos->{time02});
|
||||
$return->{tariff_description2}->{$i} = ["$td_template->{$td}","$time_unit / Tag"];
|
||||
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
|
||||
}elsif($td_template->{$td}->{xduration} && $returned_counting->{real_clock} =~ /[1-9]/){
|
||||
$time_unit = $dbt->time_format($returned_counting->{real_clock});
|
||||
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{xduration}","$time_unit"];
|
||||
}elsif($td_template->{$td}->{xprice} && $returned_counting->{total_price} && $returned_counting->{total_price} > 0){
|
||||
$returned_counting->{total_price} =~ s/\./,/;
|
||||
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{xprice}","$returned_counting->{total_price} €"];
|
||||
}
|
||||
}#end new tariff_description2
|
||||
|
||||
|
@ -472,19 +507,19 @@ sub sprit2calc {
|
|||
my $einzel = $ctpos->{int02};
|
||||
my $menge = $ctpos->{int03};
|
||||
my $rabatt_val = $ctpos->{int07} || 0;
|
||||
my $gesamt = 0;
|
||||
my $total = 0;
|
||||
if($rabatt_val != 0 && $einzel && $menge){
|
||||
my $rabatt_eur = $rabatt_val;
|
||||
#if int08 != 1 alias €
|
||||
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($ctpos->{int08} != 1);
|
||||
$gesamt = $einzel * $menge - $rabatt_eur;
|
||||
$total = $einzel * $menge - $rabatt_eur;
|
||||
}elsif($einzel && $menge){
|
||||
$gesamt = $einzel * $menge;
|
||||
$total = $einzel * $menge;
|
||||
}
|
||||
|
||||
my $sprit_price = 0;
|
||||
$sprit_price = $ctpos->{int26} * 0.3 if($ctpos->{int26} != 0);
|
||||
$sprit_price -= $gesamt;
|
||||
$sprit_price -= $total;
|
||||
$sprit_price = sprintf('%.2f',$sprit_price);
|
||||
$sprit_price =~ s/\./,/;
|
||||
|
||||
|
@ -497,7 +532,7 @@ sub price2calc {
|
|||
my $self = shift;
|
||||
my $ctpos = shift;
|
||||
|
||||
my $gesamt = 0;
|
||||
my $total = 0;
|
||||
my $rabatt = "";
|
||||
my $einzel = $ctpos->{int02};
|
||||
my $menge = $ctpos->{int03};
|
||||
|
@ -506,9 +541,9 @@ sub price2calc {
|
|||
my $rabatt_eur = $rabatt_val;
|
||||
#if int08 != 1 alias €
|
||||
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($ctpos->{int08} != 1);
|
||||
$gesamt = $einzel * $menge - $rabatt_eur;
|
||||
$total = $einzel * $menge - $rabatt_eur;
|
||||
}elsif($einzel && $menge){
|
||||
$gesamt = $einzel * $menge;
|
||||
$total = $einzel * $menge;
|
||||
}
|
||||
|
||||
if($ctpos->{int07} && $ctpos->{int07} > 0 && $menge > 0){
|
||||
|
@ -521,6 +556,6 @@ sub price2calc {
|
|||
}
|
||||
}
|
||||
|
||||
return ($gesamt,$rabatt);
|
||||
return ($total,$rabatt);
|
||||
}
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue