qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
source, memo, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT chart_id FROM tax WHERE id = ?),
- ?, ?, ?, ?, ?, ?, ?, (SELECT link FROM chart WHERE accno = ?))|;
+ ?, ?, ?, ?, ?, ?, ?, (SELECT link
+ FROM chart
+ WHERE id = (SELECT chart_id
+ FROM tax
+ WHERE id = ?)))|;
@values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}),
$tax, conv_date($form->{transdate}), $form->{"source_$i"},
$form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}), conv_i($form->{"tax_id_$i"}));
dbh => $dbh,
from => $transdate,
to => $transdate,
+ trans_id => $form->{id},
);
$datev->export;
push(@arvalues, '%' . $form->{description} . '%');
push(@apvalues, '%' . $form->{description} . '%');
}
-
- if ($form->{employee} =~ /--/) {
- ($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee});
- #if ($form->{employee_id}) {
+
+ if ($form->{employee_id}) {
$glwhere .= " AND g.employee_id = ? ";
$arwhere .= " AND a.employee_id = ? ";
$apwhere .= " AND a.employee_id = ? ";
}
}
- my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|;
-
my %sort_columns = (
'id' => [ qw(id) ],
'transdate' => [ qw(transdate id) ],
'source' => { 'gl' => 'ac.source', 'arap' => 'ac.source', },
'description' => { 'gl' => 'g.description', 'arap' => 'ct.name', },
);
-
+
# sortdir = sort direction (ascending or descending)
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
my $sortkey = $sort_columns{$form->{sort}} ? $form->{sort} : $form->{datesort}; # default used to be transdate
$query =
qq|SELECT
- ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
+ ac.acc_trans_id, g.id, 'gl' AS type, FALSE AS invoice, g.reference, ac.taxkey, c.link,
g.description, ac.transdate, ac.gldate, ac.source, ac.trans_id,
ac.amount, c.accno, g.notes, t.chart_id,
CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$main::lxdebug->leave_sub();
}
+sub get_tax_dropdown {
+ my $myconfig = \%main::myconfig;
+ my $form = $main::form;
+
+ my $dbh = $form->get_standard_dbh($myconfig);
+
+ my $query = qq|SELECT category FROM chart WHERE accno = ?|;
+ my ($category) = selectrow_query($form, $dbh, $query, $form->{accno});
+
+ $query = qq|SELECT * FROM tax WHERE chart_categories like '%$category%' order by taxkey, rate|;
+
+ my $sth = prepare_execute_query($form, $dbh, $query);
+
+ $form->{TAX_ACCOUNTS} = [];
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push(@{ $form->{TAX_ACCOUNTS} }, $ref);
+ }
+
+}
1;