use SL::PE;
require "$form->{path}/arap.pl";
+require "bin/mozilla/common.pl";
1;
map {
$chart .=
- "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>"
+ "<option value=\"$_->{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}</option>"
} @{ $form->{chart} };
map {
$tax .=
- qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |
+ qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
. ($_->{rate} * 100) . qq| %|
} @{ $form->{TAX} };
GL->transaction(\%myconfig, \%$form);
map {
$chart .=
- "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>"
+ "<option value=\"$_->{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}</option>"
} @{ $form->{chart} };
map {
$tax .=
- qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription} |
+ qq|<option value="$_->{id}--$_->{rate}">$_->{taxdescription} |
. ($_->{rate} * 100) . qq| %|
} @{ $form->{TAX} };
my $tax = 0;
my $taxaccno = "";
foreach $ref (@{ $form->{GL} }) {
- $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
-
$j = $i - 1;
if ($tax && ($ref->{accno} eq $taxaccno)) {
$form->{"tax_$j"} = abs($ref->{amount});
- $form->{"taxchart_$j"} = $ref->{taxkey} . "--" . $ref->{taxrate};
+ $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate};
if ($form->{taxincluded}) {
if ($ref->{amount} < 0) {
$form->{"debit_$j"} += $form->{"tax_$j"};
}
}
} else {
- $form->{"accno_$i"} = "$ref->{accno}--$ref->{accnotaxkey}";
+ $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}";
for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
if ($ref->{amount} < 0) {
$form->{totaldebit} -= $ref->{amount};
$form->{totalcredit} += $ref->{amount};
$form->{"credit_$i"} = $ref->{amount};
}
- $form->{"taxchart_$i"} = "0--";
+ $form->{"taxchart_$i"} = "0--0.00";
$i++;
}
if ($ref->{taxaccno} && !$tax) {
<tr>
<th align=right>| . $locale->text('From') . qq|</th>
$button1
+ <th align=right>| . $locale->text('To (time)') . qq|</th>
$button2
</tr>
<tr>
}
}
+ $transdate = "";
+ foreach $key (sort keys(%{ $ref->{transdate} })) {
+ if ($key == 0) {
+ $transdate = "$ref->{transdate}{$key}";
+ } else {
+ $transdate .= "<br>$ref->{transdate}{$key}";
+ }
+ }
+
# $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
# $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
$column_data{id} = "<td align=right> $ref->{id} </td>";
- $column_data{transdate} =
- "<td align=center> $ref->{transdate} </td>";
+ $column_data{transdate} = "<td align=center>$transdate</td>";
$column_data{reference} =
"<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
- $column_data{description} =
- "<td align=center>$ref->{description} </td>";
+ $column_data{description} = "<td align=center>$ref->{description} </td>";
$column_data{source} = "<td align=center>$ref->{source} </td>";
$column_data{notes} = "<td align=center>$ref->{notes} </td>";
$column_data{debit} = "<td align=right>$debit</td>";
<input class=submit type=submit name=action value="|
. $locale->text('Sales Invoice') . qq|">
<input class=submit type=submit name=action value="|
- . $locale->text('Vendor Invoice') . qq|">|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
+ . $locale->text('Vendor Invoice') . qq|">
</form>
sub update {
$lxdebug->enter_sub();
- if ($form->{transdate} ne $form->{oldtransdate}) {
- if ($form->{selectprojectnumber}) {
- $form->all_projects(\%myconfig, undef, $form->{transdate});
- if (@{ $form->{all_project} }) {
- $form->{selectprojectnumber} = "<option>\n";
- for (@{ $form->{all_project} }) {
- $form->{selectprojectnumber} .=
- qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n|;
- }
- $form->{selectprojectnumber} =
- $form->escape($form->{selectprojectnumber}, 1);
- }
- }
- $form->{oldtransdate} = $form->{transdate};
- }
+ $form->{oldtransdate} = $form->{transdate};
my @a = ();
my $count = 0;
: $form->{"debit_$i"};
$j = $#a;
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
- $form->{"taxchart_$i"} = "0--";
+ $form->{"taxchart_$i"} = "0--0.00";
$form->{"tax_$i"} = 0;
}
if (!$form->{"korrektur_$i"}) {
my ($init) = @_;
$lxdebug->enter_sub();
- $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber})
- if $form->{selectprojectnumber};
-
$form->{totaldebit} = 0;
$form->{totalcredit} = 0;
my $chart = $form->{chart};
$chart = $form->unquote($chart);
$form->{taxchart} = $form->unquote($form->{taxchart});
$taxchart = $form->{taxchart};
+
+ 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"};
+ }
+
for $i (1 .. $form->{rowcount}) {
$source = qq|
. ($i + 10 + (($i - 1) * 8))
. qq|>$form->{taxchart}</select></td>|;
- # if ($form->{selectprojectnumber}) {
- # $project = qq|
- # <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
- # }
$korrektur =
qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
. ($i + 9 + (($i - 1) * 8))
. ($i + 10 + (($i - 1) * 8))
. qq|>$tax</select></td>|;
- # if ($form->{selectprojectnumber}) {
- # $form->{"projectnumber_$i"} = ""
- # if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/;
- #
- # $project = $form->{"projectnumber_$i"};
- # $project =~ s/--.*//;
- # $project = qq|<td>$project</td>|;
- # }
-
if ($form->{transfer}) {
$checked = ($form->{"fx_transaction_$i"}) ? "1" : "";
$x = ($checked) ? "x" : "";
<td><select id="taxchart_$i" name="taxchart_$i" tabindex=|
. ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart</select></td>|;
- # if ($form->{selectprojectnumber}) {
- # $project = qq|
- # <td><select name="projectnumber_$i">$form->{selectprojectnumber}</select></td>|;
- # }
$korrektur =
qq|<td><input type="checkbox" name="korrektur_$i" value="1" tabindex=|
. ($i + 9 + (($i - 1) * 8))
}
}
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => "project_id_$i",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"project_id_$i"} ));
+
print qq|<tr valign=top>
$accno
$fx_transaction
$tax
$source
$memo
+ <td>$projectnumber</td>
</tr>
|;
$form->hide_form(qw(rowcount selectaccno));
- # print qq|
- # <input type=hidden name=selectprojectnumber value="|
- # . $form->escape($form->{selectprojectnumber}, 1) . qq|">|;
$lxdebug->leave_sub();
}
<!--
function setTaxkey(accno, row) {
var taxkey = accno.options[accno.selectedIndex].value;
- var reg = /--([0-9])*/;
+ var reg = /--([0-9]*)/;
var found = reg.exec(taxkey);
var index = found[1];
index = parseInt(index);
<th class=listheading style="width:20%">|
. $locale->text('Source') . qq|</th>
<th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
- $project
+ <th class=listheading style="width:20%">|
+ . $locale->text('Project Number') . qq|</th>
</tr>
$jsscript
<td></td>
<th align=right class=listtotal> $form->{totaldebit}</th>
<th align=right class=listtotal> $form->{totalcredit}</th>
- <td colspan=5></td>
+ <td colspan=6></td>
</tr>
</table>
</td>
}
}
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
print "
</form>
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- # check project
- &check_project;
-
my @a = ();
my $count = 0;
my $debittax = 0;
: $form->{"debit_$i"};
$j = $#a;
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
- $form->{"taxchart_$i"} = "0--";
+ $form->{"taxchart_$i"} = "0--0.00";
$form->{"tax_$i"} = 0;
}
if (!$form->{"korrektur_$i"}) {
if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
$form->error($locale->text('Out of balance transaction!'));
}
+
+ if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) {
+ $form->error($locale->text('Empty transaction!'));
+ }
+
if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
$errno *= -1;
$err[1] = $locale->text('Cannot have a value in both Debit and Credit!');