X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/96d10eccdcde8518cf9cc1ed863be32cf34ccfc2..d18a84dfd90b91c60093c77bbc5900408e0c5697:/SL/IS.pm diff --git a/SL/IS.pm b/SL/IS.pm index aa8ded951..1ee47f209 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -130,8 +130,6 @@ sub invoice_details { 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]; @@ -367,7 +365,7 @@ sub invoice_details { $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"}); @@ -445,7 +443,7 @@ sub customer_details { } # get rest for the customer - my $query = qq|SELECT ct.*, cp.*, ct.notes as customernotes + my $query = qq|SELECT ct.*, cp.*, ct.notes as customernotes, ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail FROM customer ct LEFT JOIN contacts cp on ct.id = cp.cp_cv_id WHERE ct.id = $form->{customer_id} $contact order by cp.cp_id limit 1|; @@ -552,6 +550,12 @@ sub post_invoice { ($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 } @@ -741,7 +745,7 @@ sub post_invoice { '$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"}, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated, 'f', - '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|, + '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}, 'NULL') . qq|, '$form->{"serialnumber_$i"}', '$pricegroup_id', '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', $baseqty, '$subtotal')|; $dbh->do($query) || $form->dberror($query); @@ -927,11 +931,11 @@ sub post_invoice { $form->{"paid_$i"} *= -1; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, - source, memo, ?) + source, memo, project_id) VALUES ($form->{id}, (SELECT c.id FROM chart c - WHERE c.accno = '$accno', project_id), + WHERE c.accno = '$accno'), $form->{"paid_$i"}, '$form->{"datepaid_$i"}', - '$form->{"source_$i"}', '$form->{"memo_$i"}')|; + '$form->{"source_$i"}', '$form->{"memo_$i"}', ?)|; do_query($form, $dbh, $query, $project_id); # exchangerate difference @@ -1858,8 +1862,7 @@ sub get_customer { $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; @@ -2220,5 +2223,28 @@ sub get_pricegroups_for_parts { $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;