#======================================================================
use POSIX qw(strftime);
-use List::Util qw(sum);
+use List::Util qw(sum first);
use SL::AR;
use SL::FU;
<table>
<tr>
<th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
- <td colspan=3>$customer <input type="button" value="?" onclick="show_vc_details('customer')"></td>
+ <td colspan=3>$customer <input type="button" value="| . $locale->text('Details (one letter abbreviation)') . qq|" onclick="show_vc_details('customer')"></td>
<input type=hidden name=selectcustomer value="$form->{selectcustomer}">
<input type=hidden name=oldcustomer value="$form->{oldcustomer}">
<input type=hidden name=customer_id value="$form->{customer_id}">
$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 =
NTI($cgi->popup_menu('-name' => "AR_amount_$i",
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
print qq| <input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
- if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar'));
+ if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($total_paid == 0) || ($total_paid eq "")));
if ($form->{id}) {
if ($form->{radier}) {
$form->{invtotal} = 0;
+ delete @{ $form }{ grep { m/^tax_\d+$/ } keys %{ $form } };
+
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
$form->{exchangerate} = $form->{forex} if $form->{forex};
$form->{invdate} = $form->{transdate};
- my $save_AR = $form->{AR};
- check_name("customer");
- $form->{AR} = $save_AR;
+
+ $form->{invdate} = $form->{transdate};
+
+ my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1);
+
+ &check_name("customer");
+
+ $form->{AR} = $saved_variables{AR};
+ if ($saved_variables{AR_amount_1} =~ m/.--./) {
+ map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1);
+ } else {
+ delete $form->{taxchart_1};
+ }
$form->{invtotal} =
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;