summaryrefslogtreecommitdiff
path: root/doc/forum/multi_domain_setup_possible__63__.mdwn
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2011-01-03 11:20:10 +0000
committerSimon McVittie <smcv@debian.org>2011-01-03 11:20:10 +0000
commita6943ba2cc9a69fa2fd963a9682a4a0e27e8c00e (patch)
treea41e616dba95c5f9c11a4a9659aff6faadaf0155 /doc/forum/multi_domain_setup_possible__63__.mdwn
parent2bf9d8dc82c528bd0372ca7f633050b38cc1eea2 (diff)
Revert spam
This reverts commit 2bf9d8dc82c528bd0372ca7f633050b38cc1eea2.
Diffstat (limited to 'doc/forum/multi_domain_setup_possible__63__.mdwn')
0 files changed, 0 insertions, 0 deletions
li id="n_37" class="hl">use LedgerSMB::Sysconfig;
  • sub invoice_details {
  • use LedgerSMB::CP;
  • my ($self, $myconfig, $form) = @_;
  • $form->{duedate} = $form->{transdate} unless ($form->{duedate});
  • # connect to database
  • my $dbh = $form->{dbh};
  • my $query = qq|
  • SELECT ?::date - ?::date
  • AS terms, value
  • FROM defaults
  • WHERE setting_key = 'weightunit'|;
  • my $sth = $dbh->prepare($query);
  • $sth->execute($form->{duedate}, $form->{transdate})
  • || $form->dberror($query);
  • ($form->{terms}, $form->{weightunit}) = $sth->fetchrow_array;
  • $sth->finish;
  • # this is for the template
  • $form->{invdate} = $form->{transdate};
  • my $tax = 0;
  • my $item;
  • my $i;
  • my @sortlist = ();
  • my $projectnumber;
  • my $projectdescription;
  • my $projectnumber_id;
  • my $translation;
  • my $partsgroup;
  • my @taxaccounts;
  • my %taxaccounts;
  • my $tax;
  • my $taxrate;
  • my $taxamount;
  • my %translations;
  • $query = qq|
  • SELECT p.description, t.description
  • FROM project p
  • LEFT JOIN translation t
  • ON (t.trans_id = p.id
  • AND t.language_code = ?)
  • WHERE id = ?|;
  • my $prh = $dbh->prepare($query) || $form->dberror($query);
  • $query = qq|
  • SELECT inventory_accno_id, income_accno_id,
  • expense_accno_id, assembly, weight FROM parts
  • WHERE id = ?|;
  • my $pth = $dbh->prepare($query) || $form->dberror($query);
  • my $sortby;
  • # sort items by project and partsgroup
  • for $i (1 .. $form->{rowcount} - 1) {
  • # account numbers
  • $pth->execute($form->{"id_$i"});
  • $ref = $pth->fetchrow_hashref(NAME_lc);
  • for (keys %$ref) { $form->{"${_}_$i"} = $ref->{$_} }
  • $pth->finish;
  • $projectnumber_id = 0;
  • $projectnumber = "";
  • $form->{partsgroup} = "";
  • $form->{projectnumber} = "";
  • if ($form->{groupprojectnumber} || $form->{grouppartsgroup}) {
  • $inventory_accno_id =
  • ($form->{"inventory_accno_id_$i"}
  • || $form->{"assembly_$i"})
  • ? "1"
  • : "";
  • if ($form->{groupprojectnumber}) {
  • ($projectnumber, $projectnumber_id) =
  • split /--/, $form->{"projectnumber_$i"};
  • }
  • if ($form->{grouppartsgroup}) {
  • ($form->{partsgroup}) =
  • split /--/, $form->{"partsgroup_$i"};
  • }
  • if ($projectnumber_id && $form->{groupprojectnumber}) {
  • if ($translation{$projectnumber_id}) {
  • $form->{projectnumber} =
  • $translation{$projectnumber_id};
  • } else {
  • # get project description
  • $prh->execute($projectnumber_id,
  • $form->{language_code});
  • ($projectdescription, $translation) =
  • $prh->fetchrow_array;
  • $prh->finish;
  • $form->{projectnumber} =
  • ($translation)
  • ? "$projectnumber, $translation"
  • : "$projectnumber, ".
  • "$projectdescription";
  • $translation{$projectnumber_id} =
  • $form->{projectnumber};
  • }
  • }
  • if ($form->{grouppartsgroup} && $form->{partsgroup}) {
  • $form->{projectnumber} .= " / "
  • if $projectnumber_id;
  • $form->{projectnumber} .= $form->{partsgroup};
  • }
  • $form->format_string(projectnumber);
  • }
  • $sortby = qq|$projectnumber$form->{partsgroup}|;
  • if ($form->{sortby} ne 'runningnumber') {
  • for (qw(partnumber description bin)) {
  • $sortby .= $form->{"${_}_$i"}
  • if $form->{sortby} eq $_;
  • }
  • }
  • push @sortlist, [ $i,
  • qq|$projectnumber$form->{partsgroup}|.
  • qq|$inventory_accno_id|,
  • $form->{projectnumber}, $projectnumber_id,
  • $form->{partsgroup}, $sortby ];
  • }
  • # sort the whole thing by project and group
  • @sortlist = sort { $a->[5] cmp $b->[5] } @sortlist;
  • my $runningnumber = 1;
  • my $sameitem = "";
  • my $subtotal;
  • my $k = scalar @sortlist;
  • my $j = 0;
  • foreach $item (@sortlist) {
  • $i = $item->[0];
  • $j++;
  • # heading
  • if ($form->{groupprojectnumber} || $form->{grouppartsgroup}) {
  • if ($item->[1] ne $sameitem) {
  • $sameitem = $item->[1];
  • $ok = 0;
  • if ($form->{groupprojectnumber}) {
  • $ok = $form->{"projectnumber_$i"};
  • }
  • if ($form->{grouppartsgroup}) {
  • $ok = $form->{"partsgroup_$i"}
  • unless $ok;
  • }
  • if ($ok) {
  • if ($form->{"inventory_accno_id_$i"}
  • || $form->{"assembly_$i"}) {
  • push(@{ $form->{part} }, "");
  • push(@{ $form->{service} },
  • NULL);
  • } else {
  • push(@{ $form->{part} }, NULL);
  • push(@{ $form->{service} }, "");
  • }
  • push(@{ $form->{description} },
  • $item->[2]);
  • for (
  • qw(taxrates runningnumber number
  • sku serialnumber bin qty ship
  • unit deliverydate projectnumber
  • sellprice listprice netprice
  • discount discountrate linetotal
  • weight itemnotes)
  • ) {
  • push(@{ $form->{$_} }, "");
  • }
  • push(@{ $form->{lineitems} },
  • { amount => 0, tax => 0 });
  • }
  • }
  • }
  • $form->{"qty_$i"} =
  • $form->parse_amount($myconfig, $form->{"qty_$i"});
  • if ($form->{"qty_$i"}) {
  • $form->{totalqty} += $form->{"qty_$i"};
  • $form->{totalship} += $form->{"qty_$i"};
  • $form->{totalweight} += ($form->{"qty_$i"}
  • * $form->{"weight_$i"});
  • $form->{totalweightship} += ($form->{"qty_$i"}
  • * $form->{"weight_$i"});
  • # add number, description and qty to $form->{number}...
  • push(@{ $form->{runningnumber} }, $runningnumber++);
  • push(@{ $form->{number} }, $form->{"partnumber_$i"});
  • push(@{ $form->{sku} }, $form->{"sku_$i"});
  • push(@{ $form->{serialnumber} },
  • $form->{"serialnumber_$i"});
  • push(@{ $form->{bin} }, $form->{"bin_$i"});
  • push(@{ $form->{description} },
  • $form->{"description_$i"});
  • push(@{ $form->{itemnotes} }, $form->{"notes_$i"});
  • push(@{ $form->{qty} },
  • $form->format_amount(
  • $myconfig, $form->{"qty_$i"}));
  • push(@{ $form->{ship} },
  • $form->format_amount(
  • $myconfig, $form->{"qty_$i"}));
  • push(@{ $form->{unit} }, $form->{"unit_$i"});
  • push(@{ $form->{deliverydate} },
  • $form->{"deliverydate_$i"});
  • push(@{ $form->{projectnumber} },
  • $form->{"projectnumber_$i"});
  • push(@{ $form->{sellprice} }, $form->{"sellprice_$i"});
  • push(@{ $form->{listprice} }, $form->{"listprice_$i"});
  • push(@{ $form->{weight} },
  • $form->format_amount(