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];
$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->{taxdescription} }, $form->{"${item}_description"} . q{ } . 100 * $form->{"${item}_rate"} . q{%});
push(@{ $form->{taxrate} },
$form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
($form->{id}) = $sth->fetchrow_array;
$sth->finish;
+
+ if (!$form->{invnumber}) {
+ $form->{invnumber} =
+ $form->update_defaults($myconfig, $form->{type} eq "credit_note" ?
+ "cnnumber" : "invnumber", $dbh);
+ }
}
map { $form->{$_} =~ s/\'/\'\'/g }
$form->{"AR_amount_$i"} = "$ref->{accno}--$ref->{description}";
}
if ($ref->{category} eq 'A') {
- $form->{ARselected} = $form->{AR_1} =
- "$ref->{accno}--$ref->{description}";
+ $form->{ARselected} = $form->{AR_1} = $ref->{accno};
}
}
$sth->finish;
$main::lxdebug->leave_sub();
}
+sub has_storno {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form, $table) = @_;
+
+ $main::lxdebug->leave_sub() and return 0 unless ($form->{id});
+
+ # make sure there's no funny stuff in $table
+ # ToDO: die when this happens and throw an error
+ $main::lxdebug->leave_sub() and return 0 if ($table =~ /\W/);
+
+ my $dbh = $form->dbconnect($myconfig);
+
+ my $query = qq|SELECT storno FROM $table WHERE id = ?|;
+ my ($result) = selectrow_query($form, $dbh, $query, $form->{id});
+
+ $dbh->disconnect();
+
+ $main::lxdebug->leave_sub();
+
+ return $result;
+}
+
1;