rental deactivation on payment-fault and payment-type key change

This commit is contained in:
ragu 2024-01-16 06:23:43 +01:00
parent f731aa352b
commit 5044e9bfe8
13 changed files with 229 additions and 101 deletions

View file

@ -956,6 +956,17 @@ sub booking_request(){
#if invoice exist
if($ctt->{c_id}){
#if any OPOS then permit further rentals
my $ctt_opos = { c_id => 0 };
my $pref_opos = {
table => "contenttrans",
fetch => "one",
template_id => "IN::(209,218)",
int10 => $auth->{c_id},
state => "payment_fault",#selects Zahlungsausfall or int14 opos
};
$ctt_opos = $dbt->fetch_record($dbh,$pref_opos);
#if payment-type prepaid, then check whether balance positive
my $sum_balance = 0;
if($auth->{int03} && $auth->{int03} == 3){
@ -986,8 +997,9 @@ sub booking_request(){
}
$bw->log("booking_request prepaid balance sum: $sum_balance, userID: $auth->{c_id} ",$sum_balance,"");
}
#Rental is only permitted if sum_balance <= 0 (in primary prepaid context positive)
if($sum_balance <= 1){
#Rental is only permitted if sum_balance <= 1 (in primary prepaid context positive)
#Rental is only permitted if no invoice with payment_fault or opos
if($sum_balance <= 1 && !$ctt_opos->{c_id}){
#2 = "requested"
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_bike,$ct_station,$auth,$ct_tariff,$now_dt,$bike,"2",$owner,$sig_book);
$bw->log("booking_request insert_pos:",$pos_id,"");
@ -1040,8 +1052,15 @@ sub booking_request(){
$response_text="Entschuldigung, es ist ein Fehler aufgetreten. Bitte kontaktieren Sie unsere hotline damit wir das Problem lösen können";
}
}else{
$response_state="Failure 1593: rental is prohibited because of prepaid balance - $sum_balance";
$response_text="Bitte überprüfen Sie Ihren Prepaid/Vorkasse Kontostand, aktuell: - $sum_balance €. Nur bei positiven Kontostand können wir das Mietradsystem für Sie freischalten.";
if($ctt_opos->{c_id}){
$response_state="Failure 1593: rental is prohibited because of payment_fault invoice $ctt_opos->{ct_name}";
$response_text="Es existiert ein Problem mit einer Rechnung. Bitte melden Sie sich bei rechnung\@sharee.bike .";
}else{
$sum_balance = sprintf('%.2f',$sum_balance);
$sum_balance =~ s/\./,/;
$response_state="Failure 1594: rental is prohibited because of prepaid balance - $sum_balance";
$response_text="Bitte überprüfen Sie Ihren Prepaid/Vorkasse Kontostand, aktuell: - $sum_balance €. Nur bei positiven Kontostand können wir das Mietradsystem für Sie freischalten.";
}
}#end if $sum_balance
}
}elsif($rentable_check == 1){
@ -1698,7 +1717,7 @@ sub user_rentals_history(){
$pref->{mtime} = ">=::(now() - interval '$month month')";
}else{
#2024-01-08 list not succesfully captured positions by also using ct.int14 >= 1
$pref->{'ct.state'} = "is::null";# OR ct.int14 >= 1
$pref->{'ct.state'} = "is::null";# ct.int04 is null OR ct.int14 >= 1
#$pref->{'ct.int14'} = "is::null";
}
@ -1966,7 +1985,7 @@ sub bikes_available(){
$return->{$id}->{bike_type}->{category} = "cargo";
$return->{$id}->{bike_type}->{wheels} = "2";
$return->{$id}->{bike_type}->{wheels} = "3" if($record->{$id}->{txt01} =~ /drei|trike/i);
if($record->{$id}->{energy_id} || $record->{$id}->{txt01} =~ /E-/i){
if($record->{$id}->{energy_id}){
$return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy";
my $max_bars = 5;
my $current_bars = 0;
@ -2151,7 +2170,7 @@ sub bikes_all(){
$return->{$id}->{bike_type}->{category} = "cargo";
$return->{$id}->{bike_type}->{wheels} = "2";
$return->{$id}->{bike_type}->{wheels} = "3" if($record->{$id}->{txt01} =~ /drei|trike/i);
if($record->{$id}->{energy_id} || $record->{$id}->{txt01} =~ /E-/i){
if($record->{$id}->{energy_id}){
$return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy";
my $max_bars = 5;
my $current_bars = 0;
@ -2201,7 +2220,7 @@ sub bikes_all(){
return ($op_return,$record,$bikes_on_station);
}#end bikes_all
#station caching for each tarif
#station cache for each tarif
sub stations_caching {
my $self = shift;
my $q = shift || "";
@ -2235,7 +2254,7 @@ sub stations_available(){
my $authed = 0;
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
my $authcookie = $q->param('authcookie') || $q->cookie('domcookie');
my $authcookie = $q->param('authcookie') || $q->cookie('domcookie') || "";
my ($bike_group,$bike_node,$user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$authcookie,$cachme);
#$bw->log("fetch_tariff adrtarif_hash from $varenv->{dbname}\n",$adrtarif_hash,"");

View file

@ -941,6 +941,8 @@ elsif($q->param('request') eq "service_done"){
#add-on to log redistribute
my $action = "txt10=" . $bikes_allraw->{$bike_id}->{int04} . " - " . $q->param('work_val');
$apif->service_update($q,$authraw,$node_template,$service_id,$action);
#2024-01-12 after redistribute
$apif->stations_caching($q,\%varenv,$authraw);
my ($stations_all,$stations_allraw) = $apif->stations_all($q,\%varenv,$bikes_on_station,$authraw);
if(looks_like_number($stations_allraw->{$to_station_id}->{int04})){
@ -985,8 +987,6 @@ elsif($q->param('request') eq "service_done"){
($response_work, $node) = $apif->service_work($pos_record,$stations_allraw,"",$node_template);
}
#should not be mandatory here, maybe only for bike_count
#$apif->stations_caching($q,\%varenv,$authraw);
#inject oprefix
my $op_response_work = {};

View file

@ -328,8 +328,6 @@ sub channel_map(){
196 => "copri",#mig
197 => "web sharee.bike",#mig
198 => "primary",#mig
199 => "LV API",#mig
201 => "web Renta",#mig
294 => "example Web",#mig
295 => "example App",#mig
296 => "example Op",#mig
@ -683,9 +681,9 @@ sub collect_post(){
$cp_where .= " and cp.$key $op '$value'";
}
}
}elsif($key =~ /ct\.close_time|ct\.state|ct\.int14/ && $value){#used to get open invoices
}elsif($key =~ /ct\.close_time|ct\.state|ct\.int04|ct\.int14/ && $value){#used to get open invoices
if($key =~ /ct\.state/ && $value eq "null"){
$ct_where .= " and ($key $op $value OR $key = '' OR ct.int14 >= 1)";
$ct_where .= " and (ct.int04 is $value OR ct.int14 >= 1)";#all un-booked or opos
}else{
$ct_where .= " and $key $op $value";
}
@ -783,7 +781,9 @@ sub fetch_record(){
#can also be "rel.main_id IN (300005,300024)"
$where .= " and rel.$key $op $value" if($key =~ /^(parent_id|main_id|template_id|rel_id)$/ && $value);
if($key =~ /^(ct_name$|txt\d+|uri\d+|state)$/ && $value){
if($value =~ /length/){
if($key eq "state" && $value eq "payment_fault"){
$where .= " and (ct.int14 >= 1 || ct.int14 == 7)";#OPOS or Zahlungsausfall
}elsif($value =~ /length/){
$where .= " and $value";
}elsif($value eq "null"){
$where .= " and (ct.$key is null OR ct.$key = '')";
@ -1621,7 +1621,7 @@ sub insert_contenttrans(){
my $doc_name = "Rechnung";
$doc_name = "Tagesabschluss" if($tpl_id == 209);
$doc_name = "Prepaid Account" if($tpl_id == 219);
$owner="199" if(!$owner);
$owner="0" if(!$owner);
my $paymenttype = $ctadr->{int03} || 0;
#keep in mind int10 will be mainly used by Prelogic and Printpreview, thats because we save it also
my $sth = $dbh->prepare("INSERT INTO contenttrans (ct_name,txt00,int10,int03,txt02,txt01,txt03,txt06,txt07,txt08,txt10,txt11,owner,itime) VALUES('$invoice_nr','$doc_name','$ctadr->{c_id}','$paymenttype','$ctadr->{txt02}','$ctadr->{txt01}','$ctadr->{txt03}','$ctadr->{txt06}','$ctadr->{txt07}','$ctadr->{txt08}','$ctadr->{txt10}','$ctadr->{txt11}','$owner','now()') RETURNING c_id");
@ -1836,7 +1836,8 @@ sub search_content {
}
}#
if($v_journal =~ /Tagesbericht/){
$txt_where .= " and (ct.state ~ '[a-z]') and ct.int01 is not null and ct.close_time is null";
#$txt_where .= " and (ct.state ~ '[a-z]') and ct.int01 is not null and ct.close_time is null";
$txt_where .= " and ct.int04 >= 1 and ct.int01 is not null and ct.close_time is null";
$txt_where .= " and ct.int14 is $opos" if($opos eq "null");
}
@ -1931,11 +1932,11 @@ sub update_close_transactions {
my $close_ref = shift;
#close transactions int11 close_trans reference c_id
my $sth = $dbh->prepare("UPDATE $close_ref->{table} SET close_time='now()',int11=$close_ref->{close_id} where c_id IN (SELECT ct.c_id from $close_ref->{table} ct, relation rel where ct.c_id=rel.content_id and (ct.state ~ '[a-z]') and ct.int01 is not null and rel.main_id IN ($close_ref->{source_main_id}) and ct.close_time is null and ct.int14 is null)");
my $sth = $dbh->prepare("UPDATE $close_ref->{table} SET close_time='now()',int11=$close_ref->{close_id} where c_id IN (SELECT ct.c_id from $close_ref->{table} ct, relation rel where ct.c_id=rel.content_id and ct.int04 >= 1 and ct.int01 is not null and rel.main_id IN ($close_ref->{source_main_id}) and ct.close_time is null and ct.int14 is null)");
my $rows = $sth->execute();
#move/set to journal
$sth = $dbh->prepare("UPDATE relation SET main_id=$close_ref->{main_id}, template_id=$close_ref->{template_id} where template_id=$close_ref->{source_template_id} and content_id IN (SELECT ct.c_id from $close_ref->{table} ct, relation rel where ct.c_id=rel.content_id and (ct.state ~ '[a-z]') and ct.int01 is not null and rel.main_id IN ($close_ref->{source_main_id}) and ct.int14 is null)");
$sth = $dbh->prepare("UPDATE relation SET main_id=$close_ref->{main_id}, template_id=$close_ref->{template_id} where template_id=$close_ref->{source_template_id} and content_id IN (SELECT ct.c_id from $close_ref->{table} ct, relation rel where ct.c_id=rel.content_id and ct.int04 >= 1 and ct.int01 is not null and rel.main_id IN ($close_ref->{source_main_id}) and ct.int14 is null)");
$rows = $sth->execute();
return $rows;

View file

@ -75,6 +75,7 @@ sub book_payment {
table => "contenttrans",
mtime => "now()",
owner => $users_dms->{u_id},
int04 => 0,
};
my $node_faktura = $dbt->get_node($dbh,$dbt->{shareedms_conf}->{faktura});
@ -105,17 +106,20 @@ sub book_payment {
my $ctadr = { c_id => 0 };
$ctadr = $dbt->fetch_tablerecord($dbh,$pref_adr) if($ctt->{int10});
my $vde_on_fail = $ctadr->{int12} || 1;#keep last or set 1
print EMA "Used adr c_id:$ctadr->{c_id} by ctt.int10: $ctt->{int10}\n";
my $sum_paid = "null";
my $sum_operatorcredit = "null";
my $sumgeb_teil = "null";
my $sumgeb_bank = "null";
my $sum_prepaid = "null";
my $state = $R::state || "";
$update_ctt->{state} = "$state";
$update_ctt->{int04} = $R::int04 if(looks_like_number($R::int04));#set payment-type by "buchen"
$update_ctt->{int14} = 2;#set OPOS
my $p_hash = $dbt->{shareedms_conf}->{payment_state2};
my $state = $p_hash->{$update_ctt->{int04}};
$update_ctt->{state} = "$state";#save it also to keep backwards compatibility
print EMA "Payment-type $p_hash->{$update_ctt->{int04}} used adr c_id:$ctadr->{c_id} by ctt.int10: $ctt->{int10}\n";
if($R::sum_paid){
$sum_paid = $R::sum_paid;
$sum_paid =~ s/,/\./;
@ -137,7 +141,7 @@ sub book_payment {
$sumgeb_teil =~ s/,/\./;
$update_ctt->{int08} = $sumgeb_teil;
}
#maybe, we don't use it
#maybe, we don't need it
if($R::sum_prepaid){
$sum_prepaid = $R::sum_prepaid;
$sum_prepaid =~ s/,/\./;
@ -146,8 +150,8 @@ sub book_payment {
$feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt);
#$R::state alias payment-type
if($R::state =~ /payone/){
#if payment-type payone
if($update_ctt->{int04} && $update_ctt->{int04} <= 2){
if(!$ctt->{txt16}){
#preauth
@ -161,22 +165,23 @@ sub book_payment {
$ctt = $dbt->fetch_record($dbh,$pref_ctt);#re-read values
#SEPA capture
if($ctt->{txt16} && $R::state =~ /SEPA/){#SEPA
if($ctt->{txt16} && $update_ctt->{int04} == 1){#SEPA
my $payoneret = $self->captureSEPA_main($varenv,$ctadr,$ctt,$users_dms->{u_id});
}
#CC capture
elsif($ctt->{txt16} && $R::state =~ /Kreditkarte/){#CC
elsif($ctt->{txt16} && $update_ctt->{int04} == 2){#CC
my $payoneret = $self->captureCC_main($varenv,$ctadr,$ctt,$users_dms->{u_id});
}
else{
$feedb->{message} = "failure::Achtung, die payone Vorautorisierung hat keine TXID geliefert. Der Geldeinzug war somit nicht möglich (TXID:$ctt->{txt16} && $R::state).";
$feedb->{message} = "failure::Achtung, die payone Vorautorisierung hat keine TXID geliefert. Der Geldeinzug war somit nicht möglich (TXID:$ctt->{txt16} && state: $update_ctt->{int04}|$state).";
}
}else{
$feedb->{message} = "failure::Abbruch, payone Geldeinzug nicht ausgeführt weil TXID bereits vorhanden. Hatte der Einzug bereits stattgefunden?";
}
}
elsif($ctt->{txt00} eq "Storno" || $state eq "Zahlungsausfall"){
#Storno or Zahlungsausfall
elsif($ctt->{txt00} eq "Storno" || $update_ctt->{int04} == 7){
$update_ctt->{int14} = "null";
$update_ctt->{pay_time} = "now()";
$feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt);
@ -187,8 +192,15 @@ sub book_payment {
}else{
$feedb->{message} = "failure::Fehler, OPOS Automatik konnte nicht ausgeführt werden.";
}
if($update_ctt->{int04} == 7){
$update_adr->{int12} = 2;#vde
$dbt->update_record($dbh,$update_adr,$ctadr);
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
$dbt->update_record($dbh_primary,$update_adr,$ctadr);
}
}
elsif($state eq "fehlgeschlagener Einzug"){
#fehlgeschlagener Einzug
elsif($update_ctt->{int04} == 6){
$update_ctt->{int14} = "null";
$update_ctt->{pay_time} = "now()";
$feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt);
@ -198,8 +210,8 @@ sub book_payment {
$update_ctt->{pay_time} = "now()";
$feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt);
}
elsif($state eq "Prepaid" && $ctadr->{c_id}){
#Prepaid
elsif($update_ctt->{int04} == 3 && $ctadr->{c_id}){
#APIshareeio APIcall
my $shareeio_json = {
request => "capture_prepaid",
@ -600,7 +612,7 @@ sub captureSEPA_main {
my $sequence = 1;
$sequence = $ctt_rec->{sequence} if($ctt_rec->{sequence});
if($ctt->{c_id} && (!$ctt->{state} || $ctt->{int14} || $ctt_rec->{payone_reset})){
if($ctt->{c_id} && (!$ctt->{int04} || $ctt->{int14} || $ctt_rec->{payone_reset})){
my $amount = 0;#if payone_reset capture 0
$amount = $ctt->{int01} * 100 if(looks_like_number($ctt->{int01}) && !$ctt_rec->{payone_reset});
my $preauth_request = {
@ -734,7 +746,7 @@ sub captureCC_main {
my $sequence = 1;
$sequence = $ctt_rec->{sequence} if($ctt_rec->{sequence});
if($ctt->{c_id} && (!$ctt->{state} || $ctt->{int14} || $ctt_rec->{payone_reset})){
if($ctt->{c_id} && (!$ctt->{int04} || $ctt->{int14} || $ctt_rec->{payone_reset})){
my $amount = 0;#if payone_reset capture 0
$amount = $ctt->{int01} * 100 if(looks_like_number($ctt->{int01}) && !$ctt_rec->{payone_reset});
my $preauth_request = {
@ -930,7 +942,7 @@ sub rpc {
}else{#not APPROVED
print FILE "NOT APPROVED $now_dt\n $todo: ctt.c_id=$ctt->{c_id} && ctadr.c_id=$ctadr->{c_id}" . $res->content . "\n" if($debug);
$update_ctt->{int14} = 1 if($ctt->{state});#OPOS
$update_ctt->{int14} = 1 if($ctt->{int04});#OPOS
#errormessage=Reference number already exists --> disabled
#errormessage=Amount no longer available --> disabled
@ -1021,7 +1033,6 @@ sub payone_capture {
my $sum_paid = shift;
my $owner = shift;
my $lang = "de";
my $mandant_id = 100002;
my $main_id = $ctt->{main_id};
my $retval = "";
@ -1030,12 +1041,20 @@ sub payone_capture {
my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
my $aconf = Config::General->new($api_file);
my %apikeyconf = $aconf->getall;
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $update_adr = {
table => "contentadr",
mtime => "now()",
owner => $owner,
};
my $update_ctt = {
table => "contenttrans",
mtime => "now()",
owner => $owner,
int01 => $sum_paid,
int04 => 0,
int14 => 2,
};
@ -1058,21 +1077,33 @@ sub payone_capture {
return $return_text;
}
#set also state because we still need (payone) for some text selection TODO
my $state = $ctt->{state} || "";
my $p_hash = $dbt->{shareedms_conf}->{payment_state2};
$state = $p_hash->{1} if($ctadr->{ct_name} =~ /\w{2}-\d+/);
$state = $p_hash->{2} if(length($ctadr->{ct_name}) >= 19);
if($ctadr->{ct_name} =~ /^\w{2}-\d+/){
$state = $p_hash->{1};
$update_ctt->{int04} = 1;
}
if(length($ctadr->{ct_name}) >= 19){
$state = $p_hash->{2};
$update_ctt->{int04} = 2;
}
if($ctadr->{ct_name} =~ /Prepaid-\d+/){
$state = $p_hash->{3};
$update_ctt->{int04} = 3;
}
$update_ctt->{state} = "$state";
$dbt->update_record($dbh,$update_ctt,$ctt) if($update_ctt->{state});
$dbt->update_record($dbh,$update_ctt,$ctt) if($update_ctt->{int04});
#in cron we set OPOS anyway. If payone captured, it will be set int14=null
if(!$state || $state !~ /payone/){
if(!$update_ctt->{int04}){
$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->{ct_name} && $ctadr->{ct_name} =~ /\w{2}-\d+/ && !$ctt->{txt16}){
if($ctadr->{ct_name} && $ctadr->{ct_name} =~ /^\w{2}-\d+/ && !$ctt->{txt16}){
$self->preauthorizationSEPA_main($varenv,$ctadr,$ctt,$owner);
sleep 2;
@ -1091,13 +1122,39 @@ sub payone_capture {
$ctt = $dbt->fetch_record($dbh,$pref);
#SEPA capture
if($ctadr->{ct_name} =~ /\w{2}-\d+/ && $ctt->{txt16} && $ctt->{state} =~ /SEPA/){#SEPA
if($ctadr->{ct_name} =~ /^\w{2}-\d+/ && $ctt->{txt16} && $ctt->{int04} == 1){
$self->captureSEPA_main($varenv,$ctadr,$ctt,$owner);
}
#CC capture
elsif(length($ctadr->{ct_name}) >= 19 && $ctt->{txt16} && $ctt->{state} =~ /Kreditkarte/){#CC
elsif(length($ctadr->{ct_name}) >= 19 && $ctt->{txt16} && $ctt->{int04} == 2){
$self->captureCC_main($varenv,$ctadr,$ctt,$owner);
}
#Prepaid
elsif($ctadr->{ct_name} =~ /Prepaid-\d+/ && $ctt->{int04} == 3){
#APIshareeio APIcall
my $shareeio_json = {
request => "capture_prepaid",
userID => "$ctadr->{c_id}",
sum_paid => "$update_ctt->{int01}",
invoice_reference => "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}-$ctt->{c_id}-$ctt->{ct_name}",
};
my $vde_on_fail = $ctadr->{int12} || 1;#keep last or set 1
my $response_in = {};
$response_in = $rpcs->request_shareeio($varenv,$dbh,$ctadr,$shareeio_json);
if($response_in->{shareeio}->{response_state} =~ /Success/i){
$update_ctt->{int14} = "null";
$update_ctt->{pay_time} = "now()";
$update_adr->{int12} = "null";
}else{
$update_adr->{int12} = $vde_on_fail;#Vde
}
$update_ctt->{txt28} = $now_dt . " $state\n" . $response_in->{shareeio}->{response_state} . "\n\n" . $ctt->{txt28};
$dbt->update_record($dbh,$update_ctt,$ctt);
$dbt->update_record($dbh,$update_adr,$ctadr);
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
$dbt->update_record($dbh_primary,$update_adr,$ctadr);
}
else{
$return_text = "Payment.pm can not get TXID ($ctadr->{int03} && $ctadr->{ct_name} && TXID:$ctt->{txt16})\n";
}
@ -1112,7 +1169,6 @@ sub payone_capture {
$exit_code = $?;
sleep 2;
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $filesize = -s "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf";
open(EMA, ">> $varenv->{logdir}/copri-print.log");
print EMA "\n$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\&pkey=$apikeyconf{pdfprinter}->{pkey}\" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $exit_code\n";

View file

@ -938,6 +938,7 @@ sub set_workflow {
delete $ctt->{txt00};
delete $ctt->{state};
delete $ctt->{int01};
delete $ctt->{int04};
delete $ctt->{int14};
delete $ctt->{int15};
delete $ctt->{int16};
@ -1043,6 +1044,7 @@ sub set_accounting2invoice {
delete $ctt->{c_id};
delete $ctt->{txt00};
delete $ctt->{state};
delete $ctt->{int04};
delete $ctt->{itime};
delete $ctt->{mtime};
delete $ctt->{close_time};

View file

@ -586,13 +586,15 @@ sub operator_accounting2calc {
my ($key,$val,$size) = split /=/,$_;
if($key =~ /int/){
if($ctpos->{state} =~ /Zahlungsausfall/){
#Zahlungsausfall
if($ctpos->{int04} == 7){
$oac->{int01} = $sumgeb_bank;
$oac->{int93} = $sumgeb_bank * -1 if($key eq "int01");#Entgelt TeilRad
$oac->{int93} = sprintf('%.3f', $oac->{int93});
}
if($ctpos->{state} =~ /Lastschrift|Überweisung/){
#Lastschrift|Überweisung
if($ctpos->{int04} == 1 || $ctpos->{int04} == 4){
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#Entgelt TeilRad
$oac->{int93} = sprintf('%.3f', $oac->{int93});
$oac->{int94} = $oac->{int01} / 100 * $ctf->{$key} * -1 if($key eq "int02");#po Disagio %
@ -604,7 +606,7 @@ sub operator_accounting2calc {
$oac->{int97} = 0;
}
if($ctpos->{state} =~ /Kreditkarte/){
if($ctpos->{int04} == 2){
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#Entgelt TeilRad
$oac->{int93} = sprintf('%.3f', $oac->{int93});
$oac->{int94} = $oac->{int01} / 100 * $ctf->{$key} * -1 if($key eq "int03");#po Disagio %
@ -644,13 +646,14 @@ sub collect_prepaid {
};
if($ctadr->{c_id}){
#all un-booked or opos
my $posref = {
table => "contenttrans",
table_pos => "contenttranspos",
fetch => "all",
keyfield => "c_id",
ca_id => "$ctadr->{c_id}",
'ct.state' => "is::null",
'ct.state' => "is::null",#selects int04 is null OR int14 >= 1
'ct.close_time' => "is::null",
};
my $cttpos = { c_id => 0 };
@ -715,7 +718,7 @@ sub primary_sum_prepaid {
fetch => "all",
keyfield => "c_id",
ca_id => "$auth->{c_id}",
'ct.state' => "is::null",
'ct.int04' => "is::null",
};
my $prepaid_pos = { c_id => 0 };
$prepaid_pos = $dbt->collect_post($dbh,$pref) if($auth->{c_id});