# setup last accounts used for this customer
if (!$form->{id} && $form->{type} !~ /_(order|quotation)/) {
- $query = qq|SELECT c.accno, c.description, c.link, c.category
+ $query = qq|SELECT c.id, c.accno, c.description, c.link, c.category
FROM chart c
JOIN acc_trans ac ON (ac.chart_id = c.id)
JOIN ar a ON (a.id = ac.trans_id)
if ($ref->{category} eq 'I') {
$i++;
$form->{"AR_amount_$i"} = "$ref->{accno}--$ref->{description}";
+
+ if ($form->{initial_transdate}) {
+ my $tax_query =
+ qq|SELECT tk.tax_id, t.rate FROM taxkeys tk | .
+ qq|LEFT JOIN tax t ON tk.tax_id = t.id | .
+ qq|WHERE tk.chart_id = ? AND startdate <= ? | .
+ qq|ORDER BY tk.startdate DESC LIMIT 1|;
+ my ($tax_id, $rate) =
+ selectrow_query($form, $dbh, $tax_query, $ref->{id},
+ $form->{initial_transdate});
+ $form->{"taxchart_$i"} = "${tax_id}--${rate}";
+ }
}
if ($ref->{category} eq 'A') {
$form->{ARselected} = $form->{AR_1} = $ref->{accno};
"$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();
}
}
}
- $lxdebug->message(0, "1 ARselected $form->{ARselected}");
-
$form->{taxincluded} = $taxincluded if ($form->{id});
$form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
if ($previous_accno &&
($previous_accno eq $selected_accno) &&
($previous_tax_id ne $selected_tax_id)) {
- $lxdebug->message(0, "yeah");
my $item = $taxcharts{$selected_tax_id};
$selected_taxchart = "$item->{id}--$item->{rate}";
}
if ($previous_accno &&
($previous_accno eq $selected_accno) &&
($previous_tax_id ne $selected_tax_id)) {
- $lxdebug->message(0, "yeah");
my $item = $taxcharts{$selected_tax_id};
$selected_taxchart = "$item->{id}--$item->{rate}";
}