mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-11 22:37:27 +02:00
Invoice on work mailing. Check iban if still exist with vde. Station selector on edit
This commit is contained in:
parent
a3d251e643
commit
1744cd35a3
15 changed files with 234 additions and 110 deletions
|
@ -1243,6 +1243,7 @@ sub booking_update(){
|
|||
$booking_values->{response_state} = "OK: occupied bike " . $q->param('bike');
|
||||
$booking_values->{response_text} = "Fahrrad Nr. " . $q->param('bike') . " Miete gestartet. ";
|
||||
$update_cc->{int10} = 3;
|
||||
#$update_cc->{int04} = "null";#Because of servicetool, we hav to be keep the station
|
||||
}
|
||||
|
||||
#fraud_rental sms_message
|
||||
|
|
|
@ -699,7 +699,7 @@ elsif($q->param('request') eq "stations_available"){
|
|||
my $localtime = Time::Piece->strptime($lnow, "%Y-%m-%d %H:%M:%S");
|
||||
my $epoch_now = $localtime->epoch;
|
||||
my $merchant_message_start = Time::Piece->strptime("2023-06-26 00:00:00", "%Y-%m-%d %H:%M:%S");
|
||||
my $merchant_message_end = Time::Piece->strptime("2023-07-06 23:59:00", "%Y-%m-%d %H:%M:%S");
|
||||
my $merchant_message_end = Time::Piece->strptime("2023-08-06 23:59:00", "%Y-%m-%d %H:%M:%S");
|
||||
my $epoch_start = $merchant_message_start->epoch;
|
||||
my $epoch_end = $merchant_message_end->epoch;
|
||||
|
||||
|
|
|
@ -422,14 +422,15 @@ sub sig_booking {
|
|||
|
||||
my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/";
|
||||
my %json = ();
|
||||
$ctadr->{txt08} =~ s/[a-z]-/-/; $ctadr->{txt08} =~ s/[a-z]_/_/; $ctadr->{txt08} =~ s/[0-9a-z]\@/\@/i; $ctadr->{txt08} =~ s/[0-9a-z]\@/\@/i; $ctadr->{txt08} =~ s/\@(\w{1,2})\w+\.(\w+)/\@$1email\.$2/i;
|
||||
$ctadr->{txt08} =~ s/[a-z]\./\./ if($ctadr->{txt08} =~ /\.\w+\@/);
|
||||
my $email = $ctadr->{txt08};
|
||||
$email =~ s/[a-z]-/-/; $email =~ s/[a-z]_/_/; $email =~ s/[0-9a-z]\@/\@/i; $email =~ s/[0-9a-z]\@/\@/i; $email =~ s/\@(\w{1,2})\w+\.(\w+)/\@$1email\.$2/i;
|
||||
$email =~ s/[a-z]\./\./ if($email =~ /\.\w+\@/);
|
||||
#reservation start
|
||||
if($todo eq "reserve"){
|
||||
$endpoint .= "bikes/reserve";
|
||||
%json = (
|
||||
bikeId => "$ct_bike->{txt22}",
|
||||
email => "$ctadr->{txt08}"
|
||||
email => "$email"
|
||||
);
|
||||
}
|
||||
#reservation end, this sig request is still not defined. maybe end by rentalId
|
||||
|
@ -438,7 +439,7 @@ sub sig_booking {
|
|||
$endpoint .= "bikes/reserve/end";
|
||||
%json = (
|
||||
rentalId => "$ctpos->{txt11}",
|
||||
email => "$ctadr->{txt08}"
|
||||
email => "$email"
|
||||
);
|
||||
}
|
||||
#rental start
|
||||
|
@ -448,7 +449,7 @@ sub sig_booking {
|
|||
my $sig_bikeId = $ctpos->{txt22} || $ct_bike->{txt22};
|
||||
%json = (
|
||||
bikeId => "$sig_bikeId",
|
||||
email => "$ctadr->{txt08}"
|
||||
email => "$email"
|
||||
);
|
||||
}
|
||||
#rental end
|
||||
|
@ -456,7 +457,7 @@ sub sig_booking {
|
|||
$endpoint .= "rental/end";
|
||||
%json = (
|
||||
rentalId => "$ctpos->{txt11}",
|
||||
email => "$ctadr->{txt08}"
|
||||
email => "$email"
|
||||
);
|
||||
#keep in mind, it will return no json, just text: "Rental Ended"
|
||||
}
|
||||
|
@ -465,7 +466,7 @@ sub sig_booking {
|
|||
elsif($todo eq "rentals_running"){
|
||||
$endpoint .= "rentals/running";
|
||||
%json = (
|
||||
email => "$ctadr->{txt08}"
|
||||
email => "$email"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ sub selector_class(){
|
|||
my $value = $opt;
|
||||
($id,$value) = split /:/,$opt if($opt =~ /\:/);
|
||||
$des_style = "color:grey;" if(!$id);
|
||||
if($sel && $sel eq $id){
|
||||
if($sel eq $id){
|
||||
push @selopt, "<option style='$des_style' selected value='$id'>$value</option>\n";
|
||||
}else{
|
||||
push @selopt, "<option style='$des_style' value='$id'>$value</option>\n";
|
||||
|
|
|
@ -1466,7 +1466,8 @@ sub insert_pos(){
|
|||
my $bike_type_id = $ct->{type_id} || 0;
|
||||
my $from_main_id = $ct->{main_id} || 0;
|
||||
my $from_template_id = $ct->{template_id} || 0;
|
||||
my $station = $ct->{int04} || 0;
|
||||
my $start_station = $ct->{int04} || 0;
|
||||
my $end_station = "null";#2023-07-12 will be not set on request.
|
||||
my $fibumark = $ct->{int16} || 0;
|
||||
my $rabatt = 0;
|
||||
|
||||
|
@ -1502,7 +1503,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,txt12,itime,start_time,end_time,int01,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,template_id,int13,owner,int07,txt04,int09,int17,int15,int11,int18,int19,txt17,txt18,int20,int25,int29,int34,txt22,txt11,int35,int36,int37,int42,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','1','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$from_template_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','1','$trackon','$bike_type_id','$staff','$sig_book->{bikeId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$aa_station','$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,int01,int02,int03,int06,txt05,txt06,txt07,int10,int12,template_id,int13,owner,int07,txt04,int09,int17,int15,int11,int18,int19,txt17,txt18,int20,int25,int29,int34,txt22,txt11,int35,int36,int37,int42,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','1','$unit_price','$menge','$start_station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$from_template_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','1','$trackon','$bike_type_id','$staff','$sig_book->{bikeId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$aa_station','$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,int01,int02,int03,txt01,txt06,txt07,int10,int12,int16,template_id,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$user_name','$ctadr->{txt09}',now(),'1','$unit_price','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$fibumark','$from_template_id','$owner') RETURNING c_id");
|
||||
}
|
||||
|
|
|
@ -213,19 +213,16 @@ sub handler {
|
|||
print $q->header(-charset=>"$html_charset", -cookie=>$cookie);
|
||||
#print "5. set cookie: " . $author->{authcookie} . " -- " . $q->param('authcookie') . " ++ " . $coo . "<br>";
|
||||
|
||||
#2020-07-09 if user-pw authorized, then ignore conflict_ because it matches exist user-data
|
||||
#if user-pw authorized, then ignore conflict_ because it matches exist user-data
|
||||
#should be result to Uhps page
|
||||
if($tinkc_id && $returnwww && $returnwww =~ /conflict_txt07|conflict_txt08/){
|
||||
#delete user-pw conflict registration and going on with existing data
|
||||
#$db->delete_content("contentadr",$tinkc_id);
|
||||
$return = $tk->delete_account($tinkc_id,$users_dms->{u_id});
|
||||
|
||||
$apif->authout($q,$coo) if($coo);
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1");
|
||||
exit 0;
|
||||
}
|
||||
elsif(length($coo) > 20){
|
||||
#we need this to get $R::sessionid to FormEdit
|
||||
#if(length($coo) > 20 && !$q->cookie(-name=>'domcookie')){
|
||||
($api_return,$users_sharee) = $apif->auth_verify($q,$author->{authcookie},"");
|
||||
if(($returnwww && $returnwww =~ /failure::(.*)/) || ($users_sharee->{txt31} && $users_sharee->{txt31} =~ /\w/)){
|
||||
$returnwww =~ s/::/=/g;
|
||||
|
@ -482,6 +479,13 @@ sub handler {
|
|||
($api_return,$users_sharee) = $apif->auth_verify($q,$coo,"");
|
||||
|
||||
if($returnwww =~ /txt22|txt23/){
|
||||
#should be result to Uhps page
|
||||
if($returnwww =~ /conflict_txt22/){
|
||||
$return = $tk->delete_account($users_sharee->{c_id},$users_dms->{u_id});
|
||||
$apif->authout($q,$coo) if($coo);
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1");
|
||||
exit 0;
|
||||
}
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_2}?cum=1$session_and\&$returnwww");
|
||||
}elsif($returnwww =~ /int03/){
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_1_5}?cum=1$session_and\&$returnwww");
|
||||
|
|
|
@ -556,6 +556,7 @@ sub save_contenttranspos {
|
|||
table => "contenttranspos",
|
||||
start_time => "$start_time",
|
||||
end_time => "$end_time",
|
||||
int04 => "null",
|
||||
owner_end => $owner,
|
||||
mtime => "now()",
|
||||
};
|
||||
|
|
|
@ -324,14 +324,12 @@ sub fetch_rentalfeed {
|
|||
|
||||
my $return = {};
|
||||
$return->{bike_group} = ["$bike_group"];
|
||||
#TOD save with prefix
|
||||
$return->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int04}";
|
||||
$return->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int06}";
|
||||
$return->{uri_operator} = "$varenv->{wwwhost}";#TOD, should be DB select
|
||||
$return->{bike} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{barcode}";
|
||||
#TOD save also sig prefix
|
||||
if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} eq "SX"){
|
||||
$return->{bike} = "S3X$ctpos->{barcode}";
|
||||
#$return->{station} = "S3X$ctpos->{int04}";
|
||||
}
|
||||
$return->{state} = "$dbt->{copri_conf}->{bike_state}->{$ctpos->{int10}}" || "";
|
||||
$return->{lock_state} = "$dbt->{copri_conf}->{lock_state}->{$ctpos->{int20}}";
|
||||
|
@ -508,46 +506,62 @@ sub operator_accounting2calc {
|
|||
my $varenv = shift;
|
||||
my $ctpos = shift;#client invoices
|
||||
my $ctf = shift;#Operator-Faktura config
|
||||
my $today4db = strftime("%Y-%m-%d %H:%M:%S",localtime(time));
|
||||
|
||||
my $tplf = $dbt->get_tpl($dbh,"196");#Operator-Faktura
|
||||
my @tplf_order = split /,/,$tplf->{tpl_order};
|
||||
|
||||
my $debug=1;
|
||||
open(FILE,">>$varenv->{logdir}/operator_accounting2calc.log") if($debug);
|
||||
print FILE "\n*-->$today4db $varenv->{dbname}\n" if($debug);
|
||||
print FILE "ctpos:\n" . Dumper($ctpos) . "\n" if($debug);
|
||||
|
||||
#returned values
|
||||
my $oac = {
|
||||
int01 => 0,
|
||||
int02 => 0,
|
||||
int93 => 0,
|
||||
int94 => 0,
|
||||
int95 => 0,
|
||||
int96 => 0,
|
||||
int97 => 0,
|
||||
int98 => 0,
|
||||
int99 => 0,
|
||||
int100 => 0,
|
||||
int01 => 0,#capture netto (Netto Erlös)
|
||||
int02 => 0,#Gutschrift
|
||||
int93 => 0,#Entgelt TeilRad
|
||||
int94 => 0,#Disagio
|
||||
int95 => 0,#Transaktion
|
||||
int96 => 0,#Zahlungsmeldung
|
||||
int97 => 0,#Kreditkarte Zuordnung
|
||||
int99 => 0,#invoice captured brutto
|
||||
int100 => 0,#Operator invoice (TeilRad Gebühren netto)
|
||||
};
|
||||
|
||||
#TODO #accounting Bank Gebühren
|
||||
my $invoice_brutto = 0;
|
||||
my $sumgeb_bank = 0;
|
||||
if($ctpos->{int01}){
|
||||
$invoice_brutto = $ctpos->{int01};
|
||||
#substract TeilRad Gebühren
|
||||
if($ctpos->{int08} && $ctpos->{int08} > 0){
|
||||
$invoice_brutto -= $ctpos->{int08};
|
||||
}
|
||||
#substract Bank Gebühren
|
||||
if($ctpos->{int07} && $ctpos->{int07} > 0){
|
||||
$invoice_brutto -= $ctpos->{int07};
|
||||
$sumgeb_bank -= $ctpos->{int07};
|
||||
}
|
||||
$oac->{int99} = $invoice_brutto;
|
||||
#invoice capture netto
|
||||
$oac->{int01} = $invoice_brutto / 119 * 100;
|
||||
}
|
||||
$oac->{int01} = sprintf('%.2f', $oac->{int01});
|
||||
|
||||
|
||||
foreach(@tplf_order){
|
||||
my ($key,$val,$size) = split /=/,$_;
|
||||
if($key =~ /int/){
|
||||
my $invoice_brutto = 0;
|
||||
if($key eq "int01" && $ctpos->{int01}){
|
||||
$invoice_brutto = $ctpos->{int01};
|
||||
#substract TeilRad Gebühren
|
||||
$invoice_brutto = $ctpos->{int01} - $ctpos->{int08} if($ctpos->{int08} && $ctpos->{int08} > 0);
|
||||
#substract Bank Gebühren
|
||||
$invoice_brutto = $ctpos->{int01} - $ctpos->{int07} if($ctpos->{int07} && $ctpos->{int07} > 0);
|
||||
$oac->{int99} = $invoice_brutto;
|
||||
#invoice capture netto
|
||||
$oac->{int01} = $invoice_brutto / 119 * 100;
|
||||
}
|
||||
$oac->{int01} = sprintf('%.2f', $oac->{int01});
|
||||
|
||||
if($ctpos->{state} =~ /Lastschrift|Überweisung/){
|
||||
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#7,5%
|
||||
if($ctpos->{state} =~ /Zahlungsausfall/){
|
||||
$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/){
|
||||
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#Entgelt TeilRad
|
||||
$oac->{int93} = sprintf('%.3f', $oac->{int93});
|
||||
$oac->{int98} = $oac->{int93} * 0.19 if($oac->{int93});#UmSt auf 7,5%
|
||||
$oac->{int98} = sprintf('%.3f', $oac->{int98});
|
||||
$oac->{int94} = $oac->{int01} / 100 * $ctf->{$key} * -1 if($key eq "int02");#po Disagio %
|
||||
$oac->{int94} = sprintf('%.3f', $oac->{int94});
|
||||
$oac->{int95} = $ctf->{$key} * -1 if($key eq "int04");#po Trans
|
||||
|
@ -556,11 +570,10 @@ sub operator_accounting2calc {
|
|||
$oac->{int96} = sprintf('%.3f', $oac->{int96});
|
||||
$oac->{int97} = 0;
|
||||
}
|
||||
|
||||
if($ctpos->{state} =~ /Kreditkarte/){
|
||||
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#7,5%
|
||||
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#Entgelt TeilRad
|
||||
$oac->{int93} = sprintf('%.3f', $oac->{int93});
|
||||
$oac->{int98} = $oac->{int93} * 0.19 if($oac->{int93});#UmSt auf 7,5%
|
||||
$oac->{int98} = sprintf('%.3f', $oac->{int98});
|
||||
$oac->{int94} = $oac->{int01} / 100 * $ctf->{$key} * -1 if($key eq "int03");#po Disagio %
|
||||
$oac->{int94} = sprintf('%.3f', $oac->{int94});
|
||||
$oac->{int95} = $ctf->{$key} * -1 if($key eq "int05");#po Trans
|
||||
|
@ -570,16 +583,19 @@ sub operator_accounting2calc {
|
|||
$oac->{int97} = $ctf->{$key} * -1 if($key eq "int07");#po CC Zuordnung
|
||||
$oac->{int97} = sprintf('%.3f', $oac->{int97});
|
||||
}
|
||||
#operator accounting
|
||||
$oac->{int02} = $oac->{int01} + $oac->{int94} + $oac->{int95} + $oac->{int96} + $oac->{int97};
|
||||
$oac->{int02} = sprintf('%.3f', $oac->{int02});
|
||||
#operator invoice
|
||||
#$oac->{int100} = $oac->{int93} + $oac->{int98};#brutto
|
||||
$oac->{int100} = $oac->{int93};#netto
|
||||
$oac->{int100} = sprintf('%.3f', $oac->{int100});
|
||||
}
|
||||
}
|
||||
|
||||
#operator accounting
|
||||
$oac->{int02} = $oac->{int01} + $oac->{int94} + $oac->{int95} + $oac->{int96} + $oac->{int97};
|
||||
$oac->{int02} = sprintf('%.3f', $oac->{int02});
|
||||
#operator invoice
|
||||
$oac->{int100} = $oac->{int93};#netto
|
||||
$oac->{int100} = sprintf('%.3f', $oac->{int100});
|
||||
|
||||
print FILE "oac:\n" . Dumper($oac) . "\n" if($debug);
|
||||
close(FILE) if($debug);
|
||||
|
||||
return $oac;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,16 +111,6 @@ sub delete_account {
|
|||
return "$i_rows-$u_rows-$d_rows";
|
||||
}
|
||||
|
||||
|
||||
sub check_account(){
|
||||
my $self = shift;
|
||||
my ($column2,$op2,$content2,$column3,$op3,$content3) = @_;
|
||||
my $table = "contentadr";
|
||||
$content2 = $q->escapeHTML("$content2");
|
||||
my $account_check = $db->get_like2sort("contentadr","","","$column2","$op2","$content2","$column3","$op3","$content3");
|
||||
return $account_check;
|
||||
}
|
||||
|
||||
#create_account is alwas done on primary first
|
||||
sub create_account(){
|
||||
my $self = shift;
|
||||
|
@ -440,8 +430,17 @@ sub save_account(){
|
|||
if($valxx !~ /\w\@\w/){
|
||||
$ret = "failure::$_#top";
|
||||
}else{
|
||||
my $account_check = &check_account("","txt08","ilike",$valxx,"c_id","!=",$c_id);
|
||||
print FILE "$account_check->{c_id} && $account_check->{c_id} != $c_id\n" if($debug);
|
||||
my $pref_ac = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
txt08 => "ilike::$valxx",
|
||||
c_id => "!=::$c_id",
|
||||
order => "mtime",
|
||||
};
|
||||
my $account_check = $dbt->fetch_tablerecord($dbh,$pref_ac);
|
||||
#my $account_check = $self->check_account("txt08","ilike",$valxx,"c_id","!=",$c_id);
|
||||
|
||||
print FILE "account_check email:$valxx, c_id:$account_check->{c_id} && $account_check->{c_id} != $c_id\n" if($debug);
|
||||
if($account_check->{c_id} && $account_check->{c_id} != $c_id){
|
||||
my $encoded_val = $uri_encode->encode($valxx);
|
||||
$ret_conflict = "failure::conflict_$_=$encoded_val#top";
|
||||
|
@ -525,6 +524,22 @@ sub save_account(){
|
|||
|
||||
my $vde_on_fail = $ctadr->{int12} || 3;#keep last or set 3
|
||||
|
||||
#check if iban from another user has Vde
|
||||
my $pref_ac = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
txt22 => "$iban",
|
||||
int12 => ">=::1",
|
||||
c_id => "!=::$c_id",
|
||||
order => "mtime",
|
||||
};
|
||||
my $account_check = $dbt->fetch_tablerecord($dbh,$pref_ac);
|
||||
print FILE "account_check iban:$iban, c_id:$account_check->{c_id} && $account_check->{c_id} != $c_id\n" if($debug);
|
||||
if($account_check->{c_id} && $account_check->{c_id} != $c_id){
|
||||
my $encoded_val = $uri_encode->encode($iban);
|
||||
$ret_conflict = "failure::conflict_txt22=$encoded_val#top";
|
||||
}
|
||||
|
||||
my $payone_mival = $payone->managemandate_main(\%varenv,$ctadr,"",$owner);
|
||||
if($payone_mival && $payone_mival =~ /\w{2}-\d+/){
|
||||
#define fictiv invoice to get 1 € test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue