X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=402df0d289499d82cfa23d61273aece22cdb6490;hb=84bed7a655edfe816ad2a04b5549b6bd6a968c79;hp=6c0f71b10cecb5d5864aa2f56bbcff0ff35cf166;hpb=15d5b55d84399cc17b24c7800a5faeeb02a665bf;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index 6c0f71b10..402df0d28 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -382,8 +382,12 @@ sub invoice_details { $form->{paid} += $form->parse_amount($myconfig, $form->{"paid_$i"}); } } - - $form->{subtotal} = $form->format_amount($myconfig, $form->{total}, 2); + if($form->{taxincluded}) { + $form->{subtotal} = $form->format_amount($myconfig, $form->{total} - $tax, 2); + } + else { + $form->{subtotal} = $form->format_amount($myconfig, $form->{total}, 2); + } $yesdiscount = $form->{nodiscount_total} - $nodiscount; $form->{nodiscount_subtotal} = $form->format_amount($myconfig, $form->{nodiscount_total}, 2); $form->{discount_total} = $form->format_amount($myconfig, $form->{discount_total}, 2); @@ -707,9 +711,8 @@ sub post_invoice { $sth->execute || $form->dberror($query); if ($sth->fetchrow_array) { - $form->update_balance($dbh, "parts", "onhand", - qq|id = $form->{"id_$i"}|, - $baseqty * -1) + $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, + $baseqty * -1, $form->{"id_$i"}) unless $form->{shipped}; } $sth->finish; @@ -717,9 +720,8 @@ sub post_invoice { # record assembly item as allocated &process_assembly($dbh, $form, $form->{"id_$i"}, $baseqty); } else { - $form->update_balance($dbh, "parts", "onhand", - qq|id = $form->{"id_$i"}|, - $baseqty * -1) + $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, + $baseqty * -1, $form->{"id_$i"}) unless $form->{shipped}; $allocated = &cogs($dbh, $form, $form->{"id_$i"}, $baseqty, $basefactor, $i); @@ -1050,6 +1052,7 @@ Message: $form->{message}\r| if $form->{message}; delivery_customer_id = $form->{delivery_customer_id}, delivery_vendor_id = $form->{delivery_vendor_id}, employee_id = $form->{employee_id}, + salesman_id = | . conv_i($form->{salesman_id}, 'NULL') . qq|, storno = '$form->{storno}', globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|, cp_id = | . conv_i($form->{"cp_id"}, 'NULL') . qq| @@ -1482,7 +1485,7 @@ sub retrieve_invoice { a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.gldate, a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.taxzone_id, a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id, - a.employee_id, e.name AS employee, a.payment_id, a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type + a.employee_id, e.name AS employee, a.salesman_id, a.payment_id, a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type FROM ar a LEFT JOIN employee e ON (e.id = a.employee_id) WHERE a.id = $form->{id}|; @@ -1685,7 +1688,8 @@ sub get_customer { c.email, c.cc, c.bcc, c.language_id, c.payment_id AS customer_payment_id, c.street, c.zipcode, c.city, c.country, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, c.notes AS intnotes, - b.discount AS tradediscount, b.description AS business, c.klass as customer_klass, c.taxzone_id + b.discount AS tradediscount, b.description AS business, c.klass as customer_klass, c.taxzone_id, + c.salesman_id FROM customer c LEFT JOIN business b ON (b.id = c.business_id) LEFT JOIN payment_terms pt ON c.payment_id = pt.id @@ -1694,12 +1698,12 @@ sub get_customer { map { $form->{$_} = $ref->{$_} } keys %$ref; my $query = qq|SELECT sum(a.amount - a.paid) AS dunning_amount FROM ar a - WHERE a.paid < a.amount AND a.customer_id = ? AND a.dunning_id IS NOT NULL|; + WHERE a.paid < a.amount AND a.customer_id = ? AND a.dunning_config_id IS NOT NULL|; $ref = selectfirst_hashref_query($form, $dbh, $query, $form->{customer_id}); map { $form->{$_} = $ref->{$_} } keys %$ref; my $query = qq|SELECT dnn.dunning_description AS max_dunning_level FROM dunning_config dnn - WHERE id in (SELECT dunning_id from ar WHERE paid < amount AND customer_id = ? AND dunning_id IS NOT NULL) + WHERE id in (SELECT dunning_config_id from ar WHERE paid < amount AND customer_id = ? AND dunning_config_id IS NOT NULL) ORDER BY dunning_level DESC LIMIT 1|; $ref = selectfirst_hashref_query($form, $dbh, $query, $form->{customer_id}); map { $form->{$_} = $ref->{$_} } keys %$ref;