-
-
-
- |
- . $locale->text('Account') . qq| |
- |
- . $locale->text('Amount') . qq| |
- |
- . $locale->text('Tax') . qq| |
- |
- . $locale->text('Korrektur') . qq| |
- |
- . $locale->text('Taxkey') . qq| |
- |
- . $locale->text('Project') . qq| |
-
-|;
+ $ARselected =
+ NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
+ '-style' => 'width:400px',
+ '-values' => \@AR_values, '-labels' => \%chart_labels,
+ '-default' => $form->{ARselected}));
- $amount = $locale->text('Amount');
- $project = $locale->text('Project');
-
- for $i (1 .. $form->{rowcount}) {
-
- # format amounts
- $form->{"amount_$i"} =
- $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
- $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
- $selectAR_amount = $selectAR_amount_unquoted;
- $selectAR_amount =~
- s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
- $tax = $taxchart;
- $tax_selected = $form->{"taxchart_$i"};
- $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
- $tax =
- qq| | |;
- $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
- print qq|
-
- |
- {"amount_$i"}> |
- {"tax_$i"}> |
- |
- $tax
-
- {"project_id_$i"}>
- |
-
-|;
- $amount = "";
- $project = "";
+ $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
+
+ my $now = $form->current_date(\%myconfig);
+
+ my @payments;
+ for my $i (1 .. $form->{paidaccounts}) {
+ my $payment = {
+ paid => $form->{"paid_$i"},
+ exchangerate => $form->{"exchangerate_$i"} || '',
+ gldate => $form->{"gldate_$i"},
+ acc_trans_id => $form->{"acc_trans_id_$i"},
+ source => $form->{"source_$i"},
+ memo => $form->{"memo_$i"},
+ AR_paid => $form->{"AR_paid_$i"},
+ forex => $form->{"forex_$i"},
+ datepaid => $form->{"datepaid_$i"},
+ paid_project_id => $form->{"paid_project_id_$i"},
+ gldate => $form->{"gldate_$i"},
+ };
+
+ $payment->{selectAR_paid} =
+ NTI($cgi->popup_menu('-name' => "AR_paid_$i",
+ '-id' => "AR_paid_$i",
+ '-values' => \@AR_paid_values,
+ '-labels' => \%chart_labels,
+ '-default' => $payment->{AR_paid}));
+
+
+
+ $payment->{changeable} =
+ $::lx_office_conf{features}->{payments_changeable} == 0 ? !$payment->{acc_trans_id} # never
+ : $::lx_office_conf{features}->{payments_changeable} == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now
+ : 1;
+
+ push @payments, $payment;
}
- $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
+ $form->{totalpaid} = sum map { $_->{paid} } @payments;
- print qq|
-
-
-
- |
-
-
- |
-
- $form->{invtotal} |
-
- {oldinvtotal}>
- {oldtotalpaid}>
-
-
-
- |
-
-
-
-
- |
-
-
-
-
-
- |
- . $locale->text('Incoming Payments') . qq| |
-
-|;
+ $form->header;
+ print $::form->parse_html_template('ar/form_header', {
+ paid_missing => $::form->{invtotal} - $::form->{totalpaid},
+ show_exch => ($::form->{defaultcurrency} && ($::form->{currency} ne $::form->{defaultcurrency})),
+ payments => \@payments,
+ transactions => \@transactions,
+ project_labels => \%project_labels,
+ rows => $rows,
+ ARselected => $ARselected,
+ onload => $onload,
+ title_str => $title,
+ follow_up_trans_info => $follow_up_trans_info,
+ });
+
+ $main::lxdebug->leave_sub();
+}
- if ($form->{currency} eq $form->{defaultcurrency}) {
- @column_index = qw(datepaid source memo paid AR_paid);
- } else {
- @column_index = qw(datepaid source memo paid exchangerate AR_paid);
- }
+sub form_footer {
+ $main::lxdebug->enter_sub();
- $column_data{datepaid} = "" . $locale->text('Date') . " | ";
- $column_data{paid} = "" . $locale->text('Amount') . " | ";
- $column_data{exchangerate} = "" . $locale->text('Exch') . " | ";
- $column_data{AR_paid} = "" . $locale->text('Account') . " | ";
- $column_data{source} = "" . $locale->text('Source') . " | ";
- $column_data{memo} = "" . $locale->text('Memo') . " | ";
+ $main::auth->assert('general_ledger');
- print "
-
-";
- map { print "$column_data{$_}\n" } @column_index;
- print "
-
-";
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+ my $cgi = $::request->{cgi};
- $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
- for $i (1 .. $form->{paidaccounts}) {
- print "
-
-";
+ my ($transdate, $closedto);
- $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
- $form->{"selectAR_paid_$i"} =~
- s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
+ my $follow_ups_block;
+ if ($form->{id}) {
+ my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
- # format amounts
- if ($form->{"paid_$i"}) {
- $form->{"paid_$i"} =
- $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
- }
- $form->{"exchangerate_$i"} =
- $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
-
- $exchangerate = qq| |;
- if ($form->{currency} ne $form->{defaultcurrency}) {
- if ($form->{"forex_$i"}) {
- $exchangerate =
- qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
- } else {
- $exchangerate =
- qq|{"exchangerate_$i"}>|;
- }
+ if (@{ $follow_ups} ) {
+ my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups };
+ $follow_ups_block = qq|| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq| |;
}
-
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
-
- $column_data{paid} =
- qq|{"paid_$i"}> | |;
- $column_data{AR_paid} =
- qq| | |;
- $column_data{exchangerate} = qq|$exchangerate | |;
- $column_data{datepaid} =
- qq|{"datepaid_$i"}> | |;
- $column_data{source} =
- qq| | |;
- $column_data{memo} =
- qq| | |;
-
- map { print qq|$column_data{$_}\n| } @column_index;
-
- print "
-
-";
}
- map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
- print qq|
-{paidaccounts}>
-
-
-
- |
-
-