mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 11:46:27 +01: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;
|
||||
|
|
|
@ -666,10 +666,11 @@ sub tpl(){
|
|||
}
|
||||
#print $q->end_form,"\n";
|
||||
|
||||
my $sum_bar="0";my $sum_ec="0";my $sum_kredit="0";my $sum_abb="0";my $sum_ueb="0";my $sum_geka="0";my $sum_paypal="0";my $sum_SEPApayone="0";my $sum_CCpayone="0";my $sum_ausfall="0";my $sum_kasse="0";my $sum_start="0";my $close_time="";my $payment_time="";my $sum_waren;my $sum_verkauf;my $sum_kaution;my $sum_am;my $sum_park; my $sum_radd;my $sum_wst_ek=0; my $sum_wst_vk=0; my $sum_verleih;
|
||||
my $sum_bar="0";my $sum_ec="0";my $sum_kredit="0";my $sum_abb="0";my $sum_ueb="0";my $sum_geka="0";my $sum_paypal="0";my $sum_SEPApayone="0";my $sum_CCpayone="0";my $sum_ausfall="0";my $sum_kasse="0";my $sum_start="0";my $close_time="";my $payment_time="";
|
||||
my $nr=0;my $nx=0;
|
||||
my $check_kaution=0;
|
||||
my $rabatt_key; my $kost_key;
|
||||
my $rabatt_key = "";
|
||||
my $kost_key = "";
|
||||
|
||||
#BIG LOOP loop content table
|
||||
foreach my $id (sort {
|
||||
|
@ -693,40 +694,27 @@ sub tpl(){
|
|||
my $sum_error = 0;
|
||||
my $ecol=0;
|
||||
|
||||
if($ct4rel->{$id}->{int01} > 0 && $ct4rel->{$id}->{int03} > 0){
|
||||
$sum_wst_ek += $ct4rel->{$id}->{int01} * $ct4rel->{$id}->{int03};
|
||||
}
|
||||
if($ct4rel->{$id}->{int02} > 0 && $ct4rel->{$id}->{int03} > 0){
|
||||
$sum_wst_vk += $ct4rel->{$id}->{int02} * $ct4rel->{$id}->{int03};
|
||||
}
|
||||
|
||||
# check sum_pos and sum_buchen
|
||||
my $sum_pos=0;
|
||||
my $sum_pos = 0;
|
||||
my $pricing = {};
|
||||
my $counting = {};
|
||||
if($ct4rel->{$id}->{state} ne "Kassenbestand"){
|
||||
foreach my $cpid (keys (%$ct4rel_parts)){
|
||||
if($ct4rel->{$id}->{c_id} eq $ct4rel_parts->{$cpid}->{ct_id}){
|
||||
if($ct4rel->{$id}->{c_id} == $ct4rel_parts->{$cpid}->{ct_id}){
|
||||
|
||||
if($ct4rel_parts->{$cpid}->{int35} && $ct4rel_parts->{$cpid}->{start_time} && $ct4rel_parts->{$cpid}->{end_time}){
|
||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$ct4rel_parts->{$cpid},"calc_price");
|
||||
$sum_pos += $pricing->{total_price}
|
||||
}elsif((looks_like_number($ct4rel_parts->{$cpid}->{int02}) && $ct4rel_parts->{$cpid}->{int02} != 0) && (looks_like_number($ct4rel_parts->{$cpid}->{int03}) && $ct4rel_parts->{$cpid}->{int03} != 0)){
|
||||
|
||||
if($ct4rel_parts->{$cpid}->{int07} != 0){
|
||||
my $rabatt_eur = $ct4rel_parts->{$cpid}->{int07};
|
||||
$rabatt_eur = $ct4rel_parts->{$cpid}->{int02} * $ct4rel_parts->{$cpid}->{int03} * $ct4rel_parts->{$cpid}->{int07}/100 if($ct4rel_parts->{$cpid}->{int08} != 1);#wenn int08 != 1 alias €
|
||||
#$rabatt_eur = $lb->round($rabatt_eur);
|
||||
$sum_pos += $ct4rel_parts->{$cpid}->{int02} * $ct4rel_parts->{$cpid}->{int03} - $rabatt_eur;
|
||||
}else{
|
||||
$sum_pos += $ct4rel_parts->{$cpid}->{int02} * $ct4rel_parts->{$cpid}->{int03};
|
||||
}
|
||||
my ($gesamt,$rabatt) = $pri->price2calc($ct4rel_parts->{$cpid});
|
||||
$sum_pos += $gesamt;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $sum_chk = $ct4rel->{$id}->{int01};
|
||||
$sum_pos = $lb->round($sum_pos);
|
||||
$sum_pos = $lb->cashme($sum_pos);
|
||||
my $sum_chkdiff = $sum_chk - $sum_pos;#wegen $rabatt_eur kleine Rundungsfehler zulassen.
|
||||
my $sum_chkdiff = $sum_chk - $sum_pos;
|
||||
if($ct4rel->{$id}->{int01} && ($sum_pos ne $sum_chk) && ($sum_chkdiff > 0.02 || $sum_chkdiff < -0.02)){
|
||||
$sum_error = "1";
|
||||
}
|
||||
|
@ -1143,13 +1131,6 @@ sub tpl(){
|
|||
}
|
||||
$sum_parts = $lb->round($sum_parts);
|
||||
$sum_parts = $lb->cashme($sum_parts);
|
||||
$sum_waren += $sum_parts;
|
||||
$sum_verkauf += $sum_parts if($ct4rel_parts->{$cpid}->{ct_name} ne "999");#999=Ausgaben, Fixme
|
||||
$ctf->{txt31} =~ s/,/|/;
|
||||
if($ct4rel->{$id}->{state} =~ /^Bar/ && $ct4rel_parts->{$cpid}->{int12} =~ /$ctf->{txt31}/){
|
||||
$sum_kaution += $sum_parts;
|
||||
$sum_bar -= $sum_parts;
|
||||
}
|
||||
|
||||
|
||||
my $parts_time = "";
|
||||
|
@ -1186,24 +1167,6 @@ sub tpl(){
|
|||
}#journal offen ende
|
||||
|
||||
|
||||
if($R::todo && $R::todo eq "Waren-Summe"){
|
||||
my $m = 9;
|
||||
$sum_wst_ek = $lb->round($sum_wst_ek);
|
||||
$sum_wst_vk = $lb->round($sum_wst_vk);
|
||||
$sum_wst_ek = $lb->cashme($sum_wst_ek,",");
|
||||
$sum_wst_vk = $lb->cashme($sum_wst_vk,",");
|
||||
print $q->Tr();
|
||||
print $q->td({-style=>"background-color:silver;"},""),"\n";
|
||||
print $q->td({-class=>'tdtxt',-style=>'text-align:center;background-color:silver;',-colspan=>"$m"},"");
|
||||
print $q->td({-class=>'tdsum',-colspan=>"2",-style=>'background-color:silver;'},"");
|
||||
print $q->Tr();
|
||||
print $q->td({-style=>"background-color:silver;"},""),"\n";
|
||||
#print $q->td({-class=>'tdsum',-colspan=>"$m"},$q->span({-style=>'color:silver;font-weight:normal;'},"(Vorsicht! incl. Ausgaben)"),$q->span("Waren-Stamm Summe"));
|
||||
print $q->td({-class=>'tdsum',-colspan=>"$m"},"Waren-Stamm Summe");
|
||||
print $q->td({-class=>'tdsum',-colspan=>"1",-nowrap=>"1"},"$sum_wst_ek €");
|
||||
print $q->td({-class=>'tdsum',-colspan=>"1",-nowrap=>"1"},"$sum_wst_vk €");
|
||||
}
|
||||
|
||||
#Kassenjournal alias Summe Bar und Kredit
|
||||
if(($nr > 0) && ($v_journal || $R::v_abschluss) && (!$R::rel_id) && ("$R::s_kontext" ne "Waren")){
|
||||
#if(($nr > 0) && ($v_journal || $R::v_abschluss || $close_time) && (!$R::rel_id)){
|
||||
|
@ -1232,10 +1195,6 @@ sub tpl(){
|
|||
$sum_ausfall = $lb->round($sum_ausfall);
|
||||
$sum_ausfall = $lb->cashme($sum_ausfall);
|
||||
|
||||
|
||||
$sum_waren = $lb->round($sum_waren);
|
||||
$sum_waren = $lb->cashme($sum_waren);
|
||||
$sum_kaution = $lb->cashme($sum_kaution);
|
||||
$sum_start = $lb->cashme($sum_start);
|
||||
$sum_kasse = $lb->cashme($sum_kasse);
|
||||
$close_time = $R::s_mtime if($R::s_mtime);
|
||||
|
|
|
@ -70,19 +70,12 @@ sub tpl(){
|
|||
my $vibuchen_mtime = "";
|
||||
$vibuchen_mtime = "Payone post " . $lb->time4de($ctt->{pay_time},1) . " . " if($ctt->{pay_time});
|
||||
|
||||
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int03=Menge","int02=Tarif/Preis","int07=Rabatt","int04=Gesamt");
|
||||
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
my $tplf = $db->get_tpl("201");#Firma tpl
|
||||
my @tplf_order = split /,/,$tplf->{tpl_order};
|
||||
|
||||
my $txt20 = $R::txt20 || $ctt->{txt20} || "";#Leistungsdatum
|
||||
my $int05 = $R::int05 || $ctt->{int05} || "";#manuell
|
||||
my $max_timestamp = "210001012359";
|
||||
if($ctf->{txt80} && $txt20 =~ /(\d{2})\.(\d{2})\.(\d{4})$/){
|
||||
$max_timestamp = $3 . $2 . $1 . "2359";
|
||||
}elsif($ctf->{txt80} =~ /(\d{2})\.(\d{2})\.(\d{4})$/){
|
||||
$max_timestamp = $3 . $2 . $1 . "2359";
|
||||
}
|
||||
my $max_sum = 1000;
|
||||
my $cttpos = { c_id => 0 };
|
||||
my $rows = 0;
|
||||
($cttpos,$rows) = $dbt->collect_contentpos($dbh,"contenttrans",$rel4tpl->{content_id});
|
||||
|
@ -90,7 +83,7 @@ sub tpl(){
|
|||
foreach my $id (keys(%$cttpos)){
|
||||
if(ref($cttpos->{$id}) eq "HASH"){
|
||||
if($cttpos->{$id}->{int26}){
|
||||
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int26=Einsparung","int03=Menge","int02=Tarif/Preis","int07=Rabatt","int04=Gesamt");
|
||||
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int26=Einsparung","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
}
|
||||
#enhanced tariff
|
||||
#if($cttpos->{$id}->{int35}){
|
||||
|
@ -165,7 +158,6 @@ EOF
|
|||
#my $scol = "c_id";#changed to itime because of Storno resorts
|
||||
my $scol = "itime";
|
||||
my $sum_parts19=0;
|
||||
#my $diff19 = 100 + $umst1619;
|
||||
my $diff19 = 100 + 19;
|
||||
my $sum_umst19=0;
|
||||
my $i=0;
|
||||
|
@ -175,12 +167,22 @@ EOF
|
|||
#foreach my $id (sort { $cttpos->{$b}->{$scol} <=> $cttpos->{$a}->{$scol} } keys(%$cttpos)){
|
||||
foreach my $id (sort { $cttpos->{$b}->{$scol} cmp $cttpos->{$a}->{$scol} } keys(%$cttpos)){
|
||||
|
||||
my $gesamt = 0;
|
||||
my $pricing = {};
|
||||
my $counting = {};
|
||||
my $rental_feed = {};
|
||||
|
||||
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);
|
||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos->{$id},"calc_price");
|
||||
$rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos->{$id},$counting);
|
||||
$sum_parts19 += $pricing->{total_price};
|
||||
$gesamt = $pri->round($pricing->{total_price});
|
||||
$gesamt = sprintf('%.2f', $gesamt);
|
||||
}else{
|
||||
($gesamt,my $rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
$sum_parts19 += $gesamt;
|
||||
$gesamt = $pri->round($gesamt);
|
||||
$gesamt = sprintf('%.2f', $gesamt);
|
||||
}
|
||||
|
||||
my $set_style="";
|
||||
|
@ -189,11 +191,9 @@ EOF
|
|||
#$occupied_style = "color:#ff1493" if($cttpos->{$id}->{txt10} =~ /occupied|requested|canceled/);
|
||||
$occupied_style = "color:#ff1493" if($cttpos->{$id}->{int10} == 2 ||$cttpos->{$id}->{int10} == 3 || $cttpos->{$id}->{int10} == 6);
|
||||
|
||||
my $cttpos_timestamp = $1 . $2 . $3 . "0000" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||||
#max. Rechnungspositionen
|
||||
if(($cttpos_timestamp <= $max_timestamp) && ($sum_parts19 <= $max_sum)){
|
||||
if(1==1){
|
||||
$i++;
|
||||
#print "$i (($id: $cttpos_timestamp <= $max_timestamp) && ($sum_parts19 <= $max_sum))<br>";
|
||||
if($i==1){
|
||||
$accounting_end = "$3.$2.$1" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||||
$accounting_end = "$3.$2.$1" if($cttpos->{$id}->{end_time} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||||
|
@ -209,13 +209,6 @@ EOF
|
|||
#$line_count2 += scalar(@line_txt01);
|
||||
}
|
||||
|
||||
my $gesamt = 0;
|
||||
my $rabatt = "";
|
||||
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
$sum_parts19 += $gesamt;
|
||||
$gesamt = $lb->round($gesamt);
|
||||
$gesamt = $lb->cashme($gesamt,",");
|
||||
|
||||
#1. Spalte
|
||||
print $q->Tr(),"\n";
|
||||
print "<td class='tdtxt' nowrap>";
|
||||
|
@ -273,7 +266,7 @@ EOF
|
|||
}elsif($key =~ /int02/){
|
||||
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
print "<td class='tdint'>\n";
|
||||
print "Tarif: $rental_feed->{tariff_description2}->{number} $rental_feed->{tariff_description2}->{name}<br />\n";
|
||||
#print "Tarif: $rental_feed->{tariff_description2}->{number} $rental_feed->{tariff_description2}->{name}<br />\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";
|
||||
|
@ -284,17 +277,9 @@ EOF
|
|||
print $q->td({-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),"\n");
|
||||
}
|
||||
}elsif($key =~ /int07/){
|
||||
if(!$cttpos->{$id}->{int35}){
|
||||
print $q->td({-class=>'element',-style=>"$txtstyle $set_style",-nowrap=>'1'},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),$but->selector("int08","40px","$cttpos->{$id}->{int08}",("0.00:%","1.00:€"))),"\n";
|
||||
}else{
|
||||
print $q->td({-class=>'tdint'},""),"\n";
|
||||
}
|
||||
print $q->td({-class=>'element',-style=>"$txtstyle $set_style",-nowrap=>'1'},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),$but->selector("int08","40px","$cttpos->{$id}->{int08}",("0.00:%","1.00:€"))),"\n";
|
||||
}elsif($key =~ /int04/){
|
||||
if($pricing->{total_price}){
|
||||
print $q->td({-class=>'tdint',-nowrap=>1},"$pricing->{total_price} €"),"\n";
|
||||
}else{
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$gesamt €");
|
||||
}
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$gesamt €");
|
||||
}elsif($key =~ /txt01/){
|
||||
if($cttpos->{$id}->{int09} && $cttpos->{$id}->{$key} !~ /Manuell/){
|
||||
$cttpos->{$id}->{$key} .= "\nManuell bearbeitet\n";
|
||||
|
@ -306,10 +291,11 @@ EOF
|
|||
print "<td class='element' style='$txtstyle $set_style;background-color: #ededed;$occupied_style;'\n>";
|
||||
print $q->textarea(-class=>'autos',-style=>"border: 1px solid #ededed;background-color: #ededed;",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-rows=>"1",-cols=>65),"<br />\n";
|
||||
|
||||
if($cttpos->{$id}->{int09}){#2020-12-07 Verleihräder werden anhand der TarifNr als solches erkannt
|
||||
#print $q->span({-style=>"$txtstyle $set_style"},
|
||||
#"Tarif Nr.: ", $q->textfield(-class=>'etxt',-name=>"int09",-default=>"$cttpos->{$id}->{int09}",-size=>"5",-maxlength=>5),
|
||||
#"Tarif Text", $q->textfield(-class=>'etxt',-name=>"txt04",-default=>"$cttpos->{$id}->{txt04}",-size=>"30",-maxlength=>50)),"<br />\n";
|
||||
#if Traiff Nr.
|
||||
if($cttpos->{$id}->{int09}){
|
||||
print $q->span({-style=>"$txtstyle $set_style"},
|
||||
"Tarif Nr.: ", $q->textfield(-class=>'etxt',-name=>"int09",-default=>"$cttpos->{$id}->{int09}",-size=>"5",-maxlength=>5),
|
||||
"Tarif Text", $q->textfield(-class=>'etxt',-name=>"txt04",-default=>"$cttpos->{$id}->{txt04}",-size=>"30",-maxlength=>50)),"<br />\n";
|
||||
|
||||
print $q->span({-style=>"$txtstyle $set_style"},
|
||||
"Endstation: ", $q->textfield(-class=>'etxt',-name=>"int04",-default=>"$cttpos->{$id}->{int04}",-size=>"5",-maxlength=>40),
|
||||
|
@ -371,7 +357,6 @@ EOF
|
|||
}elsif($key =~ /int02/){
|
||||
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
print "<td class='tdint'>\n";
|
||||
print "Tarif: $rental_feed->{tariff_description2}->{number} $rental_feed->{tariff_description2}->{name}<br />\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";
|
||||
|
@ -383,21 +368,14 @@ EOF
|
|||
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key} €"),"\n";
|
||||
}
|
||||
}elsif($key =~ /int04/){
|
||||
if($pricing->{total_price}){
|
||||
print $q->td({-class=>'tdint',-nowrap=>1},"$pricing->{total_price} €"),"\n";
|
||||
}else{
|
||||
$gesamt =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint',-nowrap=>1},"$gesamt €"),"\n";
|
||||
}
|
||||
$gesamt =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint',-nowrap=>1},"$gesamt €"),"\n";
|
||||
}elsif($key =~ /int07/){
|
||||
if(!$cttpos->{$id}->{int35}){
|
||||
my $proz="";
|
||||
$proz = "%" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0);
|
||||
$proz = "€" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0 && $cttpos->{$id}->{int08} && $cttpos->{$id}->{int08} == 1);
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$cttpos->{$id}->{$key} $proz"),"\n";
|
||||
}else{
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},""),"\n";
|
||||
}
|
||||
my $proz="";
|
||||
$proz = "%" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0);
|
||||
$proz = "€" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0 && $cttpos->{$id}->{int08} && $cttpos->{$id}->{int08} == 1);
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$cttpos->{$id}->{$key} $proz"),"\n";
|
||||
}elsif($key =~ /txt01/){
|
||||
$cttpos->{$id}->{$key} = $q->unescapeHTML("$cttpos->{$id}->{$key}");
|
||||
$cttpos->{$id}->{$key} = $lb->newline($cttpos->{$id}->{$key},"","");
|
||||
|
@ -419,16 +397,16 @@ EOF
|
|||
}
|
||||
if($cttpos->{$id}->{itime} =~ /(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2})/){
|
||||
print $q->span("$dbt->{copri_conf}->{bike_state}->{$cttpos->{$id}->{int10}} → $dbt->{copri_conf}->{lock_state}->{$cttpos->{$id}->{int20}} → $u_name / $u_name_end"),"\n";
|
||||
my $pos_id = "";
|
||||
my $pos_raw = "";
|
||||
if($users_dms->{u_id} && $users_dms->{u_id} =~ /1842/){
|
||||
my $pos_details = "";
|
||||
foreach my $did (sort keys (%{$pricing->{rentalog}})){
|
||||
$pos_details .= $did . " = " . $pricing->{rentalog}->{$did} . "</br>" if($pricing->{rentalog}->{$did});
|
||||
}
|
||||
#$pos_details = Dumper($pricing->{rentalog});
|
||||
$pos_id = $q->div({-class=>"popup",-onclick=>"toggle_box('$id')"},"$cttpos->{$id}->{c_id}", $q->span({-class=>"popuptext",-id=>"$id"},"$pos_details"));
|
||||
$pos_raw = $q->div({-class=>"popup",-onclick=>"toggle_box('$id')"},"$cttpos->{$id}->{c_id}", $q->span({-class=>"popuptext",-id=>"$id"},"$pos_details"));
|
||||
}
|
||||
print "$pos_id<br />\n";
|
||||
print "(raw $pos_raw)<br />\n";
|
||||
}
|
||||
}
|
||||
if($cttpos->{$id}->{txt01} || $cttpos->{$id}->{int09}){
|
||||
|
@ -438,9 +416,8 @@ EOF
|
|||
my $bike="";
|
||||
my $tariff = "";
|
||||
$bike = "$cttpos->{$id}->{$key}" if($cttpos->{$id}->{$key});
|
||||
#$tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
|
||||
#print $q->span("$bike $tariff<br />"),"\n";
|
||||
print $q->span("$bike<br />"),"\n";
|
||||
$tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
|
||||
print $q->span("$bike $tariff<br />"),"\n";
|
||||
}
|
||||
if($cttpos->{$id}->{int06} || $cttpos->{$id}->{int04}){
|
||||
print $q->span("Start/End Station: $cttpos->{$id}->{int06} / $cttpos->{$id}->{int04}, GPS: $cttpos->{$id}->{txt06}"),"\n";
|
||||
|
@ -464,22 +441,22 @@ EOF
|
|||
}#foreach end
|
||||
|
||||
if($sum_parts19 && $sum_parts19 != 0){
|
||||
#$sum_umst19 = $sum_parts19 / $diff19 * $umst1619;
|
||||
$sum_umst19 = $sum_parts19 / $diff19 * 19;
|
||||
$sum_umst19 = $lb->round($sum_umst19);
|
||||
$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->round($sum_nettoall);
|
||||
$sum_nettoall = $lb->cashme($sum_nettoall,",");
|
||||
$sum_netto19 = sprintf('%.2f', $sum_netto19);
|
||||
$sum_netto19 =~ s/\./,/;
|
||||
|
||||
my $sum_paid = $sum_parts19;
|
||||
$sum_paid = $lb->round($sum_paid);
|
||||
$sum_paid = $pri->round($sum_paid);
|
||||
my $sum_preauth = $sum_paid || 0;
|
||||
$sum_parts19 = $lb->cashme($sum_parts19,",");
|
||||
$sum_umst19 = $lb->round($sum_umst19);
|
||||
$sum_umst19 = $lb->cashme($sum_umst19,",");
|
||||
$sum_paid = $lb->cashme($sum_paid,",");
|
||||
$sum_paid = sprintf('%.2f', $sum_paid);
|
||||
$sum_paid =~ s/\./,/;
|
||||
|
||||
$sum_parts19 = sprintf('%.2f', $sum_parts19);
|
||||
$sum_umst19 = sprintf('%.2f', $sum_umst19);
|
||||
$sum_umst19 =~ s/\./,/;
|
||||
|
||||
my $payment_text = "";
|
||||
foreach(@tplf_order){
|
||||
|
@ -512,7 +489,7 @@ EOF
|
|||
if($node_meta->{node_name} !~ /steuerfrei/){
|
||||
print $q->Tr("\n"); $line_count2++;
|
||||
print $q->td({-class=>'tdint'},"Nettobetrag:");
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_nettoall €");
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_netto19 €");
|
||||
|
||||
if($sum_netto19 != 0){
|
||||
print $q->Tr("\n");$line_count2++;
|
||||
|
|
|
@ -404,6 +404,10 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
|
|||
print $q->td({-class=>'tdint', -style=>"$occupied_style", -nowrap=>1},"$co2saving");
|
||||
}elsif($key eq "int02"){
|
||||
if($pricing->{total_price}){
|
||||
$sum += $pricing->{total_price};
|
||||
$pricing->{total_price} = $lb->round($pricing->{total_price});
|
||||
$pricing->{total_price} = sprintf('%.2f', $pricing->{total_price});
|
||||
$pricing->{total_price} =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint', -style=>"$occupied_style", -nowrap=>1},"$pricing->{total_price} €"),"\n";
|
||||
}else{
|
||||
my $gesamt = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue