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";
$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();
my %myconfig = %main::myconfig;
$form->create_links("AR", \%myconfig, "customer");
+ $form->{invoice_obj} = _retrieve_invoice_object();
my %saved;
if (!$params{dont_save}) {
my $locale = $main::locale;
my $cgi = $::request->{cgi};
+ $form->{invoice_obj} = _retrieve_invoice_object();
+
my ($title, $readonly, $exchangerate, $rows);
my ($notes, $department, $customer, $employee, $amount, $project);
my ($ARselected);
gldate => $form->{"gldate_$i"},
};
- # default account for current assets (i.e. 1801 - SKR04) if no account is selected
- $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
+ # default account for current assets (i.e. 1801 - SKR04) if no account is selected
+ $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form);
$payment->{selectAR_paid} =
NTI($cgi->popup_menu('-name' => "AR_paid_$i",
push @payments, $payment;
}
+ my @empty = grep { $_->{paid} eq '' } @payments;
+ @payments = (
+ (sort_by { DateTime->from_kivitendo($_->{datepaid}) } grep { $_->{paid} ne '' } @payments),
+ @empty,
+ );
+
$form->{totalpaid} = sum map { $_->{paid} } @payments;
$form->header;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
+ $form->mtime_ischanged('ar');
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
my $invdate = $form->datetonum($form->{transdate}, \%myconfig);
my ($inline) = @_;
+ $form->mtime_ischanged('ar');
+
my ($datepaid);
# check if there is an invoice number, invoice and due date
@columns =
qw(transdate id type invnumber ordnumber cusordnumber name netamount tax amount paid
datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia
- marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype direct_debit);
+ marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype direct_debit dunning_description);
my $ct_cvar_configs = CVar->get_configs('module' => 'CT');
my @ct_includeable_custom_variables = grep { $_->{includeable} } @{ $ct_cvar_configs };
'charts' => { 'text' => $locale->text('Buchungskonto'), },
'customertype' => { 'text' => $locale->text('Customer type'), },
'direct_debit' => { 'text' => $locale->text('direct debit'), },
+ dunning_description => { 'text' => $locale->text('Dunning level'), },
%column_defs_cvars,
);