$query =
qq|INSERT INTO gl (id, employee_id) | .
qq|VALUES (?, (SELECT id FROM employee WHERE login = ?))|;
- @values = ($form->{id}, $form->{login});
+ @values = ($form->{id}, $::myconfig{login});
do_query($form, $dbh, $query, @values);
}
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"}));
exporttype => DATEV_ET_BUCHUNGEN,
format => DATEV_FORMAT_KNE,
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
FROM acc_trans a
JOIN chart c ON (c.id = a.chart_id)
LEFT JOIN project p ON (p.id = a.project_id)
- LEFT JOIN tax t ON
- (t.id =
- (SELECT tk.tax_id
- FROM taxkeys tk
- WHERE (tk.taxkey_id = a.taxkey) AND
- ((CASE WHEN a.chart_id IN
- (SELECT chart_id FROM taxkeys WHERE taxkey_id = a.taxkey)
- THEN tk.chart_id = a.chart_id
- ELSE 1 = 1
- END)
- OR (c.link LIKE '%tax%'))
- AND (startdate <= a.transdate)
- ORDER BY startdate DESC LIMIT 1))
+ LEFT JOIN tax t ON (t.id = a.tax_id)
WHERE (a.trans_id = ?)
AND (a.fx_transaction = '0')
ORDER BY a.acc_trans_id, a.transdate|;
$query = qq|SELECT * FROM gl WHERE id = ?|;
$storno_row = selectfirst_hashref_query($form, $dbh, $query, $id);
- $storno_row->{id} = $new_id;
- $storno_row->{storno_id} = $id;
- $storno_row->{storno} = 't';
- $storno_row->{reference} = 'Storno-' . $storno_row->{reference};
+ $storno_row->{id} = $new_id;
+ $storno_row->{storno_id} = $id;
+ $storno_row->{storno} = 't';
+ $storno_row->{reference} = 'Storno-' . $storno_row->{reference};
+
+ $query = qq|SELECT id FROM employee WHERE login = ?|;
+ my ($employee_id) = selectrow_query($form, $dbh, $query, $::myconfig{login});
+ $storno_row->{employee_id} = $employee_id;
delete @$storno_row{qw(itime mtime gldate)};
$main::lxdebug->leave_sub();
}
+sub get_tax_dropdown {
+ my ($self, $accno) = @_;
+
+ 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, $accno);
+
+ $query = qq|SELECT * FROM tax WHERE chart_categories like '%$category%' order by taxkey, rate|;
+
+ my $sth = prepare_execute_query($form, $dbh, $query);
+
+ my @tax_accounts = ();
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push(@tax_accounts, $ref);
+ }
+
+ return @tax_accounts;
+}
1;