Revision 96d10ecc
Von Moritz Bunkus vor etwa 18 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
($form->{terms}) = $sth->fetchrow_array;
|
||
$sth->finish;
|
||
|
||
my (@project_ids, %projectnumbers);
|
||
|
||
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"});
|
||
|
||
# sort items by partsgroup
|
||
for $i (1 .. $form->{rowcount}) {
|
||
$partsgroup = "";
|
||
if ($form->{"partsgroup_$i"} && $form->{groupitems}) {
|
||
$partsgroup = $form->{"partsgroup_$i"};
|
||
}
|
||
push @partsgroup, [$i, $partsgroup];
|
||
push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"});
|
||
}
|
||
|
||
if (@project_ids) {
|
||
$query = "SELECT id, projectnumber FROM project WHERE id IN (" .
|
||
join(", ", map({ "?" } @project_ids)) . ")";
|
||
$sth = $dbh->prepare($query);
|
||
$sth->execute(@project_ids) ||
|
||
$form->dberror($query . " (" . join(", ", @project_ids) . ")");
|
||
while (my $ref = $sth->fetchrow_hashref()) {
|
||
$projectnumbers{$ref->{id}} = $ref->{projectnumber};
|
||
}
|
||
$sth->finish();
|
||
}
|
||
|
||
$form->{"globalprojectnumber"} =
|
||
$projectnumbers{$form->{"globalproject_id"}};
|
||
|
||
my $tax = 0;
|
||
my $item;
|
||
my $i;
|
||
... | ... | |
my $subtotal_header = 0;
|
||
my $subposition = 0;
|
||
|
||
my @arrays =
|
||
qw(runningnumber number description longdescription qty ship unit bin
|
||
deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil
|
||
partnotes serialnumber reqdate sellprice listprice netprice
|
||
discount p_discount discount_sub nodiscount_sub
|
||
linetotal nodiscount_linetotal tax_rate projectnumber);
|
||
|
||
my @tax_arrays =
|
||
qw(taxbase tax taxdescription taxrate taxnumber);
|
||
|
||
map({ $form->{$_} = [] } (@arrays, @tax_arrays));
|
||
|
||
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
|
||
$i = $item->[0];
|
||
... | ... | |
push(@{ $form->{description} }, qq|$item->[1]|);
|
||
$sameitem = $item->[1];
|
||
|
||
map { push(@{ $form->{$_} }, "") }
|
||
qw(runningnumber number serialnumber bin partnotes qty unit deliverydate sellprice listprice netprice discount linetotal);
|
||
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
||
}
|
||
|
||
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
|
||
... | ... | |
push(@{ $form->{nodiscount_linetotal} },
|
||
$form->format_amount($myconfig, $nodiscount_linetotal, 2));
|
||
|
||
push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
|
||
|
||
|
||
@taxaccounts = split / /, $form->{"taxaccounts_$i"};
|
||
$taxrate = 0;
|
||
$taxdiff = 0;
|
||
... | ... | |
|
||
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
||
if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
|
||
map { push(@{ $form->{$_} }, "") }
|
||
qw(runningnumber number serialnumber unit qty bin sellprice listprice netprice discount linetotal nodiscount_linetotal);
|
||
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
||
$sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
|
||
push(@{ $form->{description} }, $sameitem);
|
||
}
|
||
... | ... | |
$form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}
|
||
)
|
||
. qq| -- $form->{"a_partnumber"}, $form->{"a_description"}|);
|
||
map { push(@{ $form->{$_} }, "") }
|
||
qw(number unit qty runningnumber serialnumber bin sellprice listprice netprice discount linetotal nodiscount_linetotal);
|
||
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
||
|
||
}
|
||
$sth->finish;
|
SL/OE.pm | ||
---|---|---|
my %oid = ('Pg' => 'oid',
|
||
'Oracle' => 'rowid');
|
||
|
||
my (@project_ids, %projectnumbers);
|
||
|
||
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"});
|
||
|
||
# sort items by partsgroup
|
||
for $i (1 .. $form->{rowcount}) {
|
||
$partsgroup = "";
|
||
... | ... | |
$partsgroup = $form->{"partsgroup_$i"};
|
||
}
|
||
push @partsgroup, [$i, $partsgroup];
|
||
push(@project_ids, $form->{"project_id_$i"}) if ($form->{"project_id_$i"});
|
||
}
|
||
|
||
if (@project_ids) {
|
||
$query = "SELECT id, projectnumber FROM project WHERE id IN (" .
|
||
join(", ", map({ "?" } @project_ids)) . ")";
|
||
$sth = $dbh->prepare($query);
|
||
$sth->execute(@project_ids) ||
|
||
$form->dberror($query . " (" . join(", ", @project_ids) . ")");
|
||
while (my $ref = $sth->fetchrow_hashref()) {
|
||
$projectnumbers{$ref->{id}} = $ref->{projectnumber};
|
||
}
|
||
$sth->finish();
|
||
}
|
||
|
||
$form->{"globalprojectnumber"} =
|
||
$projectnumbers{$form->{"globalproject_id"}};
|
||
|
||
my @arrays =
|
||
qw(runningnumber number description longdescription qty ship unit bin
|
||
partnotes serialnumber reqdate sellprice listprice netprice
|
||
discount p_discount discount_sub nodiscount_sub
|
||
linetotal nodiscount_linetotal tax_rate projectnumber);
|
||
|
||
my @tax_arrays =
|
||
qw(taxbase tax taxdescription taxrate taxnumber);
|
||
|
||
map({ $form->{$_} = [] } (@arrays, @tax_arrays));
|
||
|
||
my $sameitem = "";
|
||
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
|
||
$i = $item->[0];
|
||
... | ... | |
push(@{ $form->{description} }, qq|$item->[1]|);
|
||
$sameitem = $item->[1];
|
||
|
||
map { push(@{ $form->{$_} }, "") }
|
||
qw(runningnumber number qty ship unit bin partnotes
|
||
serialnumber reqdate sellprice listprice netprice
|
||
discount p_discount linetotal);
|
||
map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
|
||
}
|
||
|
||
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
|
||
... | ... | |
push(@{ $form->{p_discount} }, $form->{"discount_$i"});
|
||
|
||
$form->{ordtotal} += $linetotal;
|
||
$discount_subtotal += $linetotal;
|
||
$discount_subtotal += $linetotal;
|
||
$form->{nodiscount_total} += $nodiscount_linetotal;
|
||
$nodiscount_subtotal += $nodiscount_linetotal;
|
||
$form->{discount_total} += $form->parse_amount($myconfig, $discount);
|
||
... | ... | |
push(@{ $form->{nodiscount_linetotal} },
|
||
$form->format_amount($myconfig, $nodiscount_linetotal, 2));
|
||
|
||
push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
|
||
|
||
my ($taxamount, $taxbase);
|
||
my $taxrate = 0;
|
||
|
||
... | ... | |
|
||
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
||
if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
|
||
map { push(@{ $form->{$_} }, "") }
|
||
qw(runningnumber ship bin serialnumber number unit bin qty
|
||
reqdate sellprice listprice netprice discount p_discount
|
||
linetotal nodiscount_linetotal);
|
||
map({ push(@{ $form->{$_} }, "") }
|
||
grep({ $_ ne "description" } @arrays));
|
||
$sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
|
||
push(@{ $form->{description} }, $sameitem);
|
||
}
|
||
... | ... | |
)
|
||
. qq|, $ref->{partnumber}, $ref->{description}|);
|
||
|
||
map { push(@{ $form->{$_} }, "") }
|
||
qw(number unit qty runningnumber ship bin serialnumber reqdate
|
||
sellprice listprice netprice discount p_discount linetotal
|
||
nodiscount_linetotal);
|
||
|
||
map({ push(@{ $form->{$_} }, "") }
|
||
grep({ $_ ne "description" } @arrays));
|
||
}
|
||
$sth->finish;
|
||
}
|
||
... | ... | |
|
||
my $tax = 0;
|
||
foreach $item (sort keys %taxaccounts) {
|
||
push(@{ $form->{taxbase} },
|
||
$form->format_amount($myconfig, $taxbase{$item}, 2));
|
||
push(@{ $form->{taxbase} },
|
||
$form->format_amount($myconfig, $taxbase{$item}, 2));
|
||
|
||
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
|
||
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
|
||
|
||
push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
||
push(@{ $form->{taxdescription} }, $form->{"${item}_description"});
|
||
push(@{ $form->{taxrate} },
|
||
$form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
||
push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
|
||
push(@{ $form->{tax} }, $form->format_amount($myconfig, $taxamount, 2));
|
||
push(@{ $form->{taxdescription} }, $form->{"${item}_description"});
|
||
push(@{ $form->{taxrate} },
|
||
$form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
|
||
push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
|
||
}
|
||
$form->{subtotal} = $form->format_amount($myconfig, $form->{total}, 2);
|
||
$yesdiscount = $form->{nodiscount_total} - $nodiscount;
|
Auch abrufbar als: Unified diff
Beim Drucken von Einkaufs- und Verkaufsbelegen die Projektnummern aus der Datenbank holen. Liste der Arrays, die in order_details/invoice_details aufgebaut werden, zentral angelegt, sodass bei "leeren" Zeilen auch wirklich alle bestückt werden können, ohne die Liste an drei Orten bearbeiten zu müssen.