X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=e6265e02067e0232cc98ad200efb3898fa6fb8b0;hb=f7b15d4334848fad1bcd0b569eff5139f9a6ba4d;hp=64efbc7e6625e1b3d4d435fd57b311a60a998d5a;hpb=0e68056cbc17b531266c16454f3a74ae1e57dea6;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 64efbc7e6..e6265e020 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -24,7 +24,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # Accounts Receivables @@ -33,17 +34,18 @@ use POSIX qw(strftime); use List::Util qw(sum first max); +use List::UtilsBy qw(sort_by); use SL::AR; use SL::FU; use SL::IS; use SL::PE; use SL::DB::Default; +use SL::DB::Invoice; use SL::ReportGenerator; require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; -require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; use strict; @@ -80,13 +82,11 @@ use strict; sub add { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; my %myconfig = %main::myconfig; - return $main::lxdebug->leave_sub() if (load_draft_maybe()); - # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; @@ -96,7 +96,7 @@ sub add { # /saving the history $form->{title} = "Add"; - $form->{callback} = "ar.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; + $form->{callback} = "ar.pl?action=add" unless $form->{callback}; AR->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; @@ -109,7 +109,7 @@ sub add { sub edit { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; @@ -128,7 +128,7 @@ sub edit { sub display_form { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my $form = $main::form; @@ -138,21 +138,29 @@ sub display_form { $main::lxdebug->leave_sub(); } +sub _retrieve_invoice_object { + return undef if !$::form->{id}; + return $::form->{invoice_obj} if $::form->{invoice_obj} && $::form->{invoice_obj}->id == $::form->{id}; + return SL::DB::Invoice->new(id => $::form->{id})->load; +} + sub create_links { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); + $main::auth->assert('ar_transactions'); my %params = @_; my $form = $main::form; my %myconfig = %main::myconfig; $form->create_links("AR", \%myconfig, "customer"); + $form->{invoice_obj} = _retrieve_invoice_object(); my %saved; if (!$params{dont_save}) { %saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded); $saved{duedate} = $form->{duedate} if $form->{duedate}; + $saved{currency} = $form->{currency} if $form->{currency}; } IS->get_customer(\%myconfig, \%$form); @@ -164,6 +172,7 @@ sub create_links { # currencies $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + $form->{selectcurrency} = ""; map { $form->{selectcurrency} .= "