mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 23:26:29 +02:00
Mietpreis refactoring
This commit is contained in:
parent
e6ca75a66a
commit
74ecbbd2a8
11 changed files with 169 additions and 242 deletions
|
@ -1087,8 +1087,6 @@ sub booking_update(){
|
|||
$gps = "$latitude,$longitude" if($latitude && $longitude);
|
||||
}
|
||||
|
||||
my $Ilockit_GUID = "";
|
||||
$Ilockit_GUID = $q->escapeHTML($q->param('Ilockit_GUID')) if($q->param('Ilockit_GUID') && $q->param('Ilockit_GUID') =~ /\w+-\w+-\w+-\w+$/);
|
||||
my $gps_age = 0;
|
||||
my $gps_age_minutes = 60;
|
||||
$gps_age = $q->escapeHTML($1) if($q->param('gps_age') =~ /^(\d+)/);#in milli-sec
|
||||
|
@ -1130,8 +1128,6 @@ sub booking_update(){
|
|||
}
|
||||
}else{
|
||||
|
||||
$update_pos->{txt17} = $Ilockit_GUID if($Ilockit_GUID);
|
||||
|
||||
|
||||
#prevent reset occupied values OR only if genkey defined
|
||||
#if(($state eq "occupied" && $record_pos->{txt10} =~ /requested/) || ($state eq "occupied" && $record_pos->{txt10} =~ /occupied/ && $q->param('genkey') eq "1"))
|
||||
|
@ -1168,6 +1164,7 @@ sub booking_update(){
|
|||
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
|
||||
#new sharee_pricing
|
||||
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
|
||||
#int03 only used for tarif counting backwards compatibility
|
||||
$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}));
|
||||
|
@ -1226,6 +1223,7 @@ sub booking_update(){
|
|||
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
|
||||
#new sharee_pricing
|
||||
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
|
||||
#int03 only used for tarif counting backwards compatibility
|
||||
$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}));
|
||||
|
@ -1262,6 +1260,7 @@ sub booking_update(){
|
|||
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
|
||||
#new sharee_pricing
|
||||
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
|
||||
#int03 only used for tarif counting backwards compatibility
|
||||
$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}));
|
||||
|
@ -1321,7 +1320,6 @@ sub booking_update(){
|
|||
#$self->service_automatic($q) if($1 <= 40);
|
||||
}
|
||||
$update_cc->{txt15} = $q->escapeHTML($q->param('firmware')) if($q->param('firmware'));
|
||||
$update_cc->{txt17} = $Ilockit_GUID if($Ilockit_GUID);
|
||||
|
||||
}
|
||||
#end Ilockit || sigo
|
||||
|
@ -1768,7 +1766,6 @@ sub bikes_available(){
|
|||
|
||||
if($record->{$id}->{int11} eq "2"){
|
||||
$return->{$id}->{system} = "Ilockit";
|
||||
$return->{$id}->{Ilockit_GUID} = "$record->{$id}->{txt17}";
|
||||
$return->{$id}->{Ilockit_ID} = "$record->{$id}->{txt18}";
|
||||
#if($users_serviceapp->{int09})
|
||||
#shareetool
|
||||
|
@ -1908,7 +1905,6 @@ sub bikes_all(){
|
|||
|
||||
if($record->{$id}->{int11} eq "2"){
|
||||
$return->{$id}->{system} = "Ilockit";
|
||||
$return->{$id}->{Ilockit_GUID} = "$record->{$id}->{txt17}";
|
||||
$return->{$id}->{Ilockit_ID} = "$record->{$id}->{txt18}";
|
||||
#shareetool
|
||||
if($q->param('authcookie') && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} == 187 && scalar(@{$user_tour} >= 1)){
|
||||
|
|
|
@ -1330,7 +1330,8 @@ sub insert_pos(){
|
|||
my $station = $ct->{int04} || 0;
|
||||
my $rabatt = 0;
|
||||
|
||||
my $unit_price1 = $ct->{int02} || 0;
|
||||
my $unit_price = $ct->{int02} || 0;#article price
|
||||
my $unit_price1 = 0;
|
||||
my $unit_price2 = 0;
|
||||
my $start_price = 0;
|
||||
my $daymax_price = 0;
|
||||
|
@ -1346,6 +1347,7 @@ sub insert_pos(){
|
|||
my $menge = 0;
|
||||
if(ref($ct_tariff) eq "HASH" && $ct_tariff->{barcode}){
|
||||
$rabatt = $ctadr->{int07} || 0;
|
||||
$unit_price = $ct_tariff->{int02} || 0;#old and should in future not used by rental
|
||||
$unit_price1 = $ct_tariff->{int35} || 0;
|
||||
$unit_price2 = $ct_tariff->{int36} || 0;
|
||||
$start_price = $ct_tariff->{int37} || 0;
|
||||
|
@ -1362,7 +1364,7 @@ sub insert_pos(){
|
|||
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,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");
|
||||
$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,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_price','$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->{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");
|
||||
}
|
||||
|
|
|
@ -640,6 +640,9 @@ sub handler {
|
|||
if(!$users_sharee->{int14}){
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_1}?cum=2$session_and\&$returnwww");
|
||||
exit 0;
|
||||
}elsif(!$payable_check){
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_1_5}$session");
|
||||
exit 0;
|
||||
}else{
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_3}?cum=2$session_and\&$returnwww");
|
||||
exit 0;
|
||||
|
|
|
@ -14,6 +14,10 @@ use CGI;
|
|||
use CGI::Carp qw(fatalsToBrowser);
|
||||
use CGI ':standard';
|
||||
use Date::Calc qw(:all);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use DateTime;
|
||||
use DateTime::Format::Pg;
|
||||
|
||||
use Lib::Config;
|
||||
use Mod::Buttons;
|
||||
use Mod::Libenz;
|
||||
|
@ -21,6 +25,7 @@ use Mod::Libenzdb;
|
|||
use Mod::DBtank;
|
||||
use Mod::Callib;
|
||||
use Mod::Payment;
|
||||
use Mod::Pricing;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
@ -44,6 +49,8 @@ sub preinit(){
|
|||
my $cb = new Callib;
|
||||
my $but = new Buttons;
|
||||
my $payone = new Payment;
|
||||
my $pri = new Pricing;
|
||||
|
||||
my %ib = $but->ibuttons();
|
||||
my %varenv = $cf->envonline();
|
||||
my $script = $q->script_name();
|
||||
|
@ -219,7 +226,7 @@ sub preinit(){
|
|||
$ct_node = $db->get_node4multi($ct->{main_id},$lang);
|
||||
#check if part linked to mandant
|
||||
my $mandant_check;
|
||||
$waren = $db->get_node2($users_dms->{fullurl},"Waren",$lang);
|
||||
$waren = $db->get_node2($varenv{wwwhost},"Waren",$lang);
|
||||
$mandant_check = $db->collect_noderec($waren->{main_id},$lang,"nothing") if($waren->{main_id});
|
||||
$mandant_check =~ s/,/|/g;
|
||||
$users_dms = $db->select_users($users_dms->{u_id}) if($ib_key =~ /new_/);#nur bei new_ mit save_
|
||||
|
@ -278,9 +285,9 @@ sub preinit(){
|
|||
}
|
||||
return "pos_id=$pos_id";#new return-code to get opened Part-Position in Transposition
|
||||
}elsif($ct_name && !$rel->{content_id}){
|
||||
return "failure::Für die Terminzuordnung bitte zuerst einen Verkauf Vorgang öffnen oder neu erzeugen.<br /> ::$script/$users_dms->{fullurl}/Verkauf::Zum Verkauf";
|
||||
return "failure::Für die Terminzuordnung bitte zuerst einen Verkauf Vorgang öffnen oder neu erzeugen.<br /> ::$varenv{wwwhost}/Verkauf::Zum Verkauf";
|
||||
}else{
|
||||
return "failure::Die Artikelnummer ist in der Waren Datenbank nicht angelegt oder einem anderen Lagerort zugeordnet.<br /> ::$script/$users_dms->{fullurl}/Waren::Waren verwalten";
|
||||
return "failure::Die Artikelnummer ist in der Waren Datenbank nicht angelegt oder einem anderen Lagerort zugeordnet.<br /> ::$varenv{wwwhost}/Waren::Waren verwalten";
|
||||
}
|
||||
}
|
||||
#####
|
||||
|
@ -323,22 +330,16 @@ sub preinit(){
|
|||
}elsif($ib_key eq "save_adr" || $ib_key =~ /save_text/){
|
||||
$table = "contenttrans";
|
||||
$c_id = "$R::c_id4trans";
|
||||
}elsif($ib_key =~ /save_tver/){
|
||||
$table = "contenttver";
|
||||
$c_id = "$users_dms->{c_id4trans}";
|
||||
$c_id = $R::c_id if($R::cell_key && $R::c_id);
|
||||
}elsif($ib_key eq "save_pos"){
|
||||
$table = "contenttranspos";
|
||||
$c_id = $R::c_idpos || $R::pos_id;
|
||||
}elsif($ib_key eq "save_verpos"){
|
||||
$table = "contenttverpos";
|
||||
$c_id = $R::c_idpos || $R::pos_id;
|
||||
}
|
||||
|
||||
#Miet- bzw. BaseVA- Zeitraum
|
||||
if($R::start_date =~ /\d{1,2}\.\d{1,2}\.\d{4}/ && $R::end_date =~ /\d{1,2}\.\d{1,2}\.\d{4}/){
|
||||
my $start_date = $q->escapeHTML("$R::start_date");
|
||||
my $end_date = $q->escapeHTML("$R::end_date");
|
||||
if($ib_key =~ /save_pos/ && $R::c_idpos && $R::start_date =~ /\d{1,2}\.\d{1,2}\.\d{4}/ && $R::end_date =~ /\d{1,2}\.\d{1,2}\.\d{4}/){
|
||||
my $pos_id = $R::c_idpos;
|
||||
my $start_date = "$3-$2-$1" if($R::start_date =~ /(\d{1,2})\.(\d{1,2})\.(\d{4})/);
|
||||
my $end_date = "$3-$2-$1" if($R::end_date =~ /(\d{1,2})\.(\d{1,2})\.(\d{4})/);
|
||||
my $s_hh = $q->escapeHTML("$R::s_hh") || "0";
|
||||
my $s_mi = $q->escapeHTML("$R::s_mi") || "0";
|
||||
my $e_hh = $q->escapeHTML("$R::e_hh") || "0";
|
||||
|
@ -347,56 +348,76 @@ sub preinit(){
|
|||
$e_hh = "24" if($e_hh > "24");
|
||||
$s_mi = "59" if($s_mi > "59");
|
||||
$e_mi = "59" if($e_mi > "59");
|
||||
my $start_time="null";
|
||||
my $end_time="null";
|
||||
$start_time = "$start_date $s_hh:$s_mi" if("$start_date $s_hh:$s_mi" =~ /\d{1,2}\.\d{1,2}\.\d{4}\s\d{1,2}:\d{1,2}/);
|
||||
$end_time = "$end_date $e_hh:$e_mi" if("$end_date $e_hh:$e_mi" =~ /\d{1,2}\.\d{1,2}\.\d{4}\s\d{1,2}:\d{1,2}/);
|
||||
my $start_time="";
|
||||
my $end_time="";
|
||||
$start_time = "$start_date $s_hh:$s_mi:00" if("$start_date $s_hh:$s_mi" =~ /\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}/);
|
||||
$end_time = "$end_date $e_hh:$e_mi:00" if("$end_date $e_hh:$e_mi" =~ /\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}/);
|
||||
|
||||
if($start_time && $end_time){
|
||||
my $dtnow = DateTime->now( time_zone => "Europe/Berlin" );
|
||||
my $dt0 = DateTime::Format::Pg->parse_datetime($start_time);
|
||||
my $dt1 = DateTime::Format::Pg->parse_datetime($end_time);
|
||||
|
||||
if($ib_key =~ /save_pos/){
|
||||
my $pos_id = $R::c_idpos;
|
||||
my ($start_datetime,$end_datetime,$menge) = $cb->contenttranspos_dating($pos_id,$start_time,$end_time,$today4db);
|
||||
my ($s_yy,$s_mo,$s_dd,$s_hh,$s_mi) = $cb->split_date($start_datetime);
|
||||
my $s_time = Mktime($s_yy,$s_mo,$s_dd,$s_hh,$s_mi,0);
|
||||
my ($e_yy,$e_mo,$e_dd,$e_hh,$e_mi) = $cb->split_date($end_datetime);
|
||||
my $e_time = Mktime($e_yy,$e_mo,$e_dd,$e_hh,$e_mi,0);
|
||||
if($dt0 < $dtnow && $dt1 < $dtnow){
|
||||
|
||||
my $ctpos_id=0;
|
||||
my $cvpos_id=0;
|
||||
$ctpos_id = $pos_id if($table eq "contenttranspos");
|
||||
$cvpos_id = $pos_id if($table eq "contenttverpos");
|
||||
$db->updater($table,"c_id",$pos_id,"start_time","$start_datetime",$users_dms->{u_id});
|
||||
$db->updater($table,"c_id",$pos_id,"end_time","$end_datetime",$users_dms->{u_id});
|
||||
#print "($s_time <= $time && $e_time >= $time) xxxx";
|
||||
#set contentpos status
|
||||
if($s_time <= $time && $e_time >= $time){
|
||||
$db->updater($table,"c_id",$pos_id,"int10","3",$users_dms->{u_id});
|
||||
}else{
|
||||
$db->updater($table,"c_id",$pos_id,"int10","1",$users_dms->{u_id});
|
||||
#2021-08-04 set also bike available
|
||||
$db->updater("content","c_id",$R::cc_id,"int10","1",$users_dms->{u_id}) if($R::cc_id);
|
||||
}
|
||||
#we believe setting by manually insert of int03=$menge via Transposition
|
||||
#$db->updater($table,"c_id",$pos_id,"int03","$menge",$users_dms->{u_id});
|
||||
#set GPS
|
||||
if($R::txt06 && $R::txt06 =~ /^(\d{1,2}\.\d+),\s?(\d{1,2}\.\d+)$/){
|
||||
$db->updater($table,"c_id",$pos_id,"txt06","$R::txt06",$users_dms->{u_id});
|
||||
}
|
||||
#set StationID
|
||||
if($R::int04 =~ /^\d+$/){
|
||||
$db->updater($table,"c_id",$pos_id,"int04","$R::int04",$users_dms->{u_id});
|
||||
#disbaled because we don't know for sure
|
||||
#$db->updater("content","c_id",$R::cc_id,"int04","$R::int04",$users_dms->{u_id}) if($R::cc_id);
|
||||
my $pref = {
|
||||
table => "contenttrans",
|
||||
table_pos => "contenttranspos",
|
||||
fetch => "one",
|
||||
template_id => "218",#Mietjournal tpl_id
|
||||
c_id => $pos_id,
|
||||
"ct.close_time" => "is::null",
|
||||
};
|
||||
|
||||
my $record_pos = {};
|
||||
my $pricing = {};
|
||||
my $counting = {};
|
||||
$record_pos = $dbt->collect_post($dbh,$pref);
|
||||
|
||||
my $update_pos = {
|
||||
table => "contenttranspos",
|
||||
start_time => "$start_time",
|
||||
end_time => "$end_time",
|
||||
owner => $users_dms->{u_id},
|
||||
mtime => "now()",
|
||||
};
|
||||
my $rows = $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||
#again to get setted date-times
|
||||
$record_pos = $dbt->collect_post($dbh,$pref);
|
||||
|
||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
|
||||
|
||||
#int03 only used for tarif counting backwards compatibility
|
||||
$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} = 1;
|
||||
$update_pos->{int04} = $R::int04 if(looks_like_number($R::int04));
|
||||
|
||||
if($R::cc_id =~/^\d+$/){
|
||||
my $ctpref = {
|
||||
table => "content",
|
||||
fetch => "one",
|
||||
c_id => $R::cc_id,
|
||||
};
|
||||
my $ctbike = $dbt->fetch_tablerecord($dbh,$ctpref);
|
||||
|
||||
if($ctbike->{int10} && ($ctbike->{int10} == 2 || $ctbike->{int10} == 3)){
|
||||
$db->updater("content","c_id",$R::cc_id,"int10","1",$users_dms->{u_id});
|
||||
if($R::int04 =~/^\d+$/){
|
||||
$db->updater("content","c_id",$R::cc_id,"int04","$R::int04",$users_dms->{u_id});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"start_time","$start_datetime",$users_dms->{u_id});
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"end_time","$end_datetime",$users_dms->{u_id});
|
||||
|
||||
}elsif($ib_key =~ /save_tver|save_verpos/){
|
||||
$u_rows += $db->updater("contenttver","c_id",$c_id,"start_time","$start_time");
|
||||
$u_rows += $db->updater("contenttver","c_id",$c_id,"end_time","$end_time");
|
||||
$db->users_up("cal_start","$start_time",$users_dms->{u_id}) if($varenv{dataflow} =~ /wiki/);
|
||||
}
|
||||
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"start_time","$start_time",$users_dms->{u_id});
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"end_time","$end_time",$users_dms->{u_id});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#hidden select keys to delete first, marked with off_ (Project.pm)
|
||||
|
@ -676,8 +697,8 @@ sub preinit(){
|
|||
$ctt->{sequence} = $R::payone_sequence || 1;
|
||||
|
||||
#only if int14 = OPOS (set by preauthorization)
|
||||
#if($ctt->{int14}){#TODO doupleclick
|
||||
if(1==1){
|
||||
#if($ctt->{int14})#TODO doupleclick
|
||||
if($state !~ /Zahlungseingang/){
|
||||
#SEPA capture
|
||||
if($ctt->{int03} == 1 && $ctt->{txt16} && $R::state =~ /SEPA/){#SEPA
|
||||
my $payoneret = $payone->captureSEPA_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id});
|
||||
|
@ -693,8 +714,8 @@ sub preinit(){
|
|||
return "failure::$return_text";
|
||||
|
||||
}
|
||||
}else{
|
||||
return "failure::Payone Geldeinzug nicht ausgeführt. Hat der Einzug bereits stattgefunden?";
|
||||
#}else{
|
||||
#return "failure::Payone Geldeinzug nicht ausgeführt. Hat der Einzug bereits stattgefunden?";
|
||||
}
|
||||
}else{
|
||||
$db->updater($table,"c_id",$ctt->{c_id},"int14","null","","","","","");
|
||||
|
|
|
@ -6,7 +6,7 @@ package Pricing;
|
|||
#Rental counting and pricing methods
|
||||
#
|
||||
#perl -cw
|
||||
use lib qw(/var/www/copri-bike/shareeapp-operator/src);
|
||||
#use lib qw(/var/www/copri-bike/shareeapp-operator/src);
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -124,10 +124,12 @@ sub counting_rental {
|
|||
}
|
||||
|
||||
#substract free time from rental time ex. 00:30 Min/Gratis
|
||||
my $freed_time = "";
|
||||
if($ctpos->{time02} && $ctpos->{time02} =~ /[1-9]/){
|
||||
$ctpos_freed = $self->only_first_free($ctpos);
|
||||
if(!$ctpos_freed->{c_id}){
|
||||
my ($dhh,$dmm) = split(/:/,$ctpos->{time02});
|
||||
$freed_time = "- $dhh:$dmm" if($dhh || $dmm);
|
||||
#adding free minutes to start_time
|
||||
$dt0->add( hours => $dhh, minutes => $dmm ) if(looks_like_number($dhh) && looks_like_number($dmm));
|
||||
|
||||
|
@ -190,7 +192,7 @@ sub counting_rental {
|
|||
$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_unit_rounded = $1 + 1 if($2 > 0);
|
||||
}
|
||||
$rental_time_price = $rental_unit_rounded * $ctpos->{int35};
|
||||
$counting->{int38} = $rental_unit_rounded;#by time
|
||||
|
@ -202,7 +204,7 @@ sub counting_rental {
|
|||
$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_unit_rounded = $1 + 1 if($2 > 0);
|
||||
}
|
||||
if(!$ctpos->{int36} && $ctpos->{int17} && $ctpos->{int17} > 0){
|
||||
$counting->{int38} = $rental_unit_rounded;#count by time
|
||||
|
@ -231,12 +233,14 @@ sub counting_rental {
|
|||
|
||||
$return->{start_time} = "$ctpos->{start_time}";
|
||||
$return->{end_time} = "$computed_end_time";
|
||||
$return->{freed_time} = "$freed_time";
|
||||
$return->{computed_hours} = "$computed_hours";
|
||||
$return->{unit_price} = "$ctpos->{int35}";
|
||||
$return->{real_clock} = "$real_clock";
|
||||
$return->{total_price} = "$total_price";
|
||||
|
||||
$return->{rentalog}->{real_clock} = "$real_clock";
|
||||
$return->{rentalog}->{freed_time} = "$freed_time";
|
||||
$return->{rentalog}->{computed_clock} = "$computed_clock";
|
||||
$return->{rentalog}->{computed_hours} = "$computed_hours";
|
||||
$return->{rentalog}->{rental_minute} = "$rental_minute";
|
||||
|
@ -324,7 +328,6 @@ sub fetch_rentalfeed {
|
|||
}
|
||||
}#end new tariff_description2
|
||||
|
||||
$return->{Ilockit_GUID} = "$ctpos->{txt17}" if($ctpos->{int11} == 2);
|
||||
$return->{Ilockit_ID} = "$ctpos->{txt18}" if($ctpos->{int11} == 2);
|
||||
($return->{gps}->{latitude},$return->{gps}->{longitude}) = split(/,/,$ctpos->{txt06});
|
||||
$return->{lock_state} = "locked" if($ctpos->{int20} == 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue