for $i (1 .. $form->{rowcount}) {
if ($form->{"amount_$i"} != 0) {
my $project_id;
- if ("amount_$i" =~ /amount_/) {
- if ($form->{"project_id_$i"} && $form->{"projectnumber_$i"}) {
- $project_id = $form->{"project_id_$i"};
- }
- }
- if ("amount_$i" =~ /amount/) {
- $taxkey = $form->{AP_amounts}{"amount_$i"}{taxkey};
- }
+ $project_id = conv_i($form->{"project_id_$i"});
+ $taxkey = $form->{AP_amounts}{"amount_$i"}{taxkey};
# insert detail records in acc_trans
$query =
qq| ?, ?, ?, ?)|;
@values = ($form->{id}, $form->{AP_amounts}{"amount_$i"},
$form->{"amount_$i"}, conv_date($form->{transdate}),
- conv_i($project_id), $taxkey);
+ $project_id, $taxkey);
do_query($form, $dbh, $query, @values);
if ($form->{"tax_$i"} != 0) {
qq| ?, ?, ?, ?)|;
@values = ($form->{id}, $form->{AP_amounts}{"tax_$i"},
$form->{"tax_$i"}, conv_date($form->{transdate}),
- conv_date($project_id), $taxkey);
+ $project_id, $taxkey);
do_query($form, $dbh, $query, @values);
}
# add payables
$query =
- qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) | .
- qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | .
- qq| ?, ?, ?)|;
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) | .
+ qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?)|;
@values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables},
- conv_date($form->{transdate}), conv_i($project_id));
+ conv_date($form->{transdate}));
do_query($form, $dbh, $query, @values);
# if there is no amount but a payment record a payable
package AR;
use Data::Dumper;
+use SL::DBUtils;
sub post_transaction {
$main::lxdebug->enter_sub();
my $exchangerate = 0;
my $i;
+ my @values;
+
my $dbh = $form->dbconnect_noauto($myconfig);
if ($form->{currency} eq $form->{defaultcurrency}) {
# add individual transactions for AR, amount and taxes
for $i (1 .. $form->{rowcount}) {
if ($form->{"amount_$i"} != 0) {
- $project_id = 'NULL';
- if ("amount_$i" =~ /amount_/) {
- if ($form->{"project_id_$i"} && $form->{"projectnumber_$i"}) {
- $project_id = $form->{"project_id_$i"};
- }
- }
- if ("amount_$i" =~ /amount/) {
- $taxkey = $form->{AR_amounts}{"amount_$i"}{taxkey};
- }
+ my $project_id = undef;
+ $project_id = conv_i($form->{"project_id_$i"});
+ $taxkey = $form->{AR_amounts}{"amount_$i"}{taxkey};
+ @values = ($project_id);
# insert detail records in acc_trans
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
project_id, taxkey)
VALUES ($form->{id}, (SELECT c.id FROM chart c
WHERE c.accno = '$form->{AR_amounts}{"amount_$i"}'),
- $form->{"amount_$i"}, '$form->{transdate}', $project_id, '$taxkey')|;
- $dbh->do($query) || $form->dberror($query);
+ $form->{"amount_$i"}, '$form->{transdate}', ?, '$taxkey')|;
+ do_query($form, $dbh, $query, @values);
if ($form->{"tax_$i"} != 0) {
+ @values = ($project_id);
# insert detail records in acc_trans
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
project_id, taxkey)
VALUES ($form->{id}, (SELECT c.id FROM chart c
WHERE c.accno = '$form->{AR_amounts}{"tax_$i"}'),
- $form->{"tax_$i"}, '$form->{transdate}', $project_id, '$taxkey')|;
- $dbh->do($query) || $form->dberror($query);
+ $form->{"tax_$i"}, '$form->{transdate}', ?, '$taxkey')|;
+ do_query($form, $dbh, $query, @values);
}
}
}
# add recievables
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
- project_id)
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate)
VALUES ($form->{id}, (SELECT c.id FROM chart c
WHERE c.accno = '$form->{AR_amounts}{receivables}'),
- $form->{receivables}, '$form->{transdate}', $project_id)|;
+ $form->{receivables}, '$form->{transdate}')|;
$dbh->do($query) || $form->dberror($query);
# add paid transactions
? qq|<select name=vendor>$form->{selectvendor}</select>|
: qq|<input name=vendor value="$form->{vendor}" size=35>|;
+ my @old_project_ids = ();
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+ $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids });
+
+ my %project_labels = ();
+ my @project_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@project_values, $item->{"id"});
+ $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
# use JavaScript Calendar or not
$form->{jsscript} = $jscalendar;
$jsscript = "";
my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => "project_id_$i",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"project_id_$i"} ));
+
print qq|
<tr>
<td width=50%><select name="AP_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAP_amount</select></td>
<td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
<td><input type="checkbox" name="korrektur_$i" value="1" "$korrektur"></td>
$tax
- <td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
- <input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
- <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
+ <td>$projectnumber</td>
</tr>
|;
$amount = "";
&check_name(vendor);
$form->{AP} = $save_AP;
- &check_project;
$form->{rowcount} = $count + 1;
$form->{invtotal} =
|;
}
+ my @old_project_ids = ();
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+ $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids });
+
+ my %project_labels = ();
+ my @project_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@project_values, $item->{"id"});
+ $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
$form->{fokus} = "arledger.customer";
# use JavaScript Calendar or not
qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
$korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => "project_id_$i",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"project_id_$i"} ));
+
print qq|
<tr>
<td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
<td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
<td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
$tax
- <td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
- <input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
- <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
+ <td>$projectnumber</td>
</tr>
|;
$amount = "";
&check_name(customer);
$form->{AR} = $save_AR;
- &check_project;
-
$form->{invtotal} =
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;