mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-14 15:46:28 +02:00
Invoice refactoring
This commit is contained in:
parent
74ecbbd2a8
commit
b3fb4e2143
9 changed files with 220 additions and 441 deletions
|
@ -876,7 +876,7 @@ sub booking_request(){
|
|||
|
||||
my $dbh = "";
|
||||
my $bike_id = "";
|
||||
$bike_id = $1 if($bike =~ /(\d+)/);
|
||||
$bike_id = $1 if($bike =~ /(\d+)$/);
|
||||
|
||||
my $pos_id="";
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M", localtime;
|
||||
|
@ -1087,6 +1087,8 @@ 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
|
||||
|
@ -1127,7 +1129,7 @@ sub booking_update(){
|
|||
$booking_values->{response_text} = "Keine Reservierung zu Fahrrad Nr. " . $q->param('bike') . " gefunden.";
|
||||
}
|
||||
}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"))
|
||||
|
@ -1320,7 +1322,7 @@ 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
|
||||
}else{
|
||||
|
@ -1766,6 +1768,7 @@ 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
|
||||
|
@ -1814,7 +1817,7 @@ sub bikes_available(){
|
|||
$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/\./,/;
|
||||
#$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});
|
||||
|
@ -1905,6 +1908,7 @@ 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)){
|
||||
|
|
|
@ -1243,7 +1243,7 @@ sub tariff_description2_template {
|
|||
my $self = shift;
|
||||
my $tpl_order = {
|
||||
1 => {int35 => "Mietgebühr"},#unit_price1
|
||||
2 => {int36 => "Mietgebühr ab 2. Tag"},#unit_price2
|
||||
2 => {int36 => "ab 2. Tag"},#unit_price2
|
||||
#3 => {int37 => "Grundgebühr"},#startup_price
|
||||
4 => {int17 => "Max. Gebühr"},#max_fee/day
|
||||
5 => {time01 => "Zeiteinheit"},#unit_time
|
||||
|
@ -1318,6 +1318,10 @@ sub insert_pos(){
|
|||
my $reserveid = shift || "";
|
||||
|
||||
$ct_name = $ct->{barcode} if(!$ct_name);#artikelnr or bikenr
|
||||
my $prefix = "";
|
||||
$ct_name =~ s/S[1-9]X/SX/;#sig
|
||||
$prefix = $1 if($ct_name =~ /^([A-Z]+)(\d+)$/i);
|
||||
|
||||
my $user_name = $ctadr->{txt01};
|
||||
$user_name = $ctadr->{txt08} if(!$user_name || $user_name eq "no name");
|
||||
my $staff = 0;
|
||||
|
@ -1364,7 +1368,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,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");
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,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}','$prefix',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->{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");
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ sub preinit(){
|
|||
table => "contenttranspos",
|
||||
start_time => "$start_time",
|
||||
end_time => "$end_time",
|
||||
owner => $users_dms->{u_id},
|
||||
owner_end => $users_dms->{u_id},
|
||||
mtime => "now()",
|
||||
};
|
||||
my $rows = $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||
|
|
|
@ -38,6 +38,14 @@ sub new {
|
|||
|
||||
my $dbh = "";
|
||||
|
||||
sub round(){
|
||||
my $self = shift;
|
||||
my ($amount) = @_;
|
||||
$amount = $amount * (10**(2));
|
||||
my $rounded = int($amount + .5 * ($amount<=> 0)) / (10**(2));
|
||||
return $rounded;
|
||||
}
|
||||
|
||||
sub only_first_free(){
|
||||
my $self = shift;
|
||||
my $ctpos = shift;
|
||||
|
@ -206,14 +214,14 @@ sub counting_rental {
|
|||
if($rental_unit =~ /(\d+)\.(\d+)/){
|
||||
$rental_unit_rounded = $1 + 1 if($2 > 0);
|
||||
}
|
||||
if(!$ctpos->{int36} && $ctpos->{int17} && $ctpos->{int17} > 0){
|
||||
if($ctpos->{int36} == 0 && $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
|
||||
}elsif($ctpos->{int36} > 0){#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";
|
||||
$used_methode .= " | 1 rental_unit_rounded * $ctpos->{int35} int35 with unit_price2 $ctpos->{int36} 36";
|
||||
|
||||
if($rental_unit_rounded >= 2 && $ctpos->{int36} && $ctpos->{int36} > 0){
|
||||
my $rental_unit_rounded2 = $rental_unit_rounded - 1;#by day
|
||||
|
@ -229,7 +237,24 @@ sub counting_rental {
|
|||
|
||||
$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);
|
||||
#$total_price = sprintf('%.2f', $total_price);
|
||||
|
||||
my $discount = "";
|
||||
my $discount_val = $ctpos->{int07} || 0;
|
||||
if($discount_val != 0 && $total_price){
|
||||
my $discount_eur = $discount_val;
|
||||
$discount_eur = $total_price * $discount_val/100 if($ctpos->{int08} != 1);
|
||||
$total_price -= $discount_eur;
|
||||
|
||||
$discount = "-" . $ctpos->{int07};
|
||||
if($ctpos->{int08} == 1){
|
||||
$discount .= " €";
|
||||
}else{
|
||||
$discount =~ s/\.00//;
|
||||
$discount .= "%";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$return->{start_time} = "$ctpos->{start_time}";
|
||||
$return->{end_time} = "$computed_end_time";
|
||||
|
@ -238,6 +263,7 @@ sub counting_rental {
|
|||
$return->{unit_price} = "$ctpos->{int35}";
|
||||
$return->{real_clock} = "$real_clock";
|
||||
$return->{total_price} = "$total_price";
|
||||
$return->{discount} = "$discount";
|
||||
|
||||
$return->{rentalog}->{real_clock} = "$real_clock";
|
||||
$return->{rentalog}->{freed_time} = "$freed_time";
|
||||
|
@ -509,13 +535,13 @@ sub sprit2calc {
|
|||
|
||||
my $einzel = $ctpos->{int02};
|
||||
my $menge = $ctpos->{int03};
|
||||
my $rabatt_val = $ctpos->{int07} || 0;
|
||||
my $discount_val = $ctpos->{int07} || 0;
|
||||
my $total = 0;
|
||||
if($rabatt_val != 0 && $einzel && $menge){
|
||||
my $rabatt_eur = $rabatt_val;
|
||||
if($discount_val != 0 && $einzel && $menge){
|
||||
my $discount_eur = $discount_val;
|
||||
#if int08 != 1 alias €
|
||||
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($ctpos->{int08} != 1);
|
||||
$total = $einzel * $menge - $rabatt_eur;
|
||||
$discount_eur = $einzel * $menge * $discount_val/100 if($ctpos->{int08} != 1);
|
||||
$total = $einzel * $menge - $discount_eur;
|
||||
}elsif($einzel && $menge){
|
||||
$total = $einzel * $menge;
|
||||
}
|
||||
|
@ -530,35 +556,66 @@ sub sprit2calc {
|
|||
}
|
||||
|
||||
|
||||
#computes position price and rabatt
|
||||
#computes article position price and rabatt
|
||||
sub price2calc {
|
||||
my $self = shift;
|
||||
my $ctpos = shift;
|
||||
|
||||
my $total = 0;
|
||||
my $rabatt = "";
|
||||
my $discount = "";
|
||||
my $einzel = $ctpos->{int02};
|
||||
my $menge = $ctpos->{int03};
|
||||
my $rabatt_val = $ctpos->{int07} || 0;
|
||||
if($rabatt_val != 0 && $einzel && $menge){
|
||||
my $rabatt_eur = $rabatt_val;
|
||||
my $discount_val = $ctpos->{int07} || 0;
|
||||
if($discount_val != 0 && $einzel && $menge){
|
||||
my $discount_eur = $discount_val;
|
||||
#if int08 != 1 alias €
|
||||
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($ctpos->{int08} != 1);
|
||||
$total = $einzel * $menge - $rabatt_eur;
|
||||
$discount_eur = $einzel * $menge * $discount_val/100 if($ctpos->{int08} != 1);
|
||||
$total = $einzel * $menge - $discount_eur;
|
||||
}elsif($einzel && $menge){
|
||||
$total = $einzel * $menge;
|
||||
}
|
||||
|
||||
if($ctpos->{int07} && $ctpos->{int07} > 0 && $menge > 0){
|
||||
$rabatt = "-" . $ctpos->{int07};
|
||||
$discount = "-" . $ctpos->{int07};
|
||||
if($ctpos->{int08} == 1){
|
||||
$rabatt .= " €";
|
||||
$discount .= " €";
|
||||
}else{
|
||||
$rabatt =~ s/\.00//;
|
||||
$rabatt .= " %";
|
||||
$discount =~ s/\.00//;
|
||||
$discount .= " %";
|
||||
}
|
||||
}
|
||||
|
||||
return ($total,$rabatt);
|
||||
return ($total,$discount);
|
||||
}
|
||||
|
||||
#computes rental position price and rabatt
|
||||
sub rental_price2calc {
|
||||
my $self = shift;
|
||||
my $ctpos = shift || {};
|
||||
my $pricing = shift || {};
|
||||
|
||||
my $total = 0;
|
||||
my $discount = "";
|
||||
my $discount_val = $ctpos->{int07} || 0;
|
||||
if($discount_val != 0 && $pricing->{total_price}){
|
||||
my $discount_eur = $discount_val;
|
||||
#if int08 != 1 alias €
|
||||
$discount_eur = $pricing->{total_price} * $discount_val/100 if($ctpos->{int08} != 1);
|
||||
$total = $pricing->{total_price} - $discount_eur;
|
||||
}elsif($pricing->{total_price}){
|
||||
$total = $pricing->{total_price};
|
||||
}
|
||||
|
||||
if($ctpos->{int07} && $ctpos->{int07} > 0){
|
||||
$discount = "-" . $ctpos->{int07};
|
||||
if($ctpos->{int08} == 1){
|
||||
$discount .= " €";
|
||||
}else{
|
||||
$discount =~ s/\.00//;
|
||||
$discount .= " %";
|
||||
}
|
||||
}
|
||||
|
||||
return ($total,$discount);
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -85,7 +85,7 @@ td {
|
|||
}
|
||||
|
||||
.tdtxt {
|
||||
font-size:1em;
|
||||
font-size:0.91em;
|
||||
padding:0.1em 0.5em;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
|
@ -107,7 +107,7 @@ td {
|
|||
}
|
||||
|
||||
.tdint {
|
||||
font-size:1em;
|
||||
font-size:0.91em;
|
||||
padding:0.1em 0.5em;
|
||||
vertical-align: top;
|
||||
text-align: right;
|
||||
|
@ -342,11 +342,11 @@ td {
|
|||
#my $umst1619 = $lb->umst_breaking($ctt,"");
|
||||
|
||||
|
||||
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int03=Menge (Std:Min)","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
my ($cttpos,$rows) = $db->collect_contentpos("contenttrans",$c_id);
|
||||
foreach my $id (keys(%$cttpos)){
|
||||
if($cttpos->{$id}->{int26}){
|
||||
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int26=Einsparung","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int26=Einsparung","int03=Menge (Std:Min)","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,6 +387,8 @@ td {
|
|||
|
||||
#Tablecontent (ct_name(primary key))
|
||||
my $sum_parts19=0;
|
||||
my $diff19 = 100 + 19;
|
||||
my $sum_umst19=0;
|
||||
my $j=0;
|
||||
my $k=0;
|
||||
my $nullcount=0;
|
||||
|
@ -396,28 +398,33 @@ td {
|
|||
|
||||
my $gesamt = 0;
|
||||
my $rabatt = "";
|
||||
my $einzel = $cttpos->{$id}->{int02};
|
||||
my $menge = $cttpos->{$id}->{int03} || 0;
|
||||
my $unit = $cttpos->{$id}->{txt03};
|
||||
my $pricing = {};
|
||||
my $counting = {};
|
||||
my $rental_feed = {};
|
||||
|
||||
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos->{$id},"calc_price");
|
||||
$rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos->{$id},$counting);
|
||||
$rabatt = $pricing->{discount};
|
||||
$sum_parts19 += $pricing->{total_price};
|
||||
$gesamt = $pri->round($pricing->{total_price});
|
||||
$gesamt = sprintf('%.2f', $gesamt);
|
||||
}else{
|
||||
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
$sum_parts19 += $gesamt;
|
||||
$gesamt = $pri->round($gesamt);
|
||||
$gesamt = sprintf('%.2f', $gesamt);
|
||||
}
|
||||
|
||||
if($gesamt == 0){
|
||||
$nullcount++;
|
||||
}
|
||||
|
||||
if($gesamt != 0){
|
||||
$gesamt = $lb->round($gesamt);
|
||||
$gesamt = $lb->cashme($gesamt,",");
|
||||
|
||||
$j++;
|
||||
if($j<=$max_table_wc || $break_table_wc){
|
||||
|
||||
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
$sum_parts19 += $gesamt;
|
||||
$gesamt = $lb->round($gesamt);
|
||||
$gesamt = $lb->cashme($gesamt,",");
|
||||
|
||||
#2. empty loop for sum
|
||||
if($break_table_wc){
|
||||
#print "$j|";
|
||||
|
@ -446,15 +453,17 @@ td {
|
|||
if($key =~ /txt01/){
|
||||
print "<td class='tdtxt'>\n";
|
||||
if($cttpos->{$id}->{$key}){
|
||||
$cttpos->{$id}->{$key} =~ s/\<br \/\>/; /g;
|
||||
print "$cttpos->{$id}->{$key}<br />\n";
|
||||
$cttpos->{$id}->{$key} =~ s/\<br \/\>/, /g;
|
||||
my $tariff = "";
|
||||
$tariff = "<br />Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
|
||||
print "$cttpos->{$id}->{$key} $tariff<br />\n";
|
||||
}
|
||||
if($cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
#print "<br />\n";
|
||||
$cttpos->{$id}->{start_time} = $lb->time4de($cttpos->{$id}->{start_time},"1");
|
||||
$cttpos->{$id}->{end_time} = $lb->time4de($cttpos->{$id}->{end_time},"1");
|
||||
|
||||
print $q->span("Mietzeit: $cttpos->{$id}->{start_time} – $cttpos->{$id}->{end_time}"),"\n";
|
||||
print $q->span("$cttpos->{$id}->{start_time} – $cttpos->{$id}->{end_time}"),"\n";
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
|
@ -472,25 +481,36 @@ td {
|
|||
print $q->td({-class=>'tdint',-nowrap=>'1'},"$co2saving");
|
||||
}
|
||||
if($key =~ /int03/){
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
|
||||
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
print $q->td({-class=>'tdint',-nowrap=>1},"$pricing->{real_clock} $pricing->{freed_time}"),"\n";
|
||||
}else{
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
|
||||
}
|
||||
}
|
||||
|
||||
if($key =~ /int02/){
|
||||
if($cttpos->{$id}->{$key} == "0"){
|
||||
$cttpos->{$id}->{$key}="";
|
||||
if($key =~ /int02/){
|
||||
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
print "<td class='tdint' nowrap>\n";
|
||||
foreach my $fid (sort keys(%{ $rental_feed->{tariff_description2} })){
|
||||
if(ref($rental_feed->{tariff_description2}->{$fid}) eq "ARRAY"){
|
||||
print "$rental_feed->{tariff_description2}->{$fid}[0]: $rental_feed->{tariff_description2}->{$fid}[1]<br />\n";
|
||||
}
|
||||
}
|
||||
print "</td>\n";
|
||||
}else{
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
}
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
|
||||
}
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint',-nowrap=>1},"$cttpos->{$id}->{$key} €"),"\n";
|
||||
}
|
||||
}
|
||||
|
||||
if($key =~ /int04/){
|
||||
$gesamt .= " €";
|
||||
if($key =~ /int04/){
|
||||
$gesamt =~ s/\./,/;
|
||||
if($rabatt != 0){
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"(Rabatt $rabatt) $gesamt"),"\n";
|
||||
$rabatt =~ s/\./,/;
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$rabatt $gesamt €"),"\n";
|
||||
}else{
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$gesamt"),"\n";
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$gesamt €"),"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,18 +536,23 @@ td {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
my $diff19 = 100 + 19;
|
||||
my $sum_umst19 = $sum_parts19 / $diff19 * 19;
|
||||
$sum_umst19 = $lb->round($sum_umst19);
|
||||
if($sum_parts19 && $sum_parts19 != 0){
|
||||
$sum_umst19 = $sum_parts19 / $diff19 * 19;
|
||||
$sum_umst19 = $pri->round($sum_umst19);
|
||||
}
|
||||
my $sum_netto19 = $sum_parts19 - $sum_umst19;
|
||||
$sum_netto19 = $lb->cashme($sum_netto19);
|
||||
my $sum_nettoall = $sum_netto19;
|
||||
$sum_nettoall = $lb->cashme($sum_nettoall,",");
|
||||
$sum_netto19 = sprintf('%.2f', $sum_netto19);
|
||||
$sum_netto19 =~ s/\./,/;
|
||||
|
||||
my $sum_paid = $sum_parts19;
|
||||
$sum_parts19 = $lb->cashme($sum_parts19,",");
|
||||
$sum_umst19 = $lb->cashme($sum_umst19,",");
|
||||
$sum_paid = $lb->cashme($sum_paid,",");
|
||||
$sum_paid = $pri->round($sum_paid);
|
||||
my $sum_preauth = $sum_paid || 0;
|
||||
$sum_paid = sprintf('%.2f', $sum_paid);
|
||||
$sum_paid =~ s/\./,/;
|
||||
|
||||
$sum_parts19 = sprintf('%.2f', $sum_parts19);
|
||||
$sum_umst19 = sprintf('%.2f', $sum_umst19);
|
||||
$sum_umst19 =~ s/\./,/;
|
||||
|
||||
|
||||
print $q->Tr(),"\n";
|
||||
|
@ -549,7 +574,7 @@ td {
|
|||
if($ctt->{txt00} !~ /steuerfrei/){#dirty hack
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdint'},"Betrag Netto:"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_nettoall €"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_netto19 €"),"\n";
|
||||
if($sum_parts19 != "0"){
|
||||
print $q->Tr();
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"19% UmSt auf $sum_netto19 €:"),"\n";
|
||||
|
|
|
@ -746,257 +746,6 @@ sub save_transact(){
|
|||
}#end save_transact
|
||||
|
||||
|
||||
#online net bike booking
|
||||
#deprecated, use apif->booking_request
|
||||
sub net_booking(){
|
||||
my $self = shift;
|
||||
my $auth = shift;#API auth
|
||||
my $bikeIDin = shift;#API request
|
||||
my $owner = shift;
|
||||
my $gps = shift || "";
|
||||
|
||||
my %varenv = $cf->envonline();
|
||||
$bikeIDin =~ s/\s//g;
|
||||
my $bikeID = $q->escapeHTML($bikeIDin) if($bikeIDin =~ /\d+$/);
|
||||
my $db_bike = $bikeID;
|
||||
$db_bike = $1 if($db_bike =~ /(\d+)/);
|
||||
|
||||
my $pos_id="";
|
||||
my $return=0;
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M", localtime;
|
||||
my $dbh = "";
|
||||
my $response_state = "OK";
|
||||
my $response_text = "";
|
||||
|
||||
$bw->log("net_booking booking_request bikeIDin $bikeIDin, authID $auth->{c_id}",$bikeIDin,"");
|
||||
|
||||
my $ctadr = $db->get_contentrow("contentadr",$auth->{c_id});
|
||||
|
||||
my $update_adr = {
|
||||
table => "contentadr",
|
||||
mtime => "now()",
|
||||
owner => "$owner",
|
||||
c_id => "$ctadr->{c_id}",
|
||||
};
|
||||
|
||||
my $pref = {
|
||||
table => "contenttrans",
|
||||
fetch => "one",
|
||||
main_id => 300008,
|
||||
template_id => 218,
|
||||
#ca_id => "$ctadr->{c_id}",#TODO
|
||||
int10 => "$ctadr->{c_id}",
|
||||
state => "null",
|
||||
close_time => "is::null",
|
||||
};
|
||||
|
||||
|
||||
my $main_ids;
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $apif->fetch_tariff($varenv{dbname},$ctadr,"");
|
||||
$main_ids = join(",",@{$bike_group});
|
||||
$main_ids =~ s/[a-z_]+//ig;
|
||||
my $ct = {};
|
||||
my $pref_cc = {
|
||||
table => "content",
|
||||
fetch => "one",
|
||||
main_id => "IN::($main_ids)",
|
||||
barcode => $db_bike,
|
||||
int10 => 1,
|
||||
};
|
||||
|
||||
$ct = $dbt->fetch_record($dbh,$pref_cc) if($main_ids);
|
||||
|
||||
|
||||
|
||||
#$tariff_nr in contentadr are saved by COPRI OR user Tarif-Select!!!
|
||||
#This is the automatic user tariff setter
|
||||
my $tariff_nr = "";
|
||||
my @adr_tariff = ();
|
||||
if($ctadr->{txt30}){
|
||||
@adr_tariff = ("$ctadr->{txt30}");
|
||||
@adr_tariff = split(/\s+/,$ctadr->{txt30}) if($ctadr->{txt30} =~ /\w\s+\w/);
|
||||
}
|
||||
if(ref($ct) eq "HASH" && $ct->{main_id}){
|
||||
foreach my $id (keys (%$tariff_content)){
|
||||
foreach(@adr_tariff){
|
||||
$bw->log("adr_tariff array form $ctadr->{txt30}",$_,"");
|
||||
if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{int12} == $ct->{main_id} && $tariff_content->{$id}->{barcode} && $_ == $tariff_content->{$id}->{barcode}){
|
||||
$bw->log("1. net_booking tariff loop matches:",$tariff_content->{$id}->{barcode},"");
|
||||
$tariff_nr = $tariff_content->{$id}->{barcode};
|
||||
}
|
||||
}
|
||||
}
|
||||
#2021-07-10, if no tarif then update user account to fallback default public or private or hidden tarif
|
||||
#if(!$tariff_nr && !$ctadr->{txt30})
|
||||
if(!$tariff_nr){
|
||||
my @txt30 = ();
|
||||
foreach my $id (keys (%$tariff_content)){
|
||||
# #int18
|
||||
#<sharing_type>
|
||||
# 2 = "public"
|
||||
# 3 = "private"
|
||||
# 4 = "hidden-lv"
|
||||
#</sharing_type>
|
||||
if($tariff_content->{$id}->{int18} && ($tariff_content->{$id}->{int18} == 2 || $tariff_content->{$id}->{int18} == 3 || $tariff_content->{$id}->{int18} == 4)){
|
||||
#auto set tarif if requested bike matches flot
|
||||
if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{int12} == $ct->{main_id} && $tariff_content->{$id}->{barcode}){
|
||||
$bw->log("2. net_booking tariff loop matches:",$tariff_content->{$id}->{barcode},"");
|
||||
$tariff_nr = $tariff_content->{$id}->{barcode};
|
||||
push(@txt30, "$tariff_content->{$id}->{barcode}");
|
||||
}#add also other public tarif
|
||||
elsif($tariff_content->{$id}->{int18} && $tariff_content->{$id}->{int18} == 2 && $tariff_content->{$id}->{int12} && $tariff_content->{$id}->{barcode}){
|
||||
push(@txt30, "$tariff_content->{$id}->{barcode}");
|
||||
}
|
||||
}
|
||||
}
|
||||
$bw->log("--> NO user tariff defined, update user account to fallback default public or private or hidden",\@txt30,"");
|
||||
$dbt->update_one($dbh,$update_adr,"txt30='@txt30'");
|
||||
}else{
|
||||
$bw->log("--> user tariff selected",$tariff_nr,"");
|
||||
}
|
||||
}
|
||||
|
||||
$bw->log("---> bike $ct->{barcode} matching by bike_group: @{$bike_group} main_ids:$main_ids | user_group:@{$user_group} | Tarif selected: $tariff_nr",$tariff_content->{$tariff_nr},"");
|
||||
|
||||
if($ct->{c_id} && $tariff_nr){
|
||||
my $ctt;
|
||||
my $payoneable_check=0;
|
||||
if(($ctadr->{int03} == 1 && $ctadr->{ct_name} =~ /\w{2}-\d+/ && $ctadr->{ct_name} !~ /LV-\d+/) || ($ctadr->{int03} == 2 && length($ctadr->{ct_name}) >= 19) || ($ctadr->{int03} == 1 && $varenv{dbname} eq "sharee_lv" && $ctadr->{ct_name} =~ /LV-\d+/)){
|
||||
$payoneable_check=1;
|
||||
}else{
|
||||
$response_state="Failure 1006: There is no valid payment methode";
|
||||
$response_text="Bitte überprüfen Sie Ihre Profildaten auf Vollständigkeit, nur dann können wir das Fahrradmietsystem für Sie freischalten";
|
||||
}
|
||||
|
||||
$bw->log("--->0. payable_check=$payoneable_check for $ctadr->{txt08} int01=$ctadr->{int01}|int03=$ctadr->{int03}|int04=$ctadr->{int04}|int13=$ctadr->{int13}|int12=$ctadr->{int12}|$ctadr->{ct_name}|length($ctadr->{ct_name}) >= 19\n","","");
|
||||
|
||||
#int04==1 if email Ack
|
||||
#int13==1 if sms Ack
|
||||
#int12!=1|2|3 if Vde
|
||||
#int14==1 if AGB
|
||||
if($ctadr->{txt08} && $ctadr->{int04} == 1 && $ctadr->{int13} == 1 && !$ctadr->{int12} && $ctadr->{int14} && $payoneable_check){
|
||||
|
||||
$bw->log("---> net_booking select Tarif ct->{main_id}:$ct->{main_id}| tariff_nr:$tariff_nr| ct_tariff --> Tarif-Nr:$tariff_content->{$tariff_nr}->{barcode}|Tarif desc:$tariff_content->{$tariff_nr}->{ct_name}|unit_price:$tariff_content->{$tariff_nr}->{int02}|max EUR/Tag:$tariff_content->{$tariff_nr}->{int17}|Abo EUR:$tariff_content->{$tariff_nr}->{int15}|Gratis Std/Rad:$tariff_content->{$tariff_nr}->{int16}\n","","");
|
||||
|
||||
$ctt = $dbt->fetch_record($dbh,$pref);
|
||||
#if invoice exist
|
||||
if($ctt->{c_id}){
|
||||
my $ctpos = {};
|
||||
if($bikeID && $ctadr->{c_id}){
|
||||
my $booking_pos = {
|
||||
table => "contenttranspos",
|
||||
fetch => "one",
|
||||
barcode => "$db_bike",
|
||||
int10 => "IN::('2','3')",
|
||||
ca_id => "$ctadr->{c_id}",
|
||||
};
|
||||
$ctpos = $dbt->fetch_tablerecord($dbh,$booking_pos);
|
||||
}
|
||||
if(!$ctpos->{c_id}){
|
||||
#2 = "requested"
|
||||
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct,$ctadr,$tariff_content->{$tariff_nr},$now_dt,"$bikeID","2","$owner");
|
||||
if($pos_id){
|
||||
$response_state = "OK, bike " . $bikeID . " succesfully requested";
|
||||
$response_text = "Fahrrad Nr. $bikeID wurde erfolgreich für 15 Min. reserviert";
|
||||
$bw->log("--->2. (insert contenttranspos pos_id: $pos_id\n","","");
|
||||
#require "Mod/KMLout.pm";
|
||||
#my $kmlfile = Mod::KMLout::kmlGenerator($ctadr,"");
|
||||
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"start_time","$now_dt",$owner);
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"end_time","$now_dt",$owner);
|
||||
}else{
|
||||
$response_state="Failure 1007: booking request fails";
|
||||
$response_text="Entschuldigung, es ist ein Fehler aufgetreten. Bitte kontaktieren Sie unsere Hotline damit wir das Problem lösen können";
|
||||
}
|
||||
}
|
||||
#else if invoice does not exist, generate one
|
||||
}else{
|
||||
my $ct_id;
|
||||
if($ctt->{c_id}){
|
||||
$ct_id = $ctt->{c_id};
|
||||
}else{
|
||||
$ct_id = $dbt->insert_contenttrans($dbh,$ctadr,"300008","218","----","$owner");
|
||||
$ctt = $dbt->fetch_record($dbh,$pref);
|
||||
}
|
||||
$ctt = $dbt->fetch_record($dbh,$pref);
|
||||
|
||||
#TODO refactory, routines douple definend
|
||||
if($ctt->{c_id}){
|
||||
my $ctpos = {};
|
||||
if($bikeID && $ctadr->{c_id}){
|
||||
my $booking_pos = {
|
||||
table => "contenttranspos",
|
||||
fetch => "one",
|
||||
barcode => "$db_bike",
|
||||
int10 => "IN::('2','3')",
|
||||
ca_id => "$ctadr->{c_id}",
|
||||
};
|
||||
$ctpos = $dbt->fetch_tablerecord($dbh,$booking_pos);
|
||||
}
|
||||
if(!$ctpos->{c_id}){
|
||||
#2 = "requested"
|
||||
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct,$ctadr,$tariff_content->{$tariff_nr},$now_dt,"$bikeID","2","$owner");
|
||||
if($pos_id){
|
||||
$response_state = "OK, bike " . $bikeID . " succesfully requested";
|
||||
$response_text = "Fahrrad Nr. $bikeID wurde erfolgreich für 15 Min. reserviert";
|
||||
$bw->log("--->3. (insert contenttranspos pos_id: $pos_id\n","","");
|
||||
#require "Mod/KMLout.pm";
|
||||
#my $kmlfile = Mod::KMLout::kmlGenerator($ctadr,"");
|
||||
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"start_time","$now_dt",$owner);
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"end_time","$now_dt",$owner);
|
||||
}else{
|
||||
$response_state="Failure 1008: booking request fails";
|
||||
$response_text="Entschuldigung, es ist ein Fehler aufgetreten. Bitte kontaktieren Sie unsere Hotline damit wir das Problem lösen können";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{#end Vde AGB and payable_check
|
||||
$response_state="Failure 1005: user-account deactivated because of failing data";
|
||||
$response_text="Bitte überprüfen Sie Ihre Profildaten auf Vollständigkeit, nur dann können wir das Fahrradmietsystem für Sie freischalten";
|
||||
}
|
||||
|
||||
}else{
|
||||
my $ctpos = {};
|
||||
my $booking_pos = {
|
||||
table => "contenttranspos",
|
||||
fetch => "one",
|
||||
barcode => "$db_bike",
|
||||
int10 => "IN::('2','3')",
|
||||
ca_id => "$ctadr->{c_id}",
|
||||
};
|
||||
$ctpos = $dbt->fetch_tablerecord($dbh,$booking_pos) if($bikeID && $ctadr->{c_id});
|
||||
if($ctpos->{c_id}){
|
||||
$response_state = "OK, bike " . $bikeID . " already requested or occupied";
|
||||
$response_text = "Fahrrad Nr. " . $bikeID . " ist bereits reserviert";
|
||||
}elsif($ct->{c_id} && !$tariff_nr){
|
||||
$response_state="Failure 2089: booking bike $bikeID fails, no user tariff available";
|
||||
$response_text="Reservierungsfehler Fahrrad Nr. $bikeID. Es konnte kein Mietrad Tarif gefunden werden.";
|
||||
}else{
|
||||
$response_state="Failure 2001: booking bike $bikeID fails, bike not available";
|
||||
$response_text="Fahrrad Nr. $bikeID ist leider nicht verfügbar. U.U. ist die Fahrrad Flotte für Sie nicht freigeschaltet. Bitte überprüfen Sie Ihre Profildaten auf Vollständigkeit";
|
||||
}
|
||||
}
|
||||
$bw->log("response_state:$response_state\n","","");
|
||||
|
||||
if(ref($auth) eq "HASH"){
|
||||
$return = {
|
||||
bike => "$bikeID",
|
||||
state => "requested",
|
||||
response_state => "$response_state",
|
||||
response_text => "$response_text"
|
||||
};
|
||||
}else{
|
||||
if($response_state =~ /Failure/){
|
||||
$return = "failure::int01 $response_state";
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}#end net_booking
|
||||
|
||||
|
||||
#Send sms after payable check and !int13
|
||||
sub smsack(){
|
||||
my $self = shift;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue