Umstellung Form::throw_on_error auf Verwendung von Exception::Lite anstelle von Hashrefs
[kivitendo-erp.git] / SL / IS.pm
index 7087c5a..a940355 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -529,8 +529,12 @@ sub post_invoice {
   }
 
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
-
-  ($null, $form->{department_id}) = split(/--/, $form->{department});
+  # Seit neuestem wird die department_id schon übergeben UND $form->department nicht mehr
+  # korrekt zusammengebaut. Sehr wahrscheinlich beim Umstieg auf T8 kaputt gegangen
+  # Ich lass den Code von 2005 erstmal noch stehen ;-) jb 03-2011
+  if (!$form->{department_id}){
+    ($null, $form->{department_id}) = split(/--/, $form->{department});
+  }
 
   my $all_units = AM->retrieve_units($myconfig, $form);
 
@@ -1005,7 +1009,7 @@ sub post_invoice {
                 cp_id       = ?, marge_total   = ?, marge_percent = ?,
                 globalproject_id               = ?, delivery_customer_id             = ?,
                 transaction_description        = ?, delivery_vendor_id               = ?,
-                donumber    = ?
+                donumber    = ?, invnumber_for_credit_note = ?
               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"}),
@@ -1018,7 +1022,7 @@ sub post_invoice {
                 conv_i($form->{"cp_id"}),            1 * $form->{marge_total} ,      1 * $form->{marge_percent},
                 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
+                       $form->{"donumber"}, $form->{"invnumber_for_credit_note"},
                 conv_i($form->{"id"}));
   do_query($form, $dbh, $query, @values);
 
@@ -1045,7 +1049,7 @@ sub post_invoice {
   # save printed, emailed and queued
   $form->save_status($dbh);
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   # Link this record to the records it was created from.
   RecordLinks->create_links('dbh'        => $dbh,
@@ -1277,7 +1281,7 @@ sub cogs {
     # sellprice is the cost of the item
     my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( ($ref->{price_factor} || 1) * ( $basefactor || 1 )), 2);
 
-    if (!$main::eur) {
+    if (!$::lx_office_conf{system}->{eur}) {
       $ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
       # add to expense
       $form->{amount_cogs}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;
@@ -1362,7 +1366,7 @@ sub reverse_invoice {
 sub delete_invoice {
   $main::lxdebug->enter_sub();
 
-  my ($self, $myconfig, $form, $spool) = @_;
+  my ($self, $myconfig, $form) = @_;
 
   # connect to database
   my $dbh = $form->dbconnect_noauto($myconfig);
@@ -1398,6 +1402,7 @@ sub delete_invoice {
   $dbh->disconnect;
 
   if ($rc) {
+    my $spool = $::lx_office_conf{paths}->{spool};
     map { unlink "$spool/$_" if -f "$spool/$_"; } @spoolfiles;
   }
 
@@ -1447,9 +1452,9 @@ sub retrieve_invoice {
            a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id,
            a.employee_id, a.salesman_id, a.payment_id,
            a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type,
-           a.transaction_description,
+           a.transaction_description, a.donumber, a.invnumber_for_credit_note,
            a.marge_total, a.marge_percent,
-           e.name AS employee, a.donumber
+           e.name AS employee
          FROM ar a
          LEFT JOIN employee e ON (e.id = a.employee_id)
          WHERE a.id = ?|;
@@ -1583,7 +1588,7 @@ sub retrieve_invoice {
     }
     $sth->finish;
 
-    Common::webdav_folder($form) if ($main::webdav);
+    Common::webdav_folder($form);
   }
 
   my $rc = $dbh->commit;
@@ -2080,13 +2085,13 @@ sub get_pricegroups_for_parts {
         # to distinguish case A and B the variable pricegroup_id_$i is used
         # for new articles this variable isn't defined, for loaded articles it is
         # sellprice can't be used, as it already has 0,00 set
-        
+
         if ($pkr->{pricegroup_id} eq $form->{"pricegroup_id_$i"} and defined $form->{"pricegroup_id_$i"}) {
           # Case A
           $pkr->{selected}  = ' selected';
 
-        } elsif ($pkr->{pricegroup_id} eq $form->{customer_klass} 
-                 and not defined $form->{"pricegroup_id_$i"} 
+        } elsif ($pkr->{pricegroup_id} eq $form->{customer_klass}
+                 and not defined $form->{"pricegroup_id_$i"}
                  and $pkr->{price} != 0    # only use customer pricegroup price if it has a value, else use default_sellprice
                                            # for the case where pricegroup prices haven't been set
                 ) {
@@ -2119,7 +2124,9 @@ sub get_pricegroups_for_parts {
           if ($pkr->{pricegroup_id} eq $selectedpricegroup_id) {
             $pkr->{selected}  = ' selected';
           }
-        } elsif (($price_new != $form->{"sellprice_$i"}) and ($price_new ne 0) and defined $price_new) {
+        } elsif ( ($form->parse_amount($myconfig, $price_new)
+                 != $form->parse_amount($myconfig, $form->{"sellprice_$i"})) 
+                  and ($price_new ne 0) and defined $price_new) {
           # sellprice has changed
           # when loading existing invoices $price_new is NULL
           if ($pkr->{pricegroup_id} == 0) {