From 43dbaba064fbe72afb9ba8cbb2a21cc30b1a16a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rainer=20G=C3=BCmpelein?= Date: Mon, 14 Feb 2022 16:06:02 +0100 Subject: [PATCH] payone_cron refacoring --- copri4/main/src/Mod/APIjsonserver.pm | 26 +- copri4/main/src/Mod/Libenz.pm | 27 +- copri4/main/src/Mod/Payment.pm | 80 ++---- copri4/main/src/Mod/Prelogic.pm | 80 +----- copri4/main/src/Tpl/TransPositionen.pm | 33 +-- copri4/main/src/scripts/payone_cron.pl | 245 +----------------- .../main/src/scripts/payone_operatorsloop.pl | 35 --- .../main/src/scripts/payone_post_Payment.pl | 97 ------- 8 files changed, 50 insertions(+), 573 deletions(-) mode change 100755 => 120000 copri4/main/src/scripts/payone_cron.pl delete mode 100755 copri4/main/src/scripts/payone_operatorsloop.pl delete mode 100755 copri4/main/src/scripts/payone_post_Payment.pl diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index 7be687f..e2ce2e5 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -143,8 +143,8 @@ if($q->param('request') eq "auth_verify"){ if(ref($auth) eq "HASH" && $auth->{authcookie}){ $response = { %$response, %$auth }; }else{ - $response->{response_state} = "Failure: cannote match authcookie"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_state} = "Failure 1001: authcookie not defined"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } } @@ -162,7 +162,7 @@ elsif($q->param('request') eq "authout"){ $response->{response_text} = "Auf Wiedersehen."; }else{ $response->{response_state} = "Failure 1001: authcookie not defined"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } } #authorization @@ -258,8 +258,8 @@ elsif($q->param('request') eq "booking_request"){ $response->{timeCode} = 0;#if fails } }else{ - $response->{response_state} = "Failure 1002: authcookie not defined"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_state} = "Failure 1001: authcookie not defined"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } } @@ -361,7 +361,7 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki } }else{ $response->{response_state} = "Failure 1001: authcookie not defined"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } } @@ -379,7 +379,7 @@ elsif($q->param('request') eq "user_rentals_history"){ $response->{rentals} = $apif->rentals($record,$authraw,"0"); }else{ $response->{response_state} = "Failure 1001: authcookie not defined"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } } @@ -395,8 +395,8 @@ elsif($q->param('request') eq "user_bikes_occupied"){ $response = { %$response, %$auth }; ($response->{bikes_occupied},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$authraw,$return_merchant); }else{ - $response->{response_state} = "Failure 1001: authcookie on primary not defined"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_state} = "Failure 1001: authcookie not defined"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } }else{ @@ -407,8 +407,8 @@ elsif($q->param('request') eq "user_bikes_occupied"){ my $record = $apif->user_bikes_occupied($q,$authraw); $response->{bikes_occupied} = $apif->rentals($record,$authraw,"1"); }else{ - $response->{response_state} = "Failure 1001: authcookie on operator not defined"; - $response->{response_text} = "Entschuldigung, die Session wurde unterbrochen"; + $response->{response_state} = "Failure 1001: authcookie not defined"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; } } @@ -623,8 +623,8 @@ elsif($q->param('request') eq "stations_available"){ my ($auth,$authraw) = $apif->auth_verify($q); #Mein konrad App - #if($dbt->{merchant_ids}->{$varenv{merchant_id}}->{id} eq "176"){ - #if($aowner && $aowner eq "176"){ + #if($dbt->{merchant_ids}->{$varenv{merchant_id}}->{id} eq "176") + #if($aowner && $aowner eq "176") #$response->{merchant_message} = "Herzlich Willkommen bei der neuen konrad App! Die App ist zwar schon installierbar, bis zur vollständigen Umstellung des Systems sind aber noch keine Räder ausleihbar. Das ist erst voraussichtlich Ende Januar der Fall und wird den Nutzern noch mitgeteilt. Danke für Ihr Verständnis! Ihr konrad-Team"; #} $response = { %$response, %$auth }; diff --git a/copri4/main/src/Mod/Libenz.pm b/copri4/main/src/Mod/Libenz.pm index b532bdb..5294605 100755 --- a/copri4/main/src/Mod/Libenz.pm +++ b/copri4/main/src/Mod/Libenz.pm @@ -351,7 +351,7 @@ sub barcodeable(){ return ($ct_name,$barcode); } -#FIXME or change to barcode=c_id +#TODO or change to barcode=c_id #get free barcode sub get_freenr(){ my $self = shift; @@ -367,31 +367,6 @@ sub get_freenr(){ } } -#get free Rechnungs Nummer -sub get_freeReNr(){ - my $self = shift; - my ($table,$barcode_start,$barcode_end,$column,$content) = @_; - my $now_time = strftime "%Y-%m-%d %H:%M:%S", localtime; - my $freenr = $db->collect_content3("$table","$column","$content"); - my $s_id = $barcode_start; - my $e_id = $barcode_end || 100000; - $freenr->{$s_id}->{barcode} = "1000" if(!$freenr->{$s_id}->{barcode}); - for (; $s_id < $e_id; $s_id++){ - #if($freenr->{$s_id}->{barcode} != $s_id){ - if($freenr->{$s_id}->{ct_name} && $freenr->{$s_id}->{ct_name} !~ /^$s_id/){ - open(RENR, ">> $varenv{logdir}/get_freeReNr.log"); - print RENR "* $now_time --------------- \n"; - print RENR "$table,$barcode_start,$barcode_end,$column,$content\n"; - print RENR "for (; $s_id < $e_id; $s_id++){\n"; - print RENR "if($freenr->{$s_id}->{ct_name} && $freenr->{$s_id}->{ct_name} !~ /^$s_id/){\n"; - print RENR "return $s_id;\n"; - close RENR; - return $s_id; - } - } - return 0; -} - #CAsh sub cashme(){ my $self = shift; diff --git a/copri4/main/src/Mod/Payment.pm b/copri4/main/src/Mod/Payment.pm index 46a2660..ed7cbf3 100755 --- a/copri4/main/src/Mod/Payment.pm +++ b/copri4/main/src/Mod/Payment.pm @@ -7,7 +7,7 @@ package Payment; #Adapted from payone_post.pl # #enable for syntax check -#use lib "/var/www/copri4/shareedms-primary/src"; +#use lib "/var/www/copri-bike/shareedms-primary/src"; use strict; use warnings; @@ -543,7 +543,7 @@ sub pdfmandat { my $ctadr = $dbt->fetch_record($dbh,$authref); my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; - open(EMA, ">> $varenv->{logdir}/SEPA-PDFprint.log"); + open(EMA, ">> $varenv->{logdir}/copri-print.log"); print EMA "*** $now_dt trying pdf --> $varenv->{basedir}/pdfinvoice/SEPA-Lastschriftmandat-$varenv->{dbname}-$ctadr->{ct_name}.pdf && $ctadr->{txt27}\n"; #if((! -f "$varenv->{basedir}/pdfinvoice/SEPA-Lastschriftmandat-$varenv->{dbname}-$ctadr->{ct_name}.pdf") && $ctadr->{txt27} && $ctadr->{txt27} =~ /active|pending/){ if($ctadr->{txt27} && $ctadr->{txt27} =~ /active|pending/){ @@ -571,44 +571,26 @@ sub payone_capture(){ my $lang = "de"; my $mandant_id = 100002; - my $main_id = 300008;#Rechnung - my $today4db = strftime("%Y-%m-%d %H:%M:%S",localtime(time)); - my $retval = {}; - my $return_text = "\n"; + #my $main_id = 300008;#Rechnung + my $main_id = $ctt->{main_id}; + my $retval = ""; + my $return_text = ""; my $dbh = ""; #Node and HoleCkeck depended auto Rechnungs-Nummer my $node = $db->get_node4multi($main_id,$lang);#Rechnung node if($node->{int06} > 0){ if($ctt->{ct_name} !~ /\d/){ - #HoleCheck if ReNr available before ReNr counter - my $ReNr_start = 40000; - my $freeNr = $lb->get_freeReNr("contenttrans","$ReNr_start","$node->{int06}","txt00","$node->{node_name}"); my $nextNr = $node->{int06}; - $nextNr = $freeNr if($freeNr && $freeNr < $node->{int06}); $db->update_content4change("contenttrans",$ctt->{c_id},$nextNr,$nextNr,"barcode"); - if(!$freeNr){ - my $int06 = $node->{int06} + 1; - $db->updater("nodes","main_id",$main_id,"int06",$int06,"","","","","no_time"); - } + my $int06 = $node->{int06} + 1; + $db->updater("nodes","main_id",$main_id,"int06",$int06,"","","","","no_time"); } }else{ - $return_text = "---> payone_cron Payment.pm exit, $node->{int06} | $ctt->{ct_name} can not generate invoice number\n"; + $return_text = "payone_cron Payment.pm exit, $node->{int06} | $ctt->{ct_name} can not generate invoice number\n"; return $return_text; } - #We do it only if txt80 end_time in Firma is defined - my $max_timestamp; - if($ctf->{txt80} && $ctt->{txt20}){ - if($ctt->{txt20} =~ /(\d{2})\.(\d{2})\.(\d{4})$/){ - $max_timestamp = "$1.$2.$3 23:59"; - }else{ - $return_text = "---> Payment.pm max_timestamp: $max_timestamp fails and exit\n"; - return $return_text; - } - } - - my $state = $ctt->{state}; if($varenv->{Zahlungsweise}){ my @_paymentstate = split(/\|/,$varenv->{Zahlungsweise}); @@ -631,18 +613,16 @@ sub payone_capture(){ #in cron we set OPOS anyway. If payone captured, it will be set int14=null if(!$state || $state !~ /payone/){ $db->updater("contenttrans","c_id",$ctt->{c_id},"txt22","cronjob fail","","","","",""); - $return_text = "---> Payment.pm can not preauthorization because of absent payment-data in ctadr.c_id:$ctadr->{c_id}, SEPA/CC:$ctadr->{int03}, $ctadr->{ct_name}, we exit\n"; + $return_text = "Payment.pm can not preauthorization because of absent payment-data in ctadr.c_id:$ctadr->{c_id}, SEPA/CC:$ctadr->{int03}, $ctadr->{ct_name}, we exit\n"; return $return_text; } #preauth if($ctadr->{int03} && $ctadr->{int03} == 1 && $ctadr->{ct_name} && $ctadr->{ct_name} =~ /\w{2}-\d+/ && (!$ctt->{txt16} || $ctt->{int03} ne "1")){ - $return_text .= "---> trying payone preauthorizationSEPA\n"; $self->preauthorizationSEPA_main($varenv,$ctadr,$ctt,$owner); sleep 2; }elsif($ctadr->{int03} && $ctadr->{int03} == 2 && $ctadr->{ct_name} && length($ctadr->{ct_name}) >= 19 && (!$ctt->{txt16} || $ctt->{int03} ne "2")){ - $return_text .= "---> trying payone preauthorizationCC\n"; $self->preauthorizationCC_main($varenv,$ctadr,$ctt,$owner); sleep 2; } @@ -652,47 +632,35 @@ sub payone_capture(){ #SEPA capture if($ctt->{int03} == 1 && $ctt->{txt16} && $ctt->{state} =~ /SEPA/){#SEPA - $return_text .= "---> trying payone captureSEPA\n"; $self->captureSEPA_main($varenv,$ctadr,$ctt,$owner); } #CC capture - if($ctt->{int03} == 2 && $ctt->{txt16} && $ctt->{state} =~ /Kreditkarte/){#CC - $return_text .= "---> trying payone captureCC\n"; + elsif($ctt->{int03} == 2 && $ctt->{txt16} && $ctt->{state} =~ /Kreditkarte/){#CC $self->captureCC_main($varenv,$ctadr,$ctt,$owner); } - - #Rechnungspositionen itime > end Abrechnunsgdatum --> results in generating new Invoice - if($max_timestamp && $varenv->{wwwhost} =~ /tink/){ - my $ctpos_ck = $db->get_content7("contenttranspos","ct_id",$ctt->{c_id},"itime",">","$max_timestamp"); - if($ctpos_ck->{c_id}){ - my $ctadr = $db->get_content7("contentadr","c_id",$ctadr->{c_id}); - my $ct_id = $dbt->insert_contenttrans($dbh,$ctadr,"300008","218","----",$owner); - $db->updater("contenttrans","c_id",$ct_id,"start_time","$ctt->{start_time}",$owner); - $db->updater("contenttrans","c_id",$ct_id,"end_time","$ctt->{end_time}",$owner); - - $db->updater("contenttranspos","ct_id",$ctt->{c_id},"ct_id",$ct_id,"","itime",">","$max_timestamp","no_time"); - } + else{ + $return_text = "Payment.pm can not get TXID\n"; } #wkhtml - #TODO to sharee if(1==1){ - my $praefix = "$ctt->{txt00}-TINK"; + my $praefix = "$ctt->{txt00}-$varenv->{praefix}";#like Rechnung-sharee_operator my $wc_line= $ctt->{int04};#Adresse.Tabelle my $topdf = "$varenv->{basedir}/src/wkhtmltopdf-amd64"; my $print_return = `$topdf --page-size A4 "$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf 2>&1`; - $return_text .= "$topdf --page-size A4 \"$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line\" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\n"; - #FIXME to new mailTarnsport + my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; + open(EMA, ">> $varenv->{logdir}/copri-print.log"); + print EMA "$now_dt\n$topdf --page-size A4 \"$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&wc=$wc_line\" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\n"; + #send_invoice infomail - #if(-f "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf"){ - # system(`$varenv->{basedir}/src/Mod/newsletter_tink.pl "$varenv->{basedir}" "$varenv->{wwwhost}" "send_invoice" "$ctadr->{c_id}" "$ctt->{ct_name}"`); - # $return_text .= "---> Sent Invoice Info e-mail\n"; - #} - + if(-f "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf"){ + system(`$varenv->{basedir}/src/scripts/mailTransport.pl "$varenv->{syshost}" "send_invoice" "$ctt->{c_id}" "$praefix-$ctt->{ct_name}.pdf"`); + print EMA "---> Sent Invoice Info e-mail\n"; + } + close EMA; } - #TODO - #$retval = $db->get_content1("contenttrans",$ctt->{c_id}); + return ($retval,$return_text); } diff --git a/copri4/main/src/Mod/Prelogic.pm b/copri4/main/src/Mod/Prelogic.pm index cc97867..983bf5a 100755 --- a/copri4/main/src/Mod/Prelogic.pm +++ b/copri4/main/src/Mod/Prelogic.pm @@ -99,7 +99,6 @@ sub preinit(){ my ($ct_last,$c_idnew); my $table = "contenttrans"; - $table = "contenttver" if($users_dms->{kind_of_trans} =~ /Veranstaltung|Proje/); my $ctt = $db->get_content1($table,$users_dms->{c_id4trans}); my $buchen_mtime = $lb->time4de($ctt->{mtime}); @@ -167,45 +166,10 @@ sub preinit(){ $table = "contenttrans"; $foreign_key="ct_id"; $main_id = $parent_trans->{main_id} if(!$R::main_id); - }elsif($ib_key =~ /new_tver/){ - $table = "contenttver"; - $foreign_key="cv_id"; - $main_id = $parent_trans->{main_id} if(!$R::main_id); } my $node = $db->get_node4multi($main_id,$lang); - #new content for all sub_nodes - if($varenv{dataflow} =~ /wiki/ && $table && $main_id){ - my $main_id2 = $main_id; - $main_id2 = $node->{parent_id} if($main_id >= 300000); - my ($dd1,$mo1,$yy1) = split(/\./,$R::s_start_date_time); - my $dt1 = $yy1 . $mo1 . $dd1; - my ($dd2,$mo2,$yy2) = split(/\./,$today); - my $dt2 = $yy2 . $mo2 . $dd2; - if($R::s_start_date_time && ($dt1 > $dt2)){ - return "failure::Der Vorgang wurde abgebrochen. Das anlegen von Datensätzen in die Zukunft ist nicht vorgesehen da problematisch Aufgrund der Übernahme der Inhalte aus \"Vereinbarungen\". ($R::s_start_date_time > $today alias $dt1 > $dt2)"; - } - my $start_time = $R::s_start_date_time || $today; - my $sub_nodes = $db->collect_node($main_id2,$lang,$users_dms->{u_id}); - #only sub-nodes 300000 - foreach my $id (sort { lc($sub_nodes->{$a}->{node_name}) cmp lc($sub_nodes->{$b}->{node_name}) } (keys (%$sub_nodes))){ - #print "$sub_nodes->{$id}->{main_id}|"; - my $ctrel; - $ctrel = $db->get_ctrel2($table,"",$sub_nodes->{$id}->{main_id},$lang,"","",$R::template_id,"start_time","$start_time","="); - if(!$ctrel->{c_id} && $sub_nodes->{$id}->{main_id} > 300000){ - $c_idnew = $db->insert_content($table,$ct_name,$users_dms->{u_id},$sort); - $i_rows += 1 if($c_idnew > 0); - $db->updater("$table","c_id",$c_idnew,"ct_name","$c_idnew"); - $db->updater("$table","c_id",$c_idnew,"start_time","$start_time"); - my $ctrel_desc = $db->get_ctrel2($table,"",$sub_nodes->{$id}->{main_id},$lang,"","",$R::template_id,"","","","start_time","DESC");#copy Vereinbarung und Wissenswertes - $db->updater("$table","c_id",$c_idnew,"txt00","$ctrel_desc->{txt00}"); - #$db->updater("$table","c_id",$c_idnew,"txt01","$ctrel_desc->{txt01}");#don't copy - my $rel_id = $db->insert_relationlist($table,$sub_nodes->{$id}->{main_id},$lang,$c_idnew,$R::template_id,$foreign_key); - } - } - print redirect("$varenv{wwwhost}$script$path?detail_search=1\&s_start_date_time=$start_time\&s_end_date_time=$start_time\&return=$i_rows-$u_rows-$d_rows"); - exit 0; - }elsif($table && $main_id && $R::kind_of_trans){ + if($table && $main_id){ my $rel = $db->get_rel4tpl($main_id,$lang); $c_idnew = $db->insert_content2($table,$ct_name,$users_dms->{u_id},""); $i_rows += 1 if($c_idnew > 0); @@ -223,7 +187,7 @@ sub preinit(){ $db->update_content4change($table,$c_idnew,"","txt61,txt63","txt21") if($R::kind_of_trans =~ /Faktur|Verleih/);#Text-3 } }else{ - return "failure::Fehler, Datensatz kann nicht angelegt werden weil folgende Informationen fehlen: ($main_id && $R::kind_of_trans)"; + return "failure::Fehler, Datensatz kann nicht angelegt werden weil folgende Informationen fehlen: ($main_id)"; } } @@ -800,17 +764,10 @@ sub preinit(){ #Node and HoleCkeck depended auto Rechnungs-Nummer if(($node->{int06} > 0) && ("$ctt->{ct_name}" !~ /\d/ || "$R::set_main_id" != "$rel->{main_id}")){ - #HoleCheck if ReNr available before ReNr counter - my $ReNr_start = 40000; - my $freeNr = $lb->get_freeReNr("$table","$ReNr_start","$node->{int06}","txt00","$node->{node_name}"); my $nextNr = $node->{int06}; - $nextNr = $freeNr if($freeNr && $freeNr < $node->{int06}); - - $u_rows += $db->update_content4change($table,$c_id,$nextNr,$nextNr,"barcode"); - if(!$freeNr){ - my $int06 = $node->{int06} + 1; - $u_rows += $db->updater("nodes","main_id",$R::set_main_id,"int06",$int06,"","","","","no_time"); - } + $u_rows += $db->update_content4change($table,$c_id,$nextNr,$nextNr,"barcode"); + my $int06 = $node->{int06} + 1; + $u_rows += $db->updater("nodes","main_id",$R::set_main_id,"int06",$int06,"","","","","no_time"); }elsif($ctt->{ct_name} !~ /\d/){ @@ -891,16 +848,6 @@ sub preinit(){ $sum_kaution =~ s/,/\./; } - #We do it only if txt80 end_time in Firma is defined - my $max_timestamp; - if($ctf->{txt80} && $ctt->{txt20}){ - if($ctt->{txt20} =~ /(\d{2})\.(\d{2})\.(\d{4})$/){ - $max_timestamp = "$1.$2.$3 23:59"; - }else{ - return "failure::Abbruch, das Leistungsdatum muss als einfaches Datum (Bsp: 31.08.2016) oder als Zeitraum wie im folgenden Beispiel definiert sein: 01.08.2016 - 31.08.2016\n"; - } - } - $u_rows += $db->update_content4change($table,$c_id,"","$sum_paid","int01"); $db->update_content4change($table,$c_id,"",$state,"state"); $db->update_content4change($table,$c_id,"","now()","mtime"); @@ -933,19 +880,6 @@ sub preinit(){ }else{ $db->updater($table,"c_id","$c_id","int14","null","","","","",""); } - - #Rechnungspositionen itime > end Abrechnunsgdatum - if($max_timestamp){ - my $ctpos_ck = $db->get_content7("contenttranspos","ct_id","$c_id","itime",">","$max_timestamp"); - if($ctpos_ck->{c_id}){ - my $ctadr = $db->get_content7("contentadr","c_id",$ctt->{int10}); - my $ct_id = $dbt->insert_contenttrans($dbh,$ctadr,"300008","218","----",$users_dms->{u_id}); - $db->updater($table,"c_id",$ct_id,"start_time","$ctt->{start_time}",$users_dms->{u_id}); - $db->updater($table,"c_id",$ct_id,"end_time","$ctt->{end_time}",$users_dms->{u_id}); - - $i_rows = $db->updater("contenttranspos","ct_id","$c_id","ct_id","$ct_id","","itime",">","$max_timestamp","no_time"); - } - } } } @@ -954,11 +888,9 @@ sub preinit(){ my $c_id4print = $users_dms->{c_id4trans}; $c_id4print= $R::c_id if($R::printer_id =~ /Adresse|Kunde/); if($c_id4print){ - my $print_return; + my $print_return = ""; my $exit_code = 1; my $table = "contenttrans"; - $table = "contenttver" if($rel->{ct_table} eq "contenttver"); - $table = "contentadr" if($R::printer_id =~ /Adresse|Kunde/);#jbw my $ctt = $db->get_content1($table,$c_id4print); my $praefix = "$ctt->{txt00}-$varenv{praefix}";#like Rechnung-sharee_operator diff --git a/copri4/main/src/Tpl/TransPositionen.pm b/copri4/main/src/Tpl/TransPositionen.pm index edd1a29..41fc924 100755 --- a/copri4/main/src/Tpl/TransPositionen.pm +++ b/copri4/main/src/Tpl/TransPositionen.pm @@ -81,7 +81,7 @@ sub tpl(){ }elsif($ctf->{txt80} =~ /(\d{2})\.(\d{2})\.(\d{4})$/){ $max_timestamp = $3 . $2 . $1 . "2359"; } - my $max_sum = $ctf->{int03} || "10000"; + my $max_sum = 1000; my $cttpos = { c_id => 0 }; my $rows = 0; ($cttpos,$rows) = $db->collect_contentpos("contenttrans",$rel4tpl->{content_id}); @@ -156,13 +156,9 @@ EOF #Tablecontent (buttons and ct_name(primary key)) #my $scol = "c_id";#changed to itime because of Storno resorts my $scol = "itime"; - my $sum_parts0=0; - my $sum_parts7=0; my $sum_parts19=0; - my $diff7 = 100 + 7; #my $diff19 = 100 + $umst1619; my $diff19 = 100 + 19; - my $sum_umst7=0; my $sum_umst19=0; my $i=0; my $accounting_start; @@ -388,29 +384,20 @@ EOF } }#foreach end - if($sum_parts7 != "0"){ - $sum_umst7 = $sum_parts7 / $diff7 * 7; - $sum_umst7 = $lb->round($sum_umst7); - } - if($sum_parts19 != "0"){ + if($sum_parts19 && $sum_parts19 != 0){ #$sum_umst19 = $sum_parts19 / $diff19 * $umst1619; $sum_umst19 = $sum_parts19 / $diff19 * 19; $sum_umst19 = $lb->round($sum_umst19); } - my $sum_netto7 = $sum_parts7 - $sum_umst7; my $sum_netto19 = $sum_parts19 - $sum_umst19; - $sum_netto7 = $lb->cashme($sum_netto7); $sum_netto19 = $lb->cashme($sum_netto19); - my $sum_nettoall = $sum_parts0 + $sum_netto7 + $sum_netto19; + my $sum_nettoall = $sum_netto19; $sum_nettoall = $lb->round($sum_nettoall); $sum_nettoall = $lb->cashme($sum_nettoall,","); - my $sum_paid = $sum_parts0 + $sum_parts7 + $sum_parts19; + my $sum_paid = $sum_parts19; $sum_paid = $lb->round($sum_paid); my $sum_preauth = $sum_paid || 0; - $sum_parts0 = $lb->cashme($sum_parts0,","); - $sum_parts7 = $lb->cashme($sum_parts7,","); $sum_parts19 = $lb->cashme($sum_parts19,","); - $sum_umst7 = $lb->cashme($sum_umst7,","); $sum_umst19 = $lb->round($sum_umst19); $sum_umst19 = $lb->cashme($sum_umst19,","); $sum_paid = $lb->cashme($sum_paid,","); @@ -448,17 +435,7 @@ EOF print $q->td({-class=>'tdint'},"Nettobetrag:"); print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_nettoall €"); - if($sum_parts0 != "0"){ - print $q->Tr("\n");$line_count2++; - print $q->td({-class=>'tdint',-nowrap=>"1"},"0% UmSt auf $sum_parts0 €:"); - print $q->td({-class=>'tdint',-nowrap=>"1"},"0,00 €"); - } - if($sum_netto7 != "0"){ - print $q->Tr("\n");$line_count2++; - print $q->td({-class=>'tdint',-nowrap=>"1"},"7% UmSt auf $sum_netto7 €:"); - print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst7 €"); - } - if($sum_netto19 != "0"){ + if($sum_netto19 != 0){ print $q->Tr("\n");$line_count2++; #print $q->td({-class=>'tdint',-nowrap=>"1"},"$umst1619% UmSt auf $sum_netto19 €:"); print $q->td({-class=>'tdint',-nowrap=>"1"},"19% UmSt auf $sum_netto19 €:"); diff --git a/copri4/main/src/scripts/payone_cron.pl b/copri4/main/src/scripts/payone_cron.pl deleted file mode 100755 index f0aa097..0000000 --- a/copri4/main/src/scripts/payone_cron.pl +++ /dev/null @@ -1,244 +0,0 @@ -#!/usr/bin/perl -# -# -# SPDX-License-Identifier: AGPL-3.0-or-later -# Copyright (c) Rainer Gümpelein, TeilRad GmbH -# -#Capture payone payment by cron -# - #> 1. auto-fixed RadBuchungen (bei service-fixed hat schon jemand die Buchung manuell bearbeitet, oder?) - #--> service fixed wird gesetzt wenn das Rad via COPRI terminiert wurde. D.h. das hat keine Aussage ob auch der RadBuchungs Datensatz bearbeitet wurde. Deshalb gilt hier die userid des Datensatz Bearbeiters als key ob Automatik angewandt werden kann.-->ok - #> 2. mit defect -->ok - #> 3. RadBuchungen länger als 1 Tag oder bei konrad > 9,- € und bei TINK > 15,- € -->ok if int03 <= 5 - #> 4. Gesamtbetrag > 50,- € -->ok - #> 5. OPOS, also bereits fehlgeschlagene Einzüge -->ok - # 6. "Internas und Bearbeitungstatus" wenn definiert und nicht Buchungsfreigabe, txid renew -# -#payone_cron cron Intervall 0=disabled, 1=weekly, 2=monthly -# -#All with coded conditions -#sudo su www-data -c "./src/scripts/payone_cron.pl tinkdms '' 1" - -#One invoice -#sudo su www-data -c "./src/scripts/payone_cron.pl tinkdms ctt_id 1" -# -# -use vars qw($syshost); - -BEGIN { - $syshost = $ARGV[0] || exit 1; -} - -use lib "/var/www/copri-bike/$syshost/src"; - -my $ctt_id = $ARGV[1] || ""; -my $intervall = $ARGV[2] || "1"; - -use strict; -use warnings; -use POSIX; -use Lib::Config; -use Mod::Libenz; -use Mod::DBtank; -use Mod::Payment; -use Data::Dumper; -use Scalar::Util qw(looks_like_number); - -my $cf = new Config; -my %varenv = $cf->envonline(); -my $lb = new Libenz; -my $dbt = new DBtank; -my $pay = new Payment; -my $now_dt = strftime("%Y-%m-%d %H:%M:%S",localtime(time)); -my $owner = 179;#179=cron - -my $dbh = $dbt->dbconnect(); - - #get Firma in contentuser - my $fetchuser = { - table => "contentuser", - fetch => "one", - c_id => 100002, - }; - my $ctf = $dbt->fetch_tablerecord($dbh,$fetchuser); - - #collect open invoices - my $fetchtrans = { - table => "contenttrans", - fetch => "all", - keyfield => "c_id", - main_id => "300008",#Rechnung - template_id => "218",#Rechnung - state => "is::null",#never tried buchen - close_time => "",#invoice isn't closed - int14 => "is::null",#OPOS - owner => "!=::$owner",#not 179=cron, not still tried by payone_cron - }; - $fetchtrans = { %$fetchtrans , c_id => $ctt_id } if($ctt_id && $ctt_id =~ /^\d+$/); - my $ct4rel = $dbt->fetch_record($dbh,$fetchtrans); - - open(FILE,">>$varenv{logdir}/payone_cron.log"); - print FILE "\n\n*** $now_dt\n"; - - my $max_sum = $ctf->{int03} || "10000"; - my $max_timestamp = "210001012359"; - my $scol = "mtime"; - my $i=0; - - #loop invoices - #foreach my $id (sort { $ct4rel->{$a}->{$scol} cmp $ct4rel->{$b}->{$scol} }keys (%$ct4rel)){ - foreach my $id (sort { $ct4rel->{$b}->{$scol} cmp $ct4rel->{$a}->{$scol} }keys (%$ct4rel)){ - $i++; - - print FILE "\n$i)** loop $now_dt ---> payone_cron select invoice ct.c_id:$ct4rel->{$id}->{c_id}| ca.c_id:$ct4rel->{$id}->{int10}| ct.ct_name:$ct4rel->{$id}->{ct_name}| ct.mtime:$ct4rel->{$id}->{mtime}\n"; - if($ct4rel->{$id}->{int10} && !$ct4rel->{$id}->{txt22} && $ct4rel->{$id}->{ct_name} =~ /---|^\d+$/){ - - #my $umst1619 = $lb->umst_breaking($ct4rel->{$id},$now_dt); - - #get Adresse from contentadr - my $fetchadr = { - table => "contentadr", - fetch => "one", - int16 => $intervall, - c_id => $ct4rel->{$id}->{int10}, - }; - my $ctadr = $dbt->fetch_tablerecord($dbh,$fetchadr); - - #payone_cron cron Intervall 0=disabled, 1=weekly, 2=monthly - if($ctadr->{int16}){ - #collect invoice positions - my $fetchpos = { - table => "contenttranspos", - fetch => "all", - keyfield => "c_id", - ct_id => $ct4rel->{$id}->{c_id}, - }; - my $cttpos = $dbt->fetch_tablerecord($dbh,$fetchpos); - - my $scol = "itime"; - my $sum_parts0=0; - my $sum_parts7=0; - my $sum_parts19=0; - #my $diff19 = 100 + $umst1619; - my $diff19 = 100 + 19; - my $sum_umst7=0; - my $sum_umst19=0; - my $j=0; - my $accounting_start = ""; - my $accounting_end = ""; - my $k=0; - my $m=0; - - my $capture_condition=1;#1=false - - #loop invoice positions - foreach my $id (sort { $cttpos->{$b}->{$scol} cmp $cttpos->{$a}->{$scol} } keys(%$cttpos)){ - if(($cttpos->{$id}->{int12} && $cttpos->{$id}->{int12} !~ /300005|300024/) || (($cttpos->{$id}->{int10} && $cttpos->{$id}->{int10} == 1) && ($cttpos->{$id}->{int03} && $cttpos->{$id}->{int03} <= 5) && ($cttpos->{$id}->{txt01} && $cttpos->{$id}->{txt01} !~ /fixed|defect/ || ($cttpos->{$id}->{owner_end} && $cttpos->{$id}->{owner_end} > 1000)))){ - $j++; - - 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)){ - $k++; - #print "$i (($id: $cttpos_timestamp <= $max_timestamp) && ($sum_parts19 <= $max_sum))
"; - if($k==1){ - $accounting_end = "$3.$2.$1" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/); - $accounting_start = $accounting_end; - }else{ - $accounting_start = "$3.$2.$1" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/); - } - - $capture_condition=0; - my $gesamt = 0; - my $einzel = $cttpos->{$id}->{int02}; - my $menge = $cttpos->{$id}->{int03}; - $gesamt = $einzel * $menge; - - my $rabatt_val = $cttpos->{$id}->{int07} || 0; - my $rabatt_eur = 0; - my $proz_eur = $cttpos->{$id}->{int08} || 0; - if($rabatt_val != 0){ - $rabatt_eur = $rabatt_val; - if($proz_eur != 1){#wenn int08 != 1 alias € - $rabatt_eur = $einzel * $menge * $rabatt_val/100; - } - $gesamt = $einzel * $menge - $rabatt_eur; - } - $m++ if($gesamt != 0); - print FILE "pos gesamt: $gesamt = $einzel * $menge - $rabatt_eur ($rabatt_val|$rabatt_eur)\n"; - - $gesamt = $lb->round($gesamt); - $gesamt = $lb->cashme($gesamt); - $ctf->{txt13} = $1 if($ctf->{txt13} =~ /(\d+)/); - if($ct4rel->{$id}->{node_name} && $ct4rel->{$id}->{node_name} =~ /steuerfrei/){ - $sum_parts0 += $gesamt; - }elsif($cttpos->{$id}->{int05} && $cttpos->{$id}->{int05} =~ /\d/){ - $sum_parts0 += $gesamt if($cttpos->{$id}->{int05} == 0); - $sum_parts7 += $gesamt if($cttpos->{$id}->{int05} == 7); - $sum_parts19 += $gesamt if($cttpos->{$id}->{int05} >= 16); - }else{ - $sum_parts0 += $gesamt if($ctf->{txt13} == 0); - $sum_parts7 += $gesamt if($ctf->{txt13} == 7); - $sum_parts19 += $gesamt if($ctf->{txt13} >= 16); - } - }#end timestamp - }else{#end conditons - $capture_condition=1; - #print "LAST LINE\n"; - last; - } - }#end loop invoice positions - - my $sum_paid = $sum_parts0 + $sum_parts7 + $sum_parts19; - $sum_paid = $lb->round($sum_paid); - my $sum_preauth = $sum_paid || 0; - $sum_paid = $lb->cashme($sum_paid,""); - my $line_count2 = $m+4; - - print FILE "---> payone_cron capture conditions c_id:$ct4rel->{$id}->{c_id}, capture_condition:$capture_condition, sum_paid:$sum_paid, sum_preauth:$sum_preauth, ($accounting_start - $accounting_end)\n"; - if($capture_condition==0 && $sum_paid > 0 && $sum_paid <= 50){ - my $update = { - table => "contenttrans", - int15 => "$sum_preauth", - txt20 => "$accounting_start - $accounting_end", - owner => "$owner",#cron - int04 => "14.$line_count2", - mtime => "now()", - }; - my $record = { c_id => $ct4rel->{$id}->{c_id} }; - my $rows = $dbt->update_record($dbh,$update,$record) if($record->{c_id} > 0); - - my ($return,$return_text) = $pay->payone_capture(\%varenv,$ctf,$ctadr,$ct4rel->{$id},$sum_paid,$owner); - print FILE "---> Payment.pm Modul things: $return_text\nFinally log payone-return-post.log\n"; - - sleep 20; - }elsif($sum_paid > 0){ - my $update = { - table => "contenttrans", - txt22 => "cronjob fail",#also defined in Config.pm - owner => "$owner",#cron - mtime => "now()", - }; - my $record = { c_id => $ct4rel->{$id}->{c_id} }; - my $rows = $dbt->update_record($dbh,$update,$record) if($record->{c_id} > 0); - print FILE "---> payone_cron c_id:$ct4rel->{$id}->{c_id} conditions fails\n"; - }else{ - print FILE "---> payone_cron c_id:$ct4rel->{$id}->{c_id} conditions fails at all, sum_paid: $sum_paid > 0\n"; - } - }#end if $ctadr->{int16} - }else{ - my $update = { - table => "contenttrans", - #txt22 => "cronjob fail",#disabled to keep fibu saved Bearbeitsungsstatus - owner => "$owner",#cron - mtime => "now()", - }; - my $record = { c_id => $ct4rel->{$id}->{c_id} }; - my $rows = $dbt->update_record($dbh,$update,$record) if($record->{c_id} > 0); - - print FILE "---> payone_cron c_id:$ct4rel->{$id}->{c_id} Failure: no ct.int10 or order_stat ct.txt22:$ct4rel->{$id}->{txt22}\n"; - } - }#end loop invoices - - close(FILE); - diff --git a/copri4/main/src/scripts/payone_cron.pl b/copri4/main/src/scripts/payone_cron.pl new file mode 120000 index 0000000..f1fa908 --- /dev/null +++ b/copri4/main/src/scripts/payone_cron.pl @@ -0,0 +1 @@ +../../../../../sharee.bike/copri-bike/main/src/scripts/payone_cron.pl \ No newline at end of file diff --git a/copri4/main/src/scripts/payone_operatorsloop.pl b/copri4/main/src/scripts/payone_operatorsloop.pl deleted file mode 100755 index 683dafa..0000000 --- a/copri4/main/src/scripts/payone_operatorsloop.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl -# -# SPDX-License-Identifier: AGPL-3.0-or-later -# Copyright (c) Rainer Gümpelein, TeilRad GmbH -# -#loops sharee operators for payone capture -#only primary should do this -# -#sudo su www-data -c "./src/scripts/payone_operatorsloop.pl 1" -# -#defined by cronjob -#weekly for $ARGV[0]=1 -#nonthly for $ARGV[0]=2 -# -use lib "/var/www/copri4/shareedms-primary/src"; - -use strict; -use warnings; -use POSIX; -use Config::General; - -die if(!$ARGV[0] || ($ARGV[0] != 1 && $ARGV[0] != 2)); - -my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg"; -my $conf = Config::General->new($globalconf_file); -my %globalconf = $conf->getall; - -while (my ($key, $value) = each %{ $globalconf{"operator"} }) { - if(-d "/var/www/copri4/$value->{syshost}"){ - `/var/www/copri4/shareedms-primary/src/scripts/payone_cron.pl $value->{syshost} '' $ARGV[0]`; - die if($? != 0); - }else{ - print "/var/www/copri4/$value->{syshost} not available\n"; - } -} diff --git a/copri4/main/src/scripts/payone_post_Payment.pl b/copri4/main/src/scripts/payone_post_Payment.pl deleted file mode 100755 index 165b9b0..0000000 --- a/copri4/main/src/scripts/payone_post_Payment.pl +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/perl -# -#Autor ragu@gnu-systems.de -#sharee payone POST -# -#managemandate -#sudo su www-data -c "/var/www/copri4/shareeapp-primary/src/scripts/payone_post_Payment.pl shareeapp-fr01 managemandate contentadr 21250" -# -#captureSEPA -#sudo su www-data -c "/var/www/copri4/shareeapp-primary/src/scripts/payone_post_Payment.pl shareeapp-fr01 preauthorizationSEPA contentadr 22027 28845" -#sudo su www-data -c "/var/www/copri4/shareeapp-primary/src/scripts/payone_post_Payment.pl shareeapp-fr01 captureSEPA contenttrans '' 28845" -# -use vars qw($syshost); - -BEGIN { - $syshost = $ARGV[0] || die 'syshost not defined'; -} - -use lib "/var/www/copri-bike/$syshost/src"; - -use strict; -use warnings; -use POSIX; -use CGI ':standard'; -use Lib::Config; -use Mod::Libenzdb; -use Mod::Payment; -use Config::General; - -use Data::Dumper; -use Sys::Hostname; -my $hostname = hostname; - -my $q = new CGI; -my $cf = new Config; -my %varenv = $cf->envonline("$syshost"); -print "$varenv{dbname}\n"; - -my $db = new Libenzdb; -my $pay = new Payment; -my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; -my $owner = 178;#payone API - -my $todo = $ARGV[1]; -my $table = $ARGV[2]; -my $ctadr_id = $ARGV[3]; -my $ctt_id = $ARGV[4]; -my $sequenz = $ARGV[5] || 0; -my $set_time = $ARGV[6] || "";#no_time -my $renewed = $ARGV[7] || "";#for requesting new txid via script loop_payone_capture.pl -my $request_state = $ARGV[8] || "";#if request state=occupied , then never delete adr4xml - -my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg"; -my $conf = Config::General->new($globalconf_file); -my %globalconf = $conf->getall; -#print Dumper(\%globalconf); - -my $refpre = $globalconf{operator}{$varenv{dbname}}->{oprefix};#FR KN ... -my $payone_conf = $globalconf{operator}{$varenv{dbname}}{payone_conf} || $globalconf{payone_conf}; - -my $ctadr = { c_id => 0 }; -my $ctt = { c_id => 0 }; -$ctadr = $db->get_contentrow("contentadr",$ctadr_id,"","","","","","") if($ctadr_id); -$ctt = $db->get_contentrow("contenttrans",$ctt_id,"","","","","","") if($ctt_id); - -#managemandate SEPA -#1. -#sudo su www-data -c "./src/scripts/payone_post.pl $varenv{syshost} managemandate contentadr $ctadr_id" -if($todo eq "managemandate" && $table eq "contentadr" && $ctadr->{c_id} > 0){ - $pay->managemandate_main(\%varenv,$ctadr,$ctt,$owner); -} -#preauthorizationSEPA -#2. -#sudo su www-data -c "./src/scripts/payone_post.pl $varenv{syshost} preauthorizationSEPA contentadr $ctadr_id $ctt_id" -if($todo eq "preauthorizationSEPA" && $table eq "contentadr" && $ctadr->{c_id} > 0 && $ctt->{c_id} > 0){ - $pay->preauthorizationSEPA_main(\%varenv,$ctadr,$ctt,$owner); -} -#captureSEPA -#3. -#sudo su www-data -c "./src/scripts/payone_post.pl $varenv{syshost} captureSEPA contenttrans '' $ctt_id" -if($todo eq "captureSEPA" && $table eq "contenttrans" && $ctt->{c_id} > 0){ - $pay->captureSEPA_main(\%varenv,$ctadr,$ctt,$owner); -} -#preauthorizationCC -#1.PayoneCC creditcardcheck ajaxCall -#2. -#sudo su www-data -c "./src/scripts/payone_post.pl $varenv{syshost} preauthorizationCC contentadr $ctadr_id $ctt_id" -if($todo eq "preauthorizationCC" && $table eq "contentadr" && $ctadr->{c_id} > 0 && $ctt->{c_id} > 0){ - $pay->preauthorizationCC_main(\%varenv,$ctadr,$ctt,$owner); -} -#captureCC -#3. -# -if($todo eq "captureCC" && $table eq "contenttrans" && $ctt->{c_id} > 0){ - $pay->captureCC_main(\%varenv,$ctadr,$ctt,$owner); -} -