X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=af47235a933f49ecc395998042a480781e280d9e;hb=15f549fdb43fba2d99817c659533dfa02638bf27;hp=2451cc1a4d9f5c3407a91bb39546824519e8937d;hpb=d319704a66e9be64da837ccea10af6774c2b0838;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 2451cc1a4..af47235a9 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -34,8 +34,11 @@ use SL::AR; use SL::IS; use SL::PE; +use Data::Dumper; require "$form->{path}/arap.pl"; +require "bin/mozilla/common.pl"; +require "bin/mozilla/drafts.pl"; 1; @@ -72,19 +75,31 @@ require "$form->{path}/arap.pl"; sub add { $lxdebug->enter_sub(); + return $lxdebug->leave_sub() if (load_draft_maybe()); + + # saving the history + if(!exists $form->{addition} && ($form->{id} ne "")) { + $form->{addition} = "ADDED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + $form->{title} = "Add"; $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; &create_links; + AR->get_transdate(\%myconfig, $form); &display_form; - $lxdebug->leave_sub(); } sub edit { $lxdebug->enter_sub(); + # show history button + $form->{javascript} = qq||; + #/show hhistory button $form->{title} = "Edit"; @@ -110,14 +125,17 @@ sub create_links { $duedate = $form->{duedate}; $taxincluded = $form->{taxincluded}; - + my $id = $form->{id}; IS->get_customer(\%myconfig, \%$form); + $form->{taxincluded} = $taxincluded; + $form->{id} = $id; $form->{duedate} = $duedate if $duedate; $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; + $form->{rowcount} = 1; # currencies - @curr = split /:/, $form->{currencies}; + @curr = split(/:/, $form->{currencies}); chomp $curr[0]; $form->{defaultcurrency} = $curr[0]; @@ -155,7 +173,7 @@ sub create_links { map { $tax .= - qq|\n"; } else { $form->{"select$key"} .= - "\n"; + "\n"; } } $form->{$key} = $form->{"select$key"}; # if there is a value we have an old entry - $j = 0; + my $j = 0; + my $k = 0; + for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) { if ($key eq "AR_paid") { $j++; @@ -196,13 +216,14 @@ sub create_links { $form->{"forex_$j"} = $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{exchangerate}; $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}"; + $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id}; $form->{paidaccounts}++; } else { $akey = $key; $akey =~ s/AR_//; - if ($key eq "AR_tax") { + if ($key eq "AR_tax" || $key eq "AP_tax") { $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = @@ -221,9 +242,13 @@ sub create_links { $withholdingrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"}; } + $index = $form->{acc_trans}{$key}->[$i - 1]->{index}; + $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount}; + $totaltax += $form->{"tax_$index"}; } else { - $form->{"${akey}_$i"} = + $k++; + $form->{"${akey}_$k"} = $form->round_amount( $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate, 2); @@ -231,24 +256,25 @@ sub create_links { $form->{rowcount}++; $totalamount += $form->{"${akey}_$i"}; - $form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} = + $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}"; $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate}; - $form->{"project_id_$i"} = + $form->{"project_id_$k"} = "$form->{acc_trans}{$key}->[$i-1]->{project_id}"; } - $form->{"${key}_$i"} = + $form->{"${key}_$k"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; $form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; + my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description}); $form->{"select${key}"} =~ - /(