X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIR.pm;h=931df6b4487849d59318ca6814843200f7f7df65;hb=0152cc2e4e1e451cb51d4d3fd8a0e450eff5efcb;hp=5c335ecccbcfecc03be7d1866b27b58860f554de;hpb=61cdba5d566357f3beabe0e7f3f0cb2d7bdccd73;p=kivitendo-erp.git diff --git a/SL/IR.pm b/SL/IR.pm index 5c335eccc..931df6b44 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -42,6 +42,7 @@ use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::DO; use SL::GenericTranslations; +use SL::HTML::Restrict; use SL::IO; use SL::MoreCommon; use SL::DB::Default; @@ -56,6 +57,8 @@ sub post_invoice { # connect to database, turn off autocommit my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig); + my $restricter = SL::HTML::Restrict->create; + $form->{defaultcurrency} = $form->get_default_currency($myconfig); my $defaultcurrency = $form->{defaultcurrency}; @@ -210,7 +213,7 @@ sub post_invoice { # update parts table by setting lastcost to current price, don't allow negative values by using abs $query = qq|UPDATE parts SET lastcost = ? WHERE id = ?|; - @values = (abs($form->{"sellprice_$i"} / $basefactor), conv_i($form->{"id_$i"})); + @values = (abs($fxsellprice * $form->{exchangerate} / $basefactor), conv_i($form->{"id_$i"})); do_query($form, $dbh, $query, @values); # check if we sold the item already and @@ -378,7 +381,7 @@ sub post_invoice { project_id, serialnumber, price_factor_id, price_factor, marge_price_factor) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|; @values = ($invoice_id, conv_i($form->{id}), conv_i($form->{"id_$i"}), - $form->{"description_$i"}, $form->{"longdescription_$i"}, $form->{"qty_$i"} * -1, + $form->{"description_$i"}, $restricter->process($form->{"longdescription_$i"}), $form->{"qty_$i"} * -1, $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated, $form->{"unit_$i"}, conv_date($form->{deliverydate}), conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"}, @@ -686,7 +689,7 @@ sub post_invoice { netamount = ?, paid = ?, duedate = ?, invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?, intnotes = ?, storno_id = ?, storno = ?, - cp_id = ?, employee_id = ?, department_id = ?, + cp_id = ?, employee_id = ?, department_id = ?, delivery_term_id = ?, globalproject_id = ?, direct_debit = ? WHERE id = ?|; @values = ( @@ -695,7 +698,7 @@ sub post_invoice { $netamount, $form->{paid}, conv_date($form->{duedate}), '1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f', $form->{intnotes}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', - conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), + conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), conv_i($form->{delivery_term_id}), conv_i($form->{globalproject_id}), $form->{direct_debit} ? 't' : 'f', conv_i($form->{id}) @@ -717,9 +720,10 @@ sub post_invoice { } - # add shipto $form->{name} = $form->{vendor}; $form->{name} =~ s/--\Q$form->{vendor_id}\E//; + + # add shipto $form->add_shipto($dbh, $form->{id}, "AP"); # delete zero entries @@ -941,7 +945,8 @@ sub retrieve_invoice { $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, orddate, quodate, globalproject_id, ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, - intnotes, (SELECT cu.name FROM currencies cu WHERE cu.id=ap.currency_id) AS currency, direct_debit + intnotes, (SELECT cu.name FROM currencies cu WHERE cu.id=ap.currency_id) AS currency, direct_debit, + delivery_term_id FROM ap WHERE id = ?|; $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); @@ -970,7 +975,7 @@ sub retrieve_invoice { i.id AS invoice_id, i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, i.price_factor_id, i.price_factor, i.marge_price_factor, i.discount, - p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup + p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, pr.projectnumber, pg.partsgroup FROM invoice i JOIN parts p ON (i.parts_id = p.id) @@ -1087,7 +1092,7 @@ sub get_vendor { qq|SELECT v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount, v.creditlimit, v.terms, v.notes AS intnotes, - v.email, v.cc, v.bcc, v.language_id, v.payment_id, + v.email, v.cc, v.bcc, v.language_id, v.payment_id, v.delivery_term_id, v.street, v.zipcode, v.city, v.country, v.taxzone_id, cu.name AS curr, v.direct_debit, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.description AS business @@ -1122,16 +1127,6 @@ sub get_vendor { } $sth->finish(); - # get shipto if we do not convert an order or invoice - if (!$params->{shipto}) { - delete @{$params}{qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail)}; - - $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module= 'CT')|; - $ref = selectfirst_hashref_query($form, $dbh, $query, $vid); - @{$params}{keys %$ref} = @{$ref}{keys %$ref}; - map { $params->{$_} = $ref->{$_} } keys %$ref; - } - if (!$params->{id} && $params->{type} !~ /_(order|quotation)/) { # setup last accounts used $query = @@ -1227,7 +1222,7 @@ sub retrieve_item { my $query = qq|SELECT p.id, p.partnumber, p.description, p.lastcost AS sellprice, p.listprice, - p.unit, p.assembly, p.bin, p.onhand, p.formel, + p.unit, p.assembly, p.onhand, p.formel, p.notes AS partnotes, p.notes AS longdescription, p.not_discountable, p.inventory_accno_id, p.price_factor_id,