[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4534] branches/1.3



Revision: 4534
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4534&view=rev
Author:   einhverfr
Date:     2012-03-23 10:10:36 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
Search works, though triggers when it shouldn't

Modified Paths:
--------------
    branches/1.3/LedgerSMB/DBObject/Pricelist.pm
    branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
    branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
    branches/1.3/UI/search_results.html
    branches/1.3/sql/modules/Company.sql

Modified: branches/1.3/LedgerSMB/DBObject/Pricelist.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Pricelist.pm	2012-03-23 09:24:22 UTC (rev 4533)
+++ branches/1.3/LedgerSMB/DBObject/Pricelist.pm	2012-03-23 10:10:36 UTC (rev 4534)
@@ -45,14 +45,13 @@
 
 sub save {
     my ($self, $lines) = @_;
-    $self->exec_method({funcname => 'pricelist__clear'});
     for my $ref (@$lines){
-        my $line = $self->new({base => $self, 
+        my $line = __PACKAGE__->new({base => $self, 
                                copy => 'list',  
-                          mergelist => ['entity_class', 'credit_id'], }
+                              merge => ['entity_class', 'credit_id'], }
         );
         $line->merge($ref);
-        $line->exec_method({funcname => 'pricelist__add'});
+        $line->exec_method({funcname => 'pricelist__save'});
     }
     $self->{dbh}->commit;
 }

Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm	2012-03-23 09:24:22 UTC (rev 4533)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search/Part.pm	2012-03-23 10:10:36 UTC (rev 4534)
@@ -9,6 +9,7 @@
 =cut
 
 package LedgerSMB::ScriptLib::Common_Search::Part;
+use base qw(LedgerSMB::ScriptLib::Common_Search);
 use strict;
 use warnings;
 use LedgerSMB::DBObject::Part; 
@@ -70,7 +71,7 @@
 =cut
 
 sub new {
-    my ($self, $request) = @_;
+    my ($pkg, $request) = @_;
     my $self = {};
     bless $self, __PACKAGE__;
     $self->{_part} = LedgerSMB::DBObject::Part->new({base => $request});

Modified: branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm
===================================================================
--- branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm	2012-03-23 09:24:22 UTC (rev 4533)
+++ branches/1.3/LedgerSMB/ScriptLib/Common_Search.pm	2012-03-23 10:10:36 UTC (rev 4534)
@@ -56,9 +56,9 @@
         return $retval;
     } else {
         my @retval;
-        for $row (1 .. $form->{search_rowcount}){
-            next unless $form->{"search_select_$row"};
-            my $id = $form->{"search_select_$row"};
+        for my $row (1 .. $request->{search_rowcount}){
+            next unless $request->{"search_select_$row"};
+            my $id = $request->{"search_select_$row"};
             my $item = {};
             for my $key (keys %$request){
                 if ($key =~ /^search\_.*\_$id$/){

Modified: branches/1.3/UI/search_results.html
===================================================================
--- branches/1.3/UI/search_results.html	2012-03-23 09:24:22 UTC (rev 4533)
+++ branches/1.3/UI/search_results.html	2012-03-23 10:10:36 UTC (rev 4534)
@@ -4,9 +4,9 @@
 PROCESS 'dynatable.html';
 
 IF select_multi ;
-    COLTYPE = 'checkbox'
-ELSE
-    COLTYPE = 'radio'
+    COLTYPE = 'checkbox';
+ELSE;
+    COLTYPE = 'radio';
 END;
 
 columns.unshift({

Modified: branches/1.3/sql/modules/Company.sql
===================================================================
--- branches/1.3/sql/modules/Company.sql	2012-03-23 09:24:22 UTC (rev 4533)
+++ branches/1.3/sql/modules/Company.sql	2012-03-23 10:10:36 UTC (rev 4534)
@@ -1527,7 +1527,7 @@
 END;
 $$ language plpgsql;
 
-CREATE OR REPLACE FUNCTION eca__save_pricematrix
+CREATE OR REPLACE FUNCTION pricelist__save
 (in_parts_id int, in_credit_id int, in_pricebreak numeric, in_price numeric, 
  in_lead_time int2, in_partnumber text, in_validfrom date, in_validto date, 
  in_curr char(3), in_entry_id int)
@@ -1536,15 +1536,16 @@
 DECLARE 
    retval eca__pricematrix;
    t_insert bool;
+   t_entity_class int;
 
 BEGIN
 
 t_insert := false;
 
-PERFORM * FROM entity_credit_account 
-  WHERE id = in_credit_id AND entity_class = 1;
+SELECT entity_class INTO t_entity_class FROM entity_credit_account 
+  WHERE id = in_credit_id;
 
-IF FOUND THEN -- VENDOR
+IF t_entity_class = 1 THEN -- VENDOR
     UPDATE partsvendor
        SET lastcost = in_price,
            leadtime = in_lead_time,
@@ -1568,12 +1569,8 @@
      WHERE parts_id = in_parts_id and credit_id = in_credit_id;
 
     RETURN retval;
-END IF;
 
-PERFORM * FROM entity_credit_account
-  WHERE id = in_credit_id AND entity_class = 2;
-
-IF FOUND THEN -- CUSTOMER
+ELSIF t_entity_class = 2 THEN -- CUSTOMER
     UPDATE partscustomer
        SET pricebreak = in_pricebreak,
            sellprice  = in_price,
@@ -1604,11 +1601,20 @@
                            
     RETURN retval;
 
-END IF;
+ELSE
 
 RAISE EXCEPTION 'No valid entity credit account found';
-   
+
+END IF;
 END;
 $$ LANGUAGE PLPGSQL;
 
+CREATE OR REPLACE FUNCTION pricelist__delete(entry_id int, credit_id int)
+returns bool as
+$$
+delete from partscustomer where entry_id = $1 and credit_id = $2;
+delete from partsvendor where entry_id = $1 and credit_id = $2;
+select true;
+$$ language sql;
+
 COMMIT;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.