X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=a8937506f6356b0626e3ad20e142f39ee57b9aff;hb=2e7983737542b36d9962073a7d04f2edcf6b8bb0;hp=a6ecec82fcf626c15d1dd0c8cf44b9e650921426;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index a6ecec82f..a8937506f 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -31,15 +31,22 @@ # #====================================================================== +use POSIX qw(strftime); +use List::Util qw(sum first); use SL::AR; +use SL::FU; 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"; -1; -# end of main +use strict; +#use warnings; # this is for our long dates # $locale->text('January') @@ -69,61 +76,97 @@ require "$form->{path}/arap.pl"; # $locale->text('Nov') # $locale->text('Dec') +my $totalpaid; sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + 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}; + # saving the history + if(!exists $form->{addition} && ($form->{id} ne "")) { + $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{addition} = "ADDED"; + $form->save_history($form->dbconnect(\%myconfig)); + } + # /saving the history + + $form->{title} = "Add"; + $form->{callback} = "ar.pl?action=add" unless $form->{callback}; + AR->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(); + $main::auth->assert('general_ledger'); + my $form = $main::form; + + # show history button + $form->{javascript} = qq||; + #/show hhistory button + $form->{javascript} .= qq||; $form->{title} = "Edit"; &create_links; &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } - sub display_form { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + my $form = $main::form; &form_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } - sub create_links { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + my $form = $main::form; + my %myconfig = %main::myconfig; + + my ($duedate, $taxincluded, @curr); $form->create_links("AR", \%myconfig, "customer"); $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->{duedate} = $duedate if $duedate; $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; + $form->{rowcount} = 1; + + # notes + $form->{notes} = $form->{intnotes} unless $form->{notes}; # currencies - @curr = split /:/, $form->{currencies}; + @curr = split(/:/, $form->{currencies}); chomp $curr[0]; $form->{defaultcurrency} = $curr[0]; @@ -132,139 +175,57 @@ sub create_links { # customers if (@{ $form->{all_customer} }) { $form->{customer} = "$form->{customer}--$form->{customer_id}"; - map { $form->{selectcustomer} .= "\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 "AR_paid") { - $j++; - $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; - # reverse paid - $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{amount} * -1; - $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->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}"; - $form->{paidaccounts}++; - } else { - - $akey = $key; - $akey =~ s/AR_//; - - if ($key eq "AR_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, 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"}; - } - - } else { - $form->{"${akey}_$i"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate, 2); - if ($akey eq 'amount') { - $form->{rowcount}++; - $totalamount += $form->{"${akey}_$i"}; - - $form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}"; - $form->{taxrate} = $form->{acc_trans}{$key}->[$i-1]->{rate}; - $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->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; - $form->{"select${key}"} =~ /(