if ($tax != 0) {
# add taxentry
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
- source, memo, taxkey)
+ source, memo, project_id, taxkey)
VALUES
($form->{id}, (SELECT t.chart_id
FROM tax t
$apwhere .=
" AND ap.id in (SELECT trans_id FROM acc_trans ac2 WHERE ac2.chart_id IN (SELECT id FROM chart c2 WHERE c2.category = '$form->{category}'))";
}
+ if ($form->{project_id}) {
+ $glwhere .= " AND g.id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE project_id = " . conv_i($form->{project_id}, 'NULL') . ")";
+ $arwhere .=
+ " AND ((a.globalproject_id = " . conv_i($form->{project_id}, 'NULL') . ") OR " .
+ " (a.id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE project_id = " . conv_i($form->{project_id}, 'NULL') . ")))";
+ $apwhere .=
+ " AND ((a.globalproject_id = " . conv_i($form->{project_id}, 'NULL') . ") OR " .
+ " (a.id IN (SELECT DISTINCT trans_id FROM acc_trans WHERE project_id = " . conv_i($form->{project_id}, 'NULL') . ")))";
+ }
+
+ my ($project_columns, %project_join);
+ if ($form->{"l_projectnumbers"}) {
+ $project_columns = ", ac.project_id, pr.projectnumber";
+ $project_join = "LEFT JOIN project pr ON (ac.project_id = pr.id)";
+ }
if ($form->{accno}) {
qq|SELECT ac.oid AS acoid, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
g.description, ac.transdate, ac.source, ac.trans_id,
ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid
- FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON
+ $project_columns
+ FROM gl g, acc_trans ac $project_join, chart c LEFT JOIN tax t ON
(t.chart_id=c.id)
WHERE $glwhere
AND ac.chart_id = c.id
SELECT ac.oid AS acoid, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
ct.name, ac.transdate, ac.source, ac.trans_id,
ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
- FROM ar a, acc_trans ac, customer ct, chart c LEFT JOIN tax t ON
+ $project_columns
+ FROM ar a, acc_trans ac $project_join, customer ct, chart c LEFT JOIN tax t ON
(t.chart_id=c.id)
WHERE $arwhere
AND ac.chart_id = c.id
SELECT ac.oid AS acoid, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
ct.name, ac.transdate, ac.source, ac.trans_id,
ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
- FROM ap a, acc_trans ac, vendor ct, chart c LEFT JOIN tax t ON
+ $project_columns
+ FROM ap a, acc_trans ac $project_join, vendor ct, chart c LEFT JOIN tax t ON
(t.chart_id=c.id)
WHERE $apwhere
AND ac.chart_id = c.id
$ref->{module} = "ar";
}
}
-
+
+ $ref->{"projectnumbers"} = {};
+ $ref->{"projectnumbers"}->{$ref->{"projectnumber"}} = 1 if ($ref->{"projectnumber"});
+
$balance = $ref->{amount};
# Linenumbers of General Ledger
$balance =
(int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
+ $ref->{"projectnumbers"}->{$ref2->{"projectnumber"}} = 1 if ($ref2->{"projectnumber"});
if ($ref2->{chart_id} > 0) { # all tax accounts, following lines
if ($ref2->{amount} < 0) {
</tr>
| if $form->{selectdepartment};
+ $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ "all" => 1 });
+
+ my %project_labels = ();
+ my @project_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@project_values, $item->{"id"});
+ $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => "project_id",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels));
+
# use JavaScript Calendar or not
$form->{jsscript} = $jscalendar;
$jsscript = "";
<th align=right>| . $locale->text('Notes') . qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
+ <tr>
+ <th align=right>| . $locale->text('Project Number') . qq|</th>
+ <td colspan=3>$projectnumber</td>
+ </tr>
<tr>
<th align=right>| . $locale->text('From') . qq|</th>
$button1
<tr>
<td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
<td>| . $locale->text('Subtotal') . qq|</td>
+ <td align=right><input name="l_projectnumbers" class=checkbox type=checkbox value=Y></td>
+ <td>| . $locale->text('Project Number') . qq|</td>
</tr>
</table>
</tr>
$option .= "\n<br>" if $option;
$option .= $locale->text('Notes') . " : $form->{notes}";
}
+ if ($form->{project_id}) {
+ $href .= "&project_id=" . $form->escape($form->{project_id});
+ $callback .= "&project_id=" . $form->escape($form->{project_id});
+ }
if ($form->{datefrom}) {
$href .= "&datefrom=$form->{datefrom}";
. $locale->date(\%myconfig, $form->{dateto}, 1);
}
- @columns = $form->sort_columns(
- qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno)
- );
+ @columns =
+ qw(transdate id reference description notes source debit debit_accno credit
+ credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno
+ gifi_accno projectnumbers);
if ($form->{accno} || $form->{gifi_accno}) {
@columns = grep !/(accno|gifi_accno)/, @columns;
. $locale->text('GIFI')
. "</a></th>";
$column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
+ $column_header{projectnumbers} =
+ "<th class=listheading>" . $locale->text('Project Numbers') . "</th>";
$form->{landscape} = 1;
$column_data{balance} =
"<td align=right>"
. $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . "</td>";
+ $column_data{projectnumbers} =
+ "<td>" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . "</td>";
$i++;
$i %= 2;