X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fap.pl;h=9fa038fd457ca25bb6b616af652d764bbc73beb2;hb=dc8f62cf5df4a7f8473e7d76fdd98846cea5721f;hp=ec0ee53c1d3a85c39b89e1b8b6ffab3276522919;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index ec0ee53c1..a6d5cdc5c 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -31,16 +31,26 @@ # #====================================================================== +use POSIX qw(strftime); +use List::Util qw(sum); use SL::AP; +use SL::FU; use SL::IR; +use SL::IS; use SL::PE; +use SL::ReportGenerator; -require "$form->{path}/arap.pl"; +require "bin/mozilla/arap.pl"; +require "bin/mozilla/common.pl"; +require "bin/mozilla/drafts.pl"; +require "bin/mozilla/reportgenerator.pl"; + +use strict; 1; -# end of main +# end of main # this is for our long dates # $locale->text('January') @@ -70,301 +80,341 @@ require "$form->{path}/arap.pl"; # $locale->text('Nov') # $locale->text('Dec') - sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('general_ledger'); + return $main::lxdebug->leave_sub() if (load_draft_maybe()); $form->{title} = "Add"; - - $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; + $form->{callback} = "ap.pl?action=add" unless $form->{callback}; + + AP->get_transdate(\%myconfig, $form); + $form->{initial_transdate} = $form->{transdate}; &create_links; + $form->{transdate} = $form->{initial_transdate}; &display_form; - - $lxdebug->leave_sub(); -} + $main::lxdebug->leave_sub(); +} sub edit { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + $main::auth->assert('general_ledger'); - $form->{title} = "Edit"; &create_links; &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } - sub display_form { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + $main::auth->assert('general_ledger'); - &form_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } - sub create_links { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + $main::auth->assert('general_ledger'); $form->create_links("AP", \%myconfig, "vendor"); - $taxincluded = $form->{taxincluded}; - $duedate = $form->{duedate}; + my $taxincluded = $form->{taxincluded}; + my $duedate = $form->{duedate}; IR->get_vendor(\%myconfig, \%$form); - - $form->{duedate} = $duedate if $duedate; + $form->{taxincluded} = $taxincluded; + $form->{duedate} = $duedate if $duedate; $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}"; - + $form->{rowcount} = 1; + # build the popup menus $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked"; - - map { $tax .= qq|\n"; - } else { - $form->{"select$key"} .= "\n"; - } - } - - $form->{$key} = $form->{"select$key"}; - # if there is a value we have an old entry - $j = 0; - for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) { - - if ($key eq "AP_paid") { - $j++; - $form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; - $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{amount}; - $form->{"datepaid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{transdate}; - $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i-1]->{source}; - $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i-1]->{memo}; - - $form->{"forex_$j"} = $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i-1]->{exchangerate}; - $form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}"; - $form->{paidaccounts}++; - } else { + $form->{employee} = "$form->{employee}--$form->{employee_id}"; - $akey = $key; - $akey =~ s/AP_//; - - if ($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}"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate * -1, 2); - if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) { - $totaltax += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"}; - $taxrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"}; - } else { - $totalwithholding += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"}; - $withholdingrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"}; - } - $formtax = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate, 2) *-1; - } else { - $form->{"${akey}_$i"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate, 2); - if ($akey eq 'amount') { - $form->{"${akey}_$i"} *= -1; - $totalamount += $form->{"${akey}_$i"}; - $form->{taxrate} = $form->{acc_trans}{$key}->[$i-1]->{rate}; - $form->{rowcount}++; - $form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}"; - $form->{"project_id_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{project_id}"; - } - $form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; - $form->{"select${key}"} =~ /(