]> wagnertech.de Git - mfinanz.git/commitdiff
Merge branch 'ir_templates'
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 30 Dec 2009 15:26:04 +0000 (16:26 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 30 Dec 2009 15:26:04 +0000 (16:26 +0100)
Conflicts:
SL/OP.pm

1  2 
SL/CP.pm
SL/IC.pm
SL/OE.pm
bin/mozilla/cp.pl
bin/mozilla/is.pl

diff --combined SL/CP.pm
index e29622fb3d522c220186371c282637771df246bc,64fd988c5de903d445fddb449e6539c8667085c2..b7e6241de7b84d1971a7c5ed19ebf2ad307693c4
+++ b/SL/CP.pm
@@@ -164,9 -164,9 +164,9 @@@ sub get_openinvoices 
  
    my $query =
       qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, a.curr | .
-          qq|FROM $arap a | .
+      qq|FROM $arap a | .
       qq|WHERE (a.${vc}_id = ?) AND (a.curr = ? $curr_null) AND NOT (a.amount = paid)| .
-                qq|ORDER BY a.id|;
+      qq|ORDER BY a.id|;
    my $sth = prepare_execute_query($form, $dbh, $query,
                                    conv_i($form->{"${vc}_id"}),
                                    $form->{currency});
@@@ -304,7 -304,7 +304,7 @@@ sub process_payment 
            qq|INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, | .
            qq|                       cleared, fx_transaction) | .
            qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?)|;
-                   @values = (conv_i($form->{"id_$i"}), $paymentaccno,
+         @values = (conv_i($form->{"id_$i"}), $paymentaccno,
                     conv_date($form->{datepaid}), ($amount * $ml * -1), '0',
                     '1');
          do_query($form, $dbh, $query, @values);
  
        # update AR/AP transaction
        $query = qq|UPDATE $arap SET $paid, datepaid = ? WHERE id = ?|;
-                 @values = (conv_date($form->{datepaid}), conv_i($form->{"id_$i"}));
+       @values = (conv_date($form->{datepaid}), conv_i($form->{"id_$i"}));
        do_query($form, $dbh, $query, @values);
        # saving the history
        $form->{id} = $form->{"id_$i"};
      }
    }
  
 -  # record a AR/AP with a payment
 -  if ($form->round_amount($paymentamount, 2) > 0) {
 -    $form->{invnumber} = "";
 -    OP::overpayment("", $myconfig, $form, $dbh, $paymentamount, $ml, 1);
 -  }
 -
    my $rc;
    if ($form->round_amount($paymentamount, 2) < 0) {
 -    $dbh->rollback;
 +              # Hier werden negativen Zahlungseingänge abgefangen
 +              # Besser: in Oberfläche schon prüfen
 +              # Zahlungsein- und ausgänge sind immer positiv
 +    $dbh->rollback;   
      $rc = 0;
    }
    if ($form->round_amount($paymentamount, 2) == 0) {
diff --combined SL/IC.pm
index 9cd3ed740c1ca5b89293db0a7473a2354494733e,54cca39dd3caae87c73ee8e5a95468771e4ea5d8..080aedffef7692194d174c99122cfa154c16407b
+++ b/SL/IC.pm
@@@ -497,8 -497,8 +497,8 @@@ sub save 
        if (($form->{"make_$i"}) || ($form->{"model_$i"})) {
  
          $query = qq|INSERT INTO makemodel (parts_id, make, model) | .
-                            qq|VALUES (?, ?, ?)|;
-                   @values = (conv_i($form->{id}), conv_i($form->{"make_$i"}), $form->{"model_$i"});
+                  qq|VALUES (?, ?, ?)|;
+         @values = (conv_i($form->{id}), conv_i($form->{"make_$i"}), $form->{"model_$i"});
  
          do_query($form, $dbh, $query, @values);
        }
        $query =
          qq|INSERT INTO partstax (parts_id, chart_id)
             VALUES (?, (SELECT id FROM chart WHERE accno = ?))|;
-                       @values = (conv_i($form->{id}), $item);
+       @values = (conv_i($form->{id}), $item);
        do_query($form, $dbh, $query, @values);
      }
    }
        if ($form->{"qty_$i"} != 0) {
          $form->{"bom_$i"} *= 1;
          $query = qq|INSERT INTO assembly (id, parts_id, qty, bom) | .
-                            qq|VALUES (?, ?, ?, ?)|;
-                   @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}), conv_i($form->{"qty_$i"}), $form->{"bom_$i"} ? 't' : 'f');
+                  qq|VALUES (?, ?, ?, ?)|;
+         @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}), conv_i($form->{"qty_$i"}), $form->{"bom_$i"} ? 't' : 'f');
          do_query($form, $dbh, $query, @values);
        }
      }
@@@ -937,7 -937,9 +937,9 @@@ sub all_parts 
  
    #my $order_clause = " ORDER BY $form->{sort} $sort_order";
  
-   my $limit_clause = " LIMIT 100" if $form->{top100};
+   my $limit_clause;
+   $limit_clause = " LIMIT 100"                   if $form->{top100};
+   $limit_clause = " LIMIT " . $form->{limit} * 1 if $form->{limit} * 1;
  
    #=== joins and complicated filters ========#
  
    }
  
    $main::lxdebug->leave_sub();
+   return wantarray ? @{ $form->{parts} } : $form->{parts};
  }
  
  sub _create_filter_for_priceupdate {
@@@ -1442,7 -1446,7 +1446,7 @@@ sub follow_account_chain 
      qq|  cnew.accno | .
      qq|FROM chart c | .
      qq|LEFT JOIN chart cnew ON c.new_chart_id = cnew.id | .
 -    qq|WHERE (c.id = ?) AND NOT c.new_chart_id ISNULL AND (c.new_chart_id > 0)|;
 +    qq|WHERE (c.id = ?) AND NOT c.new_chart_id IS NULL AND (c.new_chart_id > 0)|;
    $sth = prepare_query($form, $dbh, $query);
  
    while (1) {
diff --combined SL/OE.pm
index 3f7dbaa75d3f14c97337b88ca245225cd4cc5437,b731dc1cca2bc6834d9f7479cae5676483803b8c..b1e1f9f304e422e2f026c1e3f877458e4790b2e5
+++ b/SL/OE.pm
@@@ -43,20 -43,6 +43,6 @@@ use SL::IC
  
  use strict;
  
- =head1 NAME
- OE.pm - Order entry module
- =head1 DESCRIPTION
- OE.pm is part of the OE module. OE is responsible for sales and purchase orders, as well as sales quotations and purchase requests. This file abstracts the database tables C<oe> and C<orderitems>.
- =head1 FUNCTIONS
- =over 4
- =cut
  sub transactions {
    $main::lxdebug->enter_sub();
  
@@@ -957,22 -943,6 +943,6 @@@ sub retrieve 
    return $rc;
  }
  
- =item retrieve_simple PARAMS
- simple OE retrieval by id. does not look up customer, vendor, units or any other stuff. only oe and orderitems.
-   my $order = retrieve_simple(id => 2);
-   $order => {
-     %_OE_CONTENT,
-     orderitems => [
-       %_ORDERITEM_ROW_1,
-       %_ORDERITEM_ROW_2,
-       ...
-     ]
-   }
- =cut
  sub retrieve_simple {
    $main::lxdebug->enter_sub();
  
@@@ -1227,13 -1197,13 +1197,13 @@@ sub order_details 
          }
  
          $query = qq|SELECT p.partnumber, p.description, p.unit, a.qty, | .
-                      qq|pg.partsgroup | .
-                      qq|FROM assembly a | .
-                            qq|  JOIN parts p ON (a.parts_id = p.id) | .
-                            qq|    LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) | .
-                            qq|    WHERE a.bom = '1' | .
-                            qq|    AND a.id = ? | . $sortorder;
-                   @values = ($form->{"id_$i"});
+                  qq|pg.partsgroup | .
+                  qq|FROM assembly a | .
+                  qq|  JOIN parts p ON (a.parts_id = p.id) | .
+                  qq|    LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) | .
+                  qq|    WHERE a.bom = '1' | .
+                  qq|    AND a.id = ? | . $sortorder;
+         @values = ($form->{"id_$i"});
          $sth = $dbh->prepare($query);
          $sth->execute(@values) || $form->dberror($query);
  
@@@ -1307,37 -1277,37 +1277,70 @@@ sub project_description 
    return $value;
  }
  
 +##########################
 +# Get data for the submitted order id
 +# from database
 +#
 +sub get_order_data_by_ordnumber {
 +  $main::lxdebug->enter_sub();
 +
 +  my $self      = shift;
 +  my %params    = @_;
 +
 +  Common::check_params(\%params, qw(ordnumber));
 +
 +  my $form     = $main::form;
 +  my %myconfig = %main::myconfig;
 +  my $dbh      = $form->get_standard_dbh();
 +
 +  my @values = ($params{ordnumber});
 +
 +  # We query the database for the fields we need using the submitted "ordnumber"
 +  my $query = <<SQL;
 +    SELECT o.payment_id, o.salesman_id, o.transdate AS orddate, o.taxzone_id, o.quonumber
 +    FROM oe o
 +    WHERE o.ordnumber = ?;
 +SQL
 +
 +  # Do the actual query and return the results for later processing by our "frontend"
 +  my $result = selectfirst_hashref_query($form, $dbh, $query, @values);
 +
 +  $main::lxdebug->leave_sub();
 +
 +  return $result;
 +}
 +
  1;
+ __END__
+ =head1 NAME
+ OE.pm - Order entry module
+ =head1 DESCRIPTION
+ OE.pm is part of the OE module. OE is responsible for sales and purchase orders, as well as sales quotations and purchase requests. This file abstracts the database tables C<oe> and C<orderitems>.
+ =head1 FUNCTIONS
+ =over 4
+ =item retrieve_simple PARAMS
+ simple OE retrieval by id. does not look up customer, vendor, units or any other stuff. only oe and orderitems.
+   my $order = retrieve_simple(id => 2);
+   $order => {
+     %_OE_CONTENT,
+     orderitems => [
+       %_ORDERITEM_ROW_1,
+       %_ORDERITEM_ROW_2,
+       ...
+     ]
+   }
+ =back
+ =cut
diff --combined bin/mozilla/cp.pl
index e0c567934e00a523dd18e8eba58bcb55dcc6637b,94f82e694fe8d33fec3502ed2242f52050939a8f..51624331ca34e9127607be5aa77908157e41b5f2
@@@ -32,6 -32,7 +32,6 @@@
  #======================================================================
  
  use SL::CP;
 -use SL::OP;
  use SL::IS;
  use SL::IR;
  
@@@ -144,17 -145,17 +144,17 @@@ sub form_header 
        $form->format_amount(\%myconfig, $form->{exchangerate});
      if ($form->{forex}) {
        $exchangerate = qq|
-             <tr>
-               <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
-               <td colspan=3><input type=hidden name=exchangerate size=10 value=$form->{exchangerate}>$form->{exchangerate}</td>
-             </tr>
+               <tr>
+                 <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
+                 <td colspan=3><input type=hidden name=exchangerate size=10 value=$form->{exchangerate}>$form->{exchangerate}</td>
+               </tr>
  |;
      } else {
        $exchangerate = qq|
-             <tr>
-               <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
-               <td colspan=3><input name=exchangerate size=10 value=$form->{exchangerate}></td>
-             </tr>
+                <tr>
+                 <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
+                 <td colspan=3><input name=exchangerate size=10 value=$form->{exchangerate}></td>
+               </tr>
  |;
      }
    }
@@@ -339,9 -340,9 +339,9 @@@ sub list_invoices 
    <tr>
      <td>
        <table width=100%>
-       <tr>
-         <th class=listheading colspan=$colspan>$invoice</th>
-       </tr>
+         <tr>
+           <th class=listheading colspan=$colspan>$invoice</th>
+         </tr>
  |;
  
    $column_data{invnumber} =
      $j++;
      $j %= 2;
      print qq|
-       <tr class=listrow$j>
+         <tr class=listrow$j>
  |;
      map { print "$column_data{$_}\n" } @column_index;
      print qq|
@@@ -465,7 -466,7 +465,7 @@@ sub form_footer 
      $format .= qq|
              <option value=postscript $form->{DF}{postscript}>|
        . $locale->text('Postscript') . qq|
-           <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF');
+             <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF');
    }
  
    print qq|
diff --combined bin/mozilla/is.pl
index 4a37b7ed9efa4135b502445b2b9cbc9bafd96416,4b9b1a5eb44d56b4b4630c84239ab42bcd68603a..b90209f948f79bd4edf3281eae992348b7b9fab4
@@@ -34,7 -34,6 +34,7 @@@
  use SL::FU;
  use SL::IS;
  use SL::PE;
 +use SL::OE;
  use Data::Dumper;
  use List::Util qw(max sum);
  
@@@ -156,14 -155,6 +156,14 @@@ sub invoice_links 
      $ref->{name} = $form->quote($ref->{name});
    }
  
 +  # Load data for a specific order and update form fields
 +  my $order_data = OE->get_order_data_by_ordnumber(%$form) if $form->{ordnumber};
 +
 +  # Copy the fields we need to %form
 +  for my $key (qw(payment_id salesman_id orddate taxzone_id quonumber)) {
 +    $form->{$key} = $order_data->{$key};
 +  }
 +
    $form->restore_vars(qw(id));
  
    IS->retrieve_invoice(\%myconfig, \%$form);
    $form->restore_vars(qw(taxincluded)) if $form->{id};
    $form->restore_vars(qw(salesman_id)) if $main::editing;
  
 +
    # build vendor/customer drop down comatibility... don't ask
    if (@{ $form->{"all_customer"} }) {
      $form->{"selectcustomer"} = 1;
@@@ -293,7 -283,6 +293,6 @@@ sub form_header 
    $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
  
    $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
-   $form->{radier}          = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
  
    my $set_duedate_url = "$form->{script}?action=set_duedate";
  
                     "taxzones"      => "ALL_TAXZONES",
                     "currencies"    => "ALL_CURRENCIES",
                     "customers"     => "ALL_CUSTOMERS",
+                    "departments"   => "all_departments",
                     "price_factors" => "ALL_PRICE_FACTORS");
  
    $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
@@@ -917,10 -907,10 +917,10 @@@ sub yes 
  
    if (IS->delete_invoice(\%myconfig, \%$form, $main::spool)) {
      # saving the history
-       if(!exists $form->{addition}) {
+     if(!exists $form->{addition}) {
      $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
-         $form->{addition} = "DELETED";
-         $form->save_history($form->dbconnect(\%myconfig));
+       $form->{addition} = "DELETED";
+       $form->save_history($form->dbconnect(\%myconfig));
      }
      # /saving the history
      $form->redirect($locale->text('Invoice deleted!'));