X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=ce6d6be239a54a0dec8798d3b14518d20ac0114f;hb=8961864f7c8e4233907f13773adda9c88c39776c;hp=8643eaef2cb31008f6b2381c2e888eef6f2ebe8f;hpb=58b14f96d6a7aab3bad2ffac3f8930793cf15a09;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index 8643eaef2..ce6d6be23 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -110,6 +110,8 @@ sub invoice_details { push(@{ $form->{deliverydate} }, qq|$form->{"deliverydate_$i"}|); push(@{ $form->{sellprice} }, $form->{"sellprice_$i"}); + push(@{ $form->{ordnumber_oe} }, qq|$form->{"ordnumber_$i"}|); + push(@{ $form->{transdate_oe} }, qq|$form->{"transdate_$i"}|); if ($form->{lizenzen}) { if ($form->{"licensenumber_$i"}) { @@ -122,9 +124,7 @@ sub invoice_details { push(@{ $form->{licensenumber} }, $licensenumber); push(@{ $form->{validuntil} }, $locale->date($myconfig, $validuntil, 0)); - $licensenumber = "Lizenz: " . $licensenumber; $sth->finish; - push(@{ $form->{licensenumber} }, $licensenumber); } else { push(@{ $form->{licensenumber} }, ""); push(@{ $form->{validuntil} }, ""); @@ -139,14 +139,14 @@ sub invoice_details { $dec = length $dec; my $decimalplaces = ($dec > 2) ? $dec : 2; - my $discount = - $form->round_amount( - $sellprice * $form->parse_amount($myconfig, - $form->{"discount_$i"}) / 100, - $decimalplaces); + my $i_discount = $form->round_amount($sellprice * + $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100, $decimalplaces); + + my $discount = $form->round_amount($form->{"qty_$i"} * $i_discount, $decimalplaces); # keep a netprice as well, (sellprice - discount) - $form->{"netprice_$i"} = $sellprice - $discount; + $form->{"netprice_$i"} = $sellprice - $i_discount; + push(@{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount( @@ -165,6 +165,7 @@ sub invoice_details { $linetotal = ($linetotal != 0) ? $linetotal : " "; push(@{ $form->{discount} }, $discount); + push(@{ $form->{p_discount} }, $form->{"discount_$i"}); $form->{total} += $linetotal; @@ -345,8 +346,6 @@ sub customer_details { $contact = "and cp.cp_id = $form->{cp_id}"; } - $taxincluded = $form->{taxincluded}; - # get rest for the customer my $query = qq|SELECT ct.*, cp.*, ct.notes as customernotes FROM customer ct @@ -356,9 +355,10 @@ sub customer_details { $sth->execute || $form->dberror($query); $ref = $sth->fetchrow_hashref(NAME_lc); - map { $form->{$_} = $ref->{$_} } keys %$ref; - $form->{taxincluded} = $taxincluded; + # remove id and taxincluded before copy back + delete @$ref{qw(id taxincluded)}; + map { $form->{$_} = $ref->{$_} } keys %$ref; $sth->finish; $dbh->disconnect; @@ -559,14 +559,15 @@ sub post_invoice { # save detail record in invoice table $query = qq|INSERT INTO invoice (trans_id, parts_id, description, qty, sellprice, fxsellprice, discount, allocated, assemblyitem, - unit, deliverydate, project_id, serialnumber, pricegroup_id) + unit, deliverydate, project_id, serialnumber, pricegroup_id, + ordnumber, transdate, cusordnumber) VALUES ($form->{id}, $form->{"id_$i"}, '$form->{"description_$i"}', $form->{"qty_$i"}, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated, 'f', '$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'), - '$form->{"serialnumber_$i"}', - '$pricegroup_id')|; + '$form->{"serialnumber_$i"}', '$pricegroup_id', + '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}')|; $dbh->do($query) || $form->dberror($query); if ($form->{lizenzen}) { @@ -802,8 +803,9 @@ sub post_invoice { # set values which could be empty to 0 $form->{terms} *= 1; $form->{taxincluded} *= 1; - my $datepaid = ($form->{paid}) ? qq|'$form->{datepaid}'| : "NULL"; - my $duedate = ($form->{duedate}) ? qq|'$form->{duedate}'| : "NULL"; + my $datepaid = ($form->{paid}) ? qq|'$form->{datepaid}'| : "NULL"; + my $duedate = ($form->{duedate}) ? qq|'$form->{duedate}'| : "NULL"; + my $deliverydate = ($form->{deliverydate}) ? qq|'$form->{deliverydate}'| : "NULL"; # fill in subject if there is none $form->{subject} = qq|$form->{label} $form->{invnumber}| @@ -836,6 +838,7 @@ Message: $form->{message}\r| if $form->{message}; paid = $form->{paid}, datepaid = $datepaid, duedate = $duedate, + deliverydate = $deliverydate, invoice = '1', shippingpoint = '$form->{shippingpoint}', shipvia = '$form->{shipvia}', @@ -1161,7 +1164,7 @@ sub retrieve_invoice { # retrieve invoice $query = qq|SELECT a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber, - a.transdate AS invdate, a.paid, + a.transdate AS invdate, a.deliverydate, a.paid, a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.duedate, a.taxincluded, a.curr AS currency, a.employee_id, e.name AS employee @@ -1219,7 +1222,8 @@ sub retrieve_invoice { i.discount, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, pr.projectnumber, i.serialnumber, p.partnumber, p.assembly, p.bin, p.notes AS partnotes, i.id AS invoice_pos, - pg.partsgroup, i.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=i.pricegroup_id) as pricegroup + pg.partsgroup, i.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=i.pricegroup_id) as pricegroup, + i.ordnumber, i.transdate, i.cusordnumber FROM invoice i JOIN parts p ON (i.parts_id = p.id) LEFT JOIN project pr ON (i.project_id = pr.id)