-
- $form->{title} |
-
-
-
-
-
- |
-
-
-$jsscript
- {rowcount}>
-
-
-
-
- |
- . $locale->text('Account') . qq| |
- |
- . $locale->text('Amount') . qq| |
- |
- . $locale->text('Tax') . qq| |
- |
- . $locale->text('Korrektur') . qq| |
- |
- . $locale->text('Taxkey') . qq| |
- |
- . $locale->text('Project') . qq| |
-
-|;
-
- $amount = $locale->text('Amount');
- $project = $locale->text('Project');
+# $amount = $locale->text('Amount');
+# $project = $locale->text('Project');
+ my @transactions;
for my $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);
+ my $transaction = {
+ amount => $form->{"amount_$i"},
+ tax => $form->{"tax_$i"},
+ project_id => ($i==$form->{rowcount}) ? $form->{globalproject_id} : $form->{"project_id_$i"},
+ };
my $selected_accno_full;
my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
@@ -578,347 +350,169 @@ $jsscript
$selected_taxchart = "$item->{id}--$item->{rate}";
}
- $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
+ if (!$form->{"taxchart_$i"}) {
+ if ($form->{"AR_amount_$i"} =~ m/.--./) {
+ $selected_taxchart = join '--', map { ($_->{id}, $_->{rate}) } first { $_->{id} == $item->{tax_id} } @{ $form->{ALL_TAXCHARTS} };
+ } else {
+ $selected_taxchart = $taxchart_init;
+ }
+ }
- $selectAR_amount =
+ $transaction->{selectAR_amount} =
NTI($cgi->popup_menu('-name' => "AR_amount_$i",
'-id' => "AR_amount_$i",
'-style' => 'width:400px',
'-onChange' => "setTaxkey(this, $i)",
'-values' => \@AR_amount_values,
- '-labels' => \%AR_amount_labels,
+ '-labels' => \%chart_labels,
'-default' => $selected_accno_full))
. $cgi->hidden('-name' => "previous_AR_amount_$i",
'-default' => $selected_accno_full);
- $tax = qq|| .
+ $transaction->{taxchart} =
NTI($cgi->popup_menu('-name' => "taxchart_$i",
'-id' => "taxchart_$i",
'-style' => 'width:200px',
'-values' => \@taxchart_values,
'-labels' => \%taxchart_labels,
- '-default' => $selected_taxchart))
- . qq| | |;
-
- $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
-
- my $projectnumber =
- NTI($cgi->popup_menu('-name' => "project_id_$i",
- '-values' => \@project_values,
- '-labels' => \%project_labels,
- '-default' => $form->{"project_id_$i"} ));
-
- print qq|
-
- $selectAR_amount |
- {"amount_$i"}> |
- {"tax_$i"}> |
- |
- $tax
- $projectnumber |
-
-|;
- $amount = "";
- $project = "";
+ '-default' => $selected_taxchart));
+
+ push @transactions, $transaction;
}
$form->{invtotal_unformatted} = $form->{invtotal};
- $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
$ARselected =
NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
'-style' => 'width:400px',
- '-values' => \@AR_values, '-labels' => \%AR_labels,
+ '-values' => \@AR_values, '-labels' => \%chart_labels,
'-default' => $form->{ARselected}));
- print qq|
-
-
-
- |
-
-
- ${ARselected} |
- $form->{invtotal} |
-
- {oldinvtotal}>
- {oldtotalpaid}>
-
-
-
- |
-
-
-
-
- |
-
-
-
-
-
- | . $locale->text('Notes') . qq| |
- $notes |
-
-
- |
-
-
-
-
-
- |
- . $locale->text('Incoming Payments') . qq| |
-
-|;
- if ($form->{currency} eq $form->{defaultcurrency}) {
- @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
- } else {
- @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
- }
+ $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
- $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') . " | ";
- $column_data{paid_project_id} = "" . $locale->text('Project Number') . " | ";
-
- print "
-
-";
- map { print "$column_data{$_}\n" } @column_index;
- print "
-
-";
-
- my @triggers = ();
- my $totalpaid = 0;
+ my $now = $form->current_date(\%myconfig);
- $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
+ my @payments;
for my $i (1 .. $form->{paidaccounts}) {
- print "
-
-";
-
- $selectAR_paid =
+ 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"},
+ };
+
+ # 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",
'-id' => "AR_paid_$i",
'-values' => \@AR_paid_values,
- '-labels' => \%AR_paid_labels,
- '-default' => $form->{"AR_paid_$i"}));
+ '-labels' => \%chart_labels,
+ '-default' => $payment->{AR_paid} || $form->{accno_arap}));
- $totalpaid += $form->{"paid_$i"};
- # 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"});
-
- if ($form->{"exchangerate_$i"} == 0) {
- $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"}>|;
- }
- }
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
+ $payment->{changeable} =
+ SL::DB::Default->get->payments_changeable == 0 ? !$payment->{acc_trans_id} # never
+ : SL::DB::Default->get->payments_changeable == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now
+ : 1;
- $column_data{paid} =
- qq| | |;
- $column_data{AR_paid} =
- qq|${selectAR_paid} | |;
- $column_data{exchangerate} = qq|$exchangerate | |;
- $column_data{datepaid} =
- qq|
- | |;
- $column_data{source} =
- qq| | |;
- $column_data{memo} =
- qq| | |;
-
- $column_data{paid_project_id} =
- qq||
- . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
- '-values' => \@project_values,
- '-labels' => \%project_labels,
- '-default' => $form->{"paid_project_id_$i"} ))
- . qq| | |;
-
- map { print qq|$column_data{$_}\n| } @column_index;
-
- print "
-
-";
- push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
+ push @payments, $payment;
}
- my $paid_missing = $form->{invtotal_unformatted} - $totalpaid;
+ $form->{totalpaid} = sum map { $_->{paid} } @payments;
- print qq|
-
- |
- |
- | . $locale->text('Total') . qq| |
- | . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq| |
-
-
- |
- |
- | . $locale->text('Missing amount') . qq| |
- | . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq| |
-
-| . $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
- qq|
-{paidaccounts}>
-
-
- |
-
-
-
|
-
-
-|;
-
- $lxdebug->leave_sub();
+ $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,
+ title_str => $title,
+ follow_up_trans_info => $follow_up_trans_info,
+ });
+
+ $main::lxdebug->leave_sub();
}
sub form_footer {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
- $auth->assert('general_ledger');
+ $main::auth->assert('general_ledger');
- my ($transdate, $closedto);
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+ my $cgi = $::request->{cgi};
- my $follow_ups_block;
- if ($form->{id}) {
+ if ( $form->{id} ) {
my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
-
- 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|
|;
+ if ( @{ $follow_ups} ) {
+ $form->{follow_up_length} = scalar(@{$follow_ups});
+ $form->{follow_up_due_length} = sum(map({ $_->{due} * 1 } @{ $follow_ups }));
}
}
- print qq|
-
-$follow_ups_block
-
-