invoice_nr nextNr

This commit is contained in:
ragu 2022-07-13 11:19:55 +02:00
parent 3ea4b37b78
commit b9af62e5fc
3 changed files with 59 additions and 42 deletions

View file

@ -853,9 +853,9 @@ sub update_one(){
my $one = $one_in;
if($update->{table} =~ /^users|relation|node|template/){
$one .= ",change='now()'";
$one .= ",change='now()'" if($update->{change} ne "no_time");
}else{
$one .= ",mtime='now()'";
$one .= ",mtime='now()'" if($update->{mtime} ne "no_time");
}
$one .= ",owner=$update->{owner}" if($update->{owner});

View file

@ -19,8 +19,6 @@ my $uri_encode = URI::Encode->new( { encode_reserved => 1 } );
use Scalar::Util qw(looks_like_number);
use Lib::Config;
use Mod::Libenz;
use Mod::Libenzdb;
use Mod::Callib;
use Mod::DBtank;
use Mod::Basework;
@ -28,8 +26,6 @@ use Data::Dumper;
my $q = new CGI;
my $cf = new Config;
my $lb = new Libenz;
my $db = new Libenzdb;
my $cal = new Callib;
my $dbt = new DBtank;
my $bw = new Basework;
@ -644,17 +640,31 @@ sub payone_capture(){
my $return_text = "";
my $dbh = "";
my $update_ctt = {
table => "contenttrans",
mtime => "now()",
owner => $owner,
int01 => $sum_paid,
int14 => 2,
};
#Node and HoleCkeck depended auto Rechnungs-Nummer
my $node = $db->get_node4multi($main_id,$lang);#Rechnung node
if($node->{int06} > 0){
my $node = $dbt->get_node($dbh,$main_id);#Rechnung node
if($node->{invoice_nr} > 0){
if($ctt->{ct_name} !~ /\d/){
my $nextNr = $node->{int06};
$db->update_content4change("contenttrans",$ctt->{c_id},$nextNr,$nextNr,"barcode");
my $int06 = $node->{int06} + 1;
$db->updater("nodes","main_id",$main_id,"int06",$int06,"","","","","no_time");
my $nextNr = $node->{invoice_nr};
$update_ctt->{ct_name} = "$nextNr";
$update_ctt->{barcode} = "$nextNr";
my $update_node = {
table => "nodes",
main_id => "$main_id",
change => "no_time",
};
my $invoice_nr = $node->{invoice_nr} + 1;
$dbt->update_one($dbh,$update_node,"invoice_nr='$invoice_nr'");
}
}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->{invoice_nr} | $ctt->{ct_name} can not generate invoice number\n";
return $return_text;
}
@ -673,19 +683,11 @@ sub payone_capture(){
}
}
my $update_ctt = {
table => "contenttrans",
mtime => "now()",
owner => $owner,
int01 => $sum_paid,
int14 => 2,
state => "$state",
};
$update_ctt->{state} = "$state";
$dbt->update_record($dbh,$update_ctt,$ctt);
#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 $return_text;
}
@ -701,7 +703,13 @@ sub payone_capture(){
}
#check if preauth txid is done by payone
$ctt = $db->get_content1("contenttrans",$ctt->{c_id});
my $pref = {
table => "contenttrans",
fetch => "one",
template_id => 218,
c_id => $ctt->{c_id},
};
$ctt = $dbt->fetch_record($dbh,$pref);
#SEPA capture
if($ctt->{int03} == 1 && $ctt->{txt16} && $ctt->{state} =~ /SEPA/){#SEPA

View file

@ -594,23 +594,36 @@ sub preinit(){
my ($node,$ct_exist);
return "failure::Bitte erst einen Formular-Typ wählen" if($R::set_main_id <= "300000");
$u_rows += $db->update_relation2("",$lang,$R::set_main_id,"",$rel->{rel_id}) if(!$R::close_time && $rel->{rel_id});
$node = $db->get_node4multi($R::set_main_id,$lang);
if($node->{main_id} > 300000){
my $rows = $node->{int10} + 1;
$db->updater("nodes","main_id",$node->{main_id},"int10",$rows);
}
#$node = $db->get_node4multi($R::set_main_id,$lang);
$node = $dbt->get_node($dbh,$R::set_main_id);
#if($node->{main_id} > 300000){
# my $rows = $node->{int10} + 1;
# $db->updater("nodes","main_id",$node->{main_id},"int10",$rows);
#}
my $update_ctt = {
table => "contenttrans",
mtime => "now()",
owner => $users_dms->{u_id},
};
#Node and HoleCkeck depended auto Rechnungs-Nummer
if(($node->{int06} > 0) && ("$ctt->{ct_name}" !~ /\d/ || "$R::set_main_id" != "$rel->{main_id}")){
if(($node->{invoice_nr} > 0) && ("$ctt->{ct_name}" !~ /\d/ || "$R::set_main_id" != "$rel->{main_id}")){
my $nextNr = $node->{int06};
$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");
my $nextNr = $node->{invoice_nr};
$update_ctt->{ct_name} = "$nextNr";
$update_ctt->{barcode} = "$nextNr";
my $update_node = {
table => "nodes",
main_id => "$R::set_main_id",
change => "no_time",
};
my $invoice_nr = $node->{invoice_nr} + 1;
$dbt->update_one($dbh,$update_node,"invoice_nr='$invoice_nr'");
}elsif($ctt->{ct_name} !~ /\d/){
$db->update_content4change($table,$c_id,$c_id,$c_id,"barcode") ;
#}elsif($ctt->{ct_name} !~ /\d/){
#$db->update_content4change($table,$c_id,$c_id,$c_id,"barcode") ;
}
#Change Formular Type -----------------------------------------------
@ -634,13 +647,9 @@ sub preinit(){
$sum_paid = $R::sum_paid;
$sum_paid =~ s/,/\./;
}
my $update_ctt = {
table => "contenttrans",
mtime => "now()",
owner => $users_dms->{u_id},
int01 => $sum_paid,
state => "$state",
};
$update_ctt->{int01} = "$sum_paid";
$update_ctt->{state} = "$state";
$update_ctt->{int14} = 2 if($state =~ /payone/);#set OPOS
$dbt->update_record($dbh,$update_ctt,$ctt);