X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Far.pl;h=1b59d789e65cd703c612582f2c8e3f962fe98e11;hb=6768ddad54d2a675939e1167536f4943628de2bb;hp=a05a9717869dd96aa7471b0ab4be194de897089a;hpb=978c6f75abc1bbfded560f856b000e87cbe106bd;p=kivitendo-erp.git
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index a05a97178..1b59d789e 100644
--- a/bin/mozilla/ar.pl
+++ b/bin/mozilla/ar.pl
@@ -33,17 +33,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;
@@ -85,8 +86,6 @@ sub add {
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,11 +95,11 @@ 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};
- &create_links;
+ create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
&display_form;
$main::lxdebug->leave_sub();
@@ -119,7 +118,7 @@ sub edit {
$form->{javascript} .= qq||;
$form->{title} = "Edit";
- &create_links;
+ create_links();
&display_form;
$main::lxdebug->leave_sub();
@@ -138,17 +137,30 @@ 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');
+ my %params = @_;
my $form = $main::form;
my %myconfig = %main::myconfig;
$form->create_links("AR", \%myconfig, "customer");
+ $form->{invoice_obj} = _retrieve_invoice_object();
- my %saved = map { ($_ => $form->{$_}) } qw(direct_debit duedate id taxincluded);
+ 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);
@@ -159,6 +171,7 @@ sub create_links {
# currencies
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+ $form->{selectcurrency} = "";
map { $form->{selectcurrency} .= "