X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=9a197ab84b9114c4c96c8355db8aacc5aa14100d;hb=3879426c4db6c8a2ff8afa9a98992eeaede38a49;hp=a390f522ff47dc43aff45ee33814592025435933;hpb=3b1eaa1a8b1265a0ecc5a27cf5d557d9e4f8ac46;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index a390f522f..9a197ab84 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -34,7 +34,7 @@ package IS; -use strict; +#use strict; use List::Util qw(max); @@ -143,7 +143,7 @@ sub invoice_details { partnotes serialnumber reqdate sellprice listprice netprice discount p_discount discount_sub nodiscount_sub linetotal nodiscount_linetotal tax_rate projectnumber - price_factor price_factor_name); + price_factor price_factor_name partsgroup); my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber); @@ -196,6 +196,7 @@ sub invoice_details { push @{ $form->{invdate} }, $form->{"invdate"}; push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; push @{ $form->{price_factor_name} }, $price_factor->{description}; + push @{ $form->{partsgroup} }, $form->{"partsgroup_$i"}; if ($form->{lizenzen}) { if ($form->{"licensenumber_$i"}) { @@ -498,7 +499,7 @@ sub post_invoice { if (!$form->{employee_id}) { $form->get_employee($dbh); } - + $form->{defaultcurrency} = $form->get_default_currency($myconfig); ($null, $form->{department_id}) = split(/--/, $form->{department}); @@ -950,6 +951,8 @@ sub post_invoice { $amount = $netamount + $tax; # save AR record + #erweiterung fuer lieferscheinnummer (donumber) 12.02.09 jb + $query = qq|UPDATE ar set invnumber = ?, ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, orddate = ?, quodate = ?, customer_id = ?, @@ -959,24 +962,26 @@ sub post_invoice { curr = ?, department_id = ?, payment_id = ?, taxincluded = ?, type = ?, language_id = ?, taxzone_id = ?, shipto_id = ?, employee_id = ?, salesman_id = ?, storno_id = ?, storno = ?, - cp_id = ?, marge_total = ?, marge_percent = ?, + cp_id = ?, marge_total = ?, marge_percent = ?, globalproject_id = ?, delivery_customer_id = ?, - transaction_description = ?, delivery_vendor_id = ? + transaction_description = ?, delivery_vendor_id = ?, + donumber = ? WHERE id = ?|; @values = ( $form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"}, - conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}), - $amount, $netamount, $form->{"paid"}, conv_date($form->{"datepaid"}), + conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}), + $amount, $netamount, $form->{"paid"}, conv_date($form->{"datepaid"}), conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), '1', $form->{"shippingpoint"}, $form->{"shipvia"}, conv_i($form->{"terms"}), $form->{"notes"}, $form->{"intnotes"}, $form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}), $form->{"taxincluded"} ? 't' : 'f', $form->{"type"}, conv_i($form->{"language_id"}), conv_i($form->{"taxzone_id"}), conv_i($form->{"shipto_id"}), - conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}), conv_i($form->{storno_id}), $form->{"storno"} ? 't' : 'f', + conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}), conv_i($form->{storno_id}), $form->{"storno"} ? 't' : 'f', conv_i($form->{"cp_id"}), 1 * $form->{marge_total} , 1 * $form->{marge_percent}, - conv_i($form->{"globalproject_id"}), conv_i($form->{"delivery_customer_id"}), + conv_i($form->{"globalproject_id"}), conv_i($form->{"delivery_customer_id"}), $form->{transaction_description}, conv_i($form->{"delivery_vendor_id"}), + $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb conv_i($form->{"id"})); do_query($form, $dbh, $query, @values); - + if($form->{"formname"} eq "credit_note") { for my $i (1 .. $form->{rowcount}) { $query = qq|UPDATE parts SET onhand = onhand - ? WHERE id = ?|; @@ -984,7 +989,7 @@ sub post_invoice { do_query($form, $dbh, $query, @values); } } - + if ($form->{storno}) { $query = qq!UPDATE ar SET @@ -1207,6 +1212,9 @@ sub cogs { $main::lxdebug->enter_sub(); my ($dbh, $form, $id, $totalqty, $basefactor, $row) = @_; + + $basefactor ||= 1; + $form->{taxzone_id} *=1; my $transdate = $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date"; my $taxzone_id = $form->{"taxzone_id"} * 1; @@ -1237,7 +1245,7 @@ sub cogs { # total expenses and inventory # sellprice is the cost of the item - my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / $basefactor, 2); + my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( $basefactor || 1 ), 2); if (!$main::eur) { $ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno}; @@ -1384,6 +1392,8 @@ sub retrieve_invoice { my $id = conv_i($form->{id}); # retrieve invoice + #erweiterung um das entsprechende feld lieferscheinnummer (a.donumber) in der html-maske anzuzeigen 12.02.2009 jb + $query = qq|SELECT a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber, @@ -1395,7 +1405,7 @@ sub retrieve_invoice { a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type, a.transaction_description, a.marge_total, a.marge_percent, - e.name AS employee + e.name AS employee, a.donumber FROM ar a LEFT JOIN employee e ON (e.id = a.employee_id) WHERE a.id = ?|; @@ -1431,7 +1441,7 @@ sub retrieve_invoice { my $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate}) : $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date"; - + my $taxzone_id = $form->{taxzone_id} *= 1; $taxzone_id = 0 if (0 > $taxzone_id) || (3 < $taxzone_id); @@ -1481,7 +1491,7 @@ sub retrieve_invoice { LEFT JOIN chart c ON (c.id = t.chart_id) WHERE t.id IN (SELECT tk.tax_id FROM taxkeys tk - WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) + WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) AND startdate <= date($transdate) ORDER BY startdate DESC LIMIT 1) ORDER BY c.accno|; @@ -1687,13 +1697,19 @@ sub retrieve_item { my $where = qq|NOT p.obsolete = '1'|; my @values; - foreach my $column (qw(p.partnumber p.description pgpartsgroup)) { + foreach my $column (qw(p.partnumber p.description pgpartsgroup )) { my ($table, $field) = split m/\./, $column; next if !$form->{"${field}_${i}"}; $where .= qq| AND lower(${column}) ILIKE ?|; push @values, '%' . $form->{"${field}_${i}"} . '%'; } + #Es soll auch nach EAN gesucht werden, ohne Einschränkung durch Beschreibung + if ($form->{"partnumber_$i"} && !$form->{"description_$i"}) { + $where .= qq| OR (NOT p.obsolete = '1' AND p.ean = ? )|; + push @values, $form->{"partnumber_$i"}; + } + if ($form->{"description_$i"}) { $where .= qq| ORDER BY p.description|; } else { @@ -1808,7 +1824,7 @@ sub retrieve_item { my $i = 0; while (my $ptr = $stw->fetchrow_hashref('NAME_lc')) { - # if ($customertax{$ref->{accno}}) + # if ($customertax{$ref->{accno}}) if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { $i++; $ptr->{accno} = $i;