"$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
unless $form->{callback};
- &create_links;
AR->get_transdate(\%myconfig, $form);
+ $form->{initial_transdate} = $form->{transdate};
+ &create_links;
+ $form->{transdate} = $form->{initial_transdate};
&display_form;
$lxdebug->leave_sub();
}
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
$form->{rowcount} = 1;
+ # notes
+ $form->{notes} = $form->{intnotes} unless $form->{notes};
+
# currencies
@curr = split(/:/, $form->{currencies});
chomp $curr[0];
}
}
- $lxdebug->message(0, "1 ARselected $form->{ARselected}");
-
$form->{taxincluded} = $taxincluded if ($form->{id});
$form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
}
}
- $taxincluded = "";
-
$taxincluded = qq|
<tr>
<td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
my (%AR_amount_labels, @AR_amount_values);
my (%AR_labels, @AR_values);
my (%AR_paid_labels, @AR_paid_values);
+ my %charts;
my $taxchart_init;
foreach my $item (@{ $form->{ALL_CHARTS} }) {
$AR_paid_labels{$item->{accno}} =
"$item->{accno}--$item->{description}";
}
+
+ $charts{$item->{accno}} = $item;
}
my %taxchart_labels = ();
my @taxchart_values = ();
+ my %taxcharts = ();
foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
my $key = "$item->{id}--$item->{rate}";
$taxchart_init = $key if ($taxchart_init eq $item->{id});
push(@taxchart_values, $key);
$taxchart_labels{$key} =
"$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
+ $taxcharts{$item->{id}} = $item;
}
$form->{fokus} = "arledger.customer";
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
+ my $selected_accno_full;
+ my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
+ my $item = $charts{$accno_row};
+ $selected_accno_full = "$item->{accno}--$item->{tax_id}";
+
+ my $selected_taxchart = $form->{"taxchart_$i"};
+ my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
+ my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"});
+
+ if ($previous_accno &&
+ ($previous_accno eq $selected_accno) &&
+ ($previous_tax_id ne $selected_tax_id)) {
+ my $item = $taxcharts{$selected_tax_id};
+ $selected_taxchart = "$item->{id}--$item->{rate}";
+ }
+
+ $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
+
$selectAR_amount =
NTI($cgi->popup_menu('-name' => "AR_amount_$i",
'-id' => "AR_amount_$i",
'-onChange' => "setTaxkey(this, $i)",
'-values' => \@AR_amount_values,
'-labels' => \%AR_amount_labels,
- '-default' => $form->{"AR_amount_$i"}));
+ '-default' => $selected_accno_full))
+ . $cgi->hidden('-name' => "previous_AR_amount_$i",
+ '-default' => $selected_accno_full);
$tax = qq|<td>| .
NTI($cgi->popup_menu('-name' => "taxchart_$i",
'-style' => 'width:200px',
'-values' => \@taxchart_values,
'-labels' => \%taxchart_labels,
- '-default' => $form->{"taxchart_$i"} eq "" ?
- $taxchart_init : $form->{"taxchart_$i"}))
+ '-default' => $selected_taxchart))
. qq|</td>|;
$korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
<br>
|;
+ if (!$form->{id} && $form->{draft_id}) {
+ print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
+ '-value' => 1, '-checked' => $form->{remove_draft},
+ '-label' => '')) .
+ qq| <label for="remove_draft">| .
+ $locale->text("Remove draft when posting") .
+ qq|</label><br>|);
+ }
+
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
$form->{AR}{receivables} = $form->{ARselected};
- $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
- unless $form->{invnumber};
-
$form->{id} = 0 if $form->{postasnew};
if (AR->post_transaction(\%myconfig, \%$form)) {
# saving the history