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,"");