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

SF.net SVN: ledger-smb:[4906] trunk



Revision: 4906
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4906&view=rev
Author:   einhverfr
Date:     2012-06-18 06:07:47 +0000 (Mon, 18 Jun 2012)
Log Message:
-----------
DB Creation now works again in trunk

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/DBObject/Admin.pm
    trunk/LedgerSMB/DBObject/Report/Contact/History.pm
    trunk/LedgerSMB/DBObject_Moose.pm
    trunk/LedgerSMB/Sysconfig.pm
    trunk/LedgerSMB/Template/CSV.pm
    trunk/bin/is.pl
    trunk/doc/release_notes
    trunk/doc/samples/recon_csv.pl
    trunk/lsmb-request.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Roles.sql
    trunk/t/04-template-handling.t

Property Changed:
----------------
    trunk/
    trunk/LedgerSMB/Scripts/account.pm
    trunk/LedgerSMB/Scripts/admin.pm
    trunk/LedgerSMB/Scripts/contact.pm
    trunk/LedgerSMB/Scripts/employee.pm
    trunk/LedgerSMB/Scripts/file.pm
    trunk/LedgerSMB/Scripts/journal.pm
    trunk/LedgerSMB/Scripts/login.pm
    trunk/LedgerSMB/Scripts/menu.pm
    trunk/LedgerSMB/Scripts/payment.pm
    trunk/LedgerSMB/Scripts/recon.pm
    trunk/LedgerSMB/Scripts/setup.pm
    trunk/LedgerSMB/Scripts/taxform.pm
    trunk/sql/upgrade/1.2-1.3-manual.sql


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-4890
   + /branches/1.3:3711-4904

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/Changelog	2012-06-18 06:07:47 UTC (rev 4906)
@@ -70,8 +70,16 @@
 * Added fs_cssdir config option for easier packaging (Chris T, h/t Robert C)
 * Fixed discarded input/bad label on 1.2 upgrade screen (Chris T, h/t Robert C)
 * Fixed encoding of attachment retrieval (Chris T h/t Erik H)
-* Fixed missing grant on partsnumber_entry_id_seq (Chris T, h/t Brian W)
+* Fixed missing grant on partsvendor_entry_id_seq (Chris T, h/t Brian W)
+* Fixed voiding invoice duplicates payment (Chris T h/t John L)
 
+Brian W is Brian Wolf
+Chris T is Chris Travers
+Erik H is Erik Huelsmann
+Nigel T is Nigel Titley
+Robert C is Robert James Clay
+
+
 Changelog for 1.3.18
 * Fixed missing template for CSV pricelists (Chris T)
 * Added ODS pricelists (Chris T)

Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2012-06-18 06:07:47 UTC (rev 4906)
@@ -31,7 +31,7 @@
 
 use LedgerSMB::Location;
 use LedgerSMB::Contact;
-use LedgerSMB::DBObject::Employee;
+use LedgerSMB::DBObject::Entity::Person::Employee;
 use LedgerSMB::DBObject::User;
 use Log::Log4perl;
 use strict;
@@ -75,7 +75,8 @@
 
     # I deleted some assignments which didn't play well with strict mode
     # and by my reading probably broke things. --CT
-    my $employee = LedgerSMB::DBObject::Employee->new( base=>$self);
+    $self->{control_code} = $self->{employeenumber};
+    my $employee = LedgerSMB::DBObject::Entity::Person::Employee->new(%$self);
     if (!$employee->{entity_id}){
          $employee->save();
     }

Modified: trunk/LedgerSMB/DBObject/Report/Contact/History.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Report/Contact/History.pm	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/LedgerSMB/DBObject/Report/Contact/History.pm	2012-06-18 06:07:47 UTC (rev 4906)
@@ -61,7 +61,7 @@
          {col_id => 'invnumber',
             type => 'href',
        href_base => 'is.pl?action=edit&id=',
-            name => $locale->text('Account Number') },
+            name => $locale->text('Invoice Number') },
 
          {col_id => 'curr',
             type => 'text',
@@ -149,7 +149,7 @@
 
 =cut
 
-has account_class => (is => 'ro', isa => 'Int');
+has entity_class => (is => 'ro', isa => 'Int');
 
 =item name
 
@@ -348,7 +348,7 @@
 
 sub run_report {
     my ($self) = @_;
-    my $proc = 'company__history';
+    my $proc = 'eca__history';
     $proc .= '_summary' if $self->is_summary; 
     my @rows = $self->exec_method({funcname => $proc});
     for my $r(@rows){

Modified: trunk/LedgerSMB/DBObject_Moose.pm
===================================================================
--- trunk/LedgerSMB/DBObject_Moose.pm	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/LedgerSMB/DBObject_Moose.pm	2012-06-18 06:07:47 UTC (rev 4906)
@@ -54,15 +54,11 @@
 sub __validate__ {}
 
 has 'dbh' => (is => 'ro', isa => 'DBI::db', required => '1');
-has '_user' => (is => 'ro', isa => 'LedgerSMB::User', required => '1');
-has '_locale' => (is => 'ro', isa => 'LedgerSMB::Locale', required => '1');
 
 sub prepare_dbhash {
     my $self = shift;
     my $target = shift;
     $target->{dbh} = $LedgerSMB::App_State::DBH;
-    $target->{_user} = $LedgerSMB::App_State::User;
-    $target->{_locale} = $LedgerSMB::App_State::Locale;
 }
 
 # _to_dbobject 


Property changes on: trunk/LedgerSMB/Scripts/account.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/account.pm:3712-4890
/branches/1.3/scripts/account.pl:3711-4368
   + /branches/1.3/LedgerSMB/Scripts/account.pm:3712-4904
/branches/1.3/scripts/account.pl:3711-4368


Property changes on: trunk/LedgerSMB/Scripts/admin.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/admin.pm:3712-4890
/branches/1.3/scripts/admin.pl:3711-4678
   + /branches/1.3/LedgerSMB/Scripts/admin.pm:3712-4904
/branches/1.3/scripts/admin.pl:3711-4678


Property changes on: trunk/LedgerSMB/Scripts/contact.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/contact.pm:4783-4890
/branches/1.3/LedgerSMB/Scripts/customer.pm:3712-4782
/branches/1.3/scripts/customer.pl:4273-4287
   + /branches/1.3/LedgerSMB/Scripts/contact.pm:4783-4904
/branches/1.3/LedgerSMB/Scripts/customer.pm:3712-4782
/branches/1.3/scripts/customer.pl:4273-4287


Property changes on: trunk/LedgerSMB/Scripts/employee.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-4890
/branches/1.3/scripts/employee.pl:3842-3843,4273-4287,4289-4310
   + /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-4904
/branches/1.3/scripts/employee.pl:3842-3843,4273-4287,4289-4310


Property changes on: trunk/LedgerSMB/Scripts/file.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4890
/branches/1.3/scripts/file.pl:3711-4880
   + /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4904
/branches/1.3/scripts/file.pl:3711-4880


Property changes on: trunk/LedgerSMB/Scripts/journal.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/journal.pm:3712-4890
/branches/1.3/scripts/journal.pl:3711-4328
   + /branches/1.3/LedgerSMB/Scripts/journal.pm:3712-4904
/branches/1.3/scripts/journal.pl:3711-4328


Property changes on: trunk/LedgerSMB/Scripts/login.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/login.pm:3712-4890
/branches/1.3/scripts/login.pl:3711-4192
   + /branches/1.3/LedgerSMB/Scripts/login.pm:3712-4904
/branches/1.3/scripts/login.pl:3711-4192


Property changes on: trunk/LedgerSMB/Scripts/menu.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/menu.pm:3712-4890
/branches/1.3/scripts/menu.pl:3711-4192,4273-4287
   + /branches/1.3/LedgerSMB/Scripts/menu.pm:3712-4904
/branches/1.3/scripts/menu.pl:3711-4192,4273-4287


Property changes on: trunk/LedgerSMB/Scripts/payment.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/payment.pm:3712-4890
/branches/1.3/scripts/payment.pl:3711-4680
   + /branches/1.3/LedgerSMB/Scripts/payment.pm:3712-4904
/branches/1.3/scripts/payment.pl:3711-4680


Property changes on: trunk/LedgerSMB/Scripts/recon.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/recon.pm:3711-4890
/branches/1.3/scripts/recon.pl:4194-4271,4273-4287,4393-4438
   + /branches/1.3/LedgerSMB/Scripts/recon.pm:3711-4904
/branches/1.3/scripts/recon.pl:4194-4271,4273-4287,4393-4438


Property changes on: trunk/LedgerSMB/Scripts/setup.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/setup.pm:3712-4890
/branches/1.3/scripts/setup.pl:3711-4550
   + /branches/1.3/LedgerSMB/Scripts/setup.pm:3712-4904
/branches/1.3/scripts/setup.pl:3711-4550


Property changes on: trunk/LedgerSMB/Scripts/taxform.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/taxform.pm:3712-4890
/branches/1.3/scripts/taxform.pl:3711-4192,4273-4287
   + /branches/1.3/LedgerSMB/Scripts/taxform.pm:3712-4904
/branches/1.3/scripts/taxform.pl:3711-4192,4273-4287

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/LedgerSMB/Sysconfig.pm	2012-06-18 06:07:47 UTC (rev 4906)
@@ -83,7 +83,7 @@
 our $smtpauthmethod = '';
 
 # set language for login and admin
-our $language = "";
+our $language = "en";
 
 # Maximum number of invoices that can be printed on a check
 our $check_max_invoices = 5;

Modified: trunk/LedgerSMB/Template/CSV.pm
===================================================================
--- trunk/LedgerSMB/Template/CSV.pm	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/LedgerSMB/Template/CSV.pm	2012-06-18 06:07:47 UTC (rev 4906)
@@ -79,7 +79,6 @@
 		$vars =~ s/(^ +| +$)//g;
 		$vars =~ s/"/""/g;
 		$vars = qq|"$vars"| if $vars =~ /[^0-9.+-]/;
-                warn $vars;
 	} else { # hashes and objects
 		for ( keys %{$rawvars} ) {
 			$vars->{$_} = preprocess( $rawvars->{$_} );

Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/bin/is.pl	2012-06-18 06:07:47 UTC (rev 4906)
@@ -607,6 +607,13 @@
     }
     $form->{invnumber} .= '-VOID';
     $form->{reverse} = 1;
+    $form->{paidaccounts} = 1;
+    if ($form->{paid_1}){
+        warn $locale->text(
+             'Payments associated with voided invoice may need to be reversed.'
+        );
+        delete $form->{paid_1};
+    }
     &post_as_new;
 }
 

Modified: trunk/doc/release_notes
===================================================================
--- trunk/doc/release_notes	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/doc/release_notes	2012-06-18 06:07:47 UTC (rev 4906)
@@ -1,7 +1,7 @@
 RELEASE NOTES
 LedgerSMB 1.3
 
-Latest Revision:  1.3.18, May 18, 2012.
+Latest Revision:  1.3.19, June 17, 2012.
 
 1:  Welcome to LedgerSMB
 

Modified: trunk/doc/samples/recon_csv.pl
===================================================================
--- trunk/doc/samples/recon_csv.pl	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/doc/samples/recon_csv.pl	2012-06-18 06:07:47 UTC (rev 4906)
@@ -1,7 +1,5 @@
 # This is a simple CSV parsing routine.  The API isn't perfect and is likely to
-# change in the future.  Right now the function is parse_[account_id] which may 
-# break where multiple banks are used along with multiple databases.  In the 
-# In the future it is likely to change to parse_[dbname]_[account_id]
+# change in the future.  Right now the function is parse_[dbname]_[account_id].
 #
 # COPYRIGHT (c) 2012 Chris Travers (..hidden..)
 # All rights reserved.

Modified: trunk/lsmb-request.pl
===================================================================
--- trunk/lsmb-request.pl	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/lsmb-request.pl	2012-06-18 06:07:47 UTC (rev 4906)
@@ -68,6 +68,7 @@
 } else {
     $locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} )
        or $request->error( __FILE__ . ':' . __LINE__ . ": Locale not loaded: $!\n" );
+    $LedgerSMB::App_State::Locale = $locale;
 }
 
 if (!$script){

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/sql/Pg-database.sql	2012-06-18 06:07:47 UTC (rev 4906)
@@ -72,7 +72,7 @@
   id serial not null unique,
   accno text primary key,
   description text,
-  is_temp not null default false bool,
+  is_temp bool not null default false,
   category CHAR(1) NOT NULL,
   gifi_accno text,
   heading int not null references account_heading(id),
@@ -494,31 +494,6 @@
 
 -- BEGIN new entity management
 
-CREATE FUNCTION tg_enforce_perms_eclass () RETURNS TRIGGER AS 
-$$
-DECLARE
-   r_eclass entity_class;
-   roll_pfx text;
-BEGIN;
-IF TG_OP = 'DELETE' THEN
-   RETURN OLD;
-ELSE 
-   SELECT value INTO roll_pfx FROM defaults WHERE setting_key = 'roll_prefix';
-   SELECT * INTO r_eclass from entity_class WHERE id = new.entity_class;
-   IF pg_has_role(SESSION_USER, coalesce(roll_pfx, 
-                                         'lsmb_' || current_database || '__')
-                                || 'contact_class_' || lower(regexp_replace(
-                                                        r_eclass.class, 
-                                                        ' ', 
-                                                        '_') 
-   THEN
-      RETURN NEW;
-   ELSE
-      RAISE EXCEPTION 'Access Denied for class';
-   END IF;
-END;
-$$ LANGUAGE PLPGSQL;
-
 CREATE TABLE entity_class (
   id serial primary key,
   class text check (class ~ '[[:alnum:]_]') NOT NULL,
@@ -541,30 +516,26 @@
   country_id int references country(id) not null,
   PRIMARY KEY(control_code, entity_class));
 
-CREATE TRIGGER eclass_perms_check ON entity 
-BEFORE INSERT OR UPDATE OR DELETE 
-EXECUTE PROCEDURE tg_enforce_perms_eclass;
-  
 COMMENT ON TABLE entity IS $$ The primary entity table to map to all contacts $$;
 COMMENT ON COLUMN entity.name IS $$ This is the common name of an entity. If it was a person it may be Joshua Drake, a company Acme Corp. You may also choose to use a domain such as commandprompt.com $$;
 
 
 ALTER TABLE entity ADD FOREIGN KEY (entity_class) REFERENCES entity_class(id);
 
-INSERT INTO entity_class (id,class) VALUES (1,'Vendor');
-INSERT INTO entity_class (id,class) VALUES (2,'Customer');
-INSERT INTO entity_class (id,class) VALUES (3,'Employee');
-INSERT INTO entity_class (id,class) VALUES (4,'Contact');
-INSERT INTO entity_class (id,class) VALUES (5,'Lead');
-INSERT INTO entity_class (id,class) VALUES (6,'Referral');
-INSERT INTO entity_class (id,class) VALUES (7,'Hot Lead');
-INSERT INTO entity_class (id,class) VALUES (8,'Cold Lead');
+INSERT INTO entity_class (id,class) 
+VALUES (1,'Vendor'),
+       (2,'Customer'),
+       (3,'Employee'),
+       (4,'Contact'),
+       (5,'Lead'),
+       (6,'Referral'),
+       (7,'Hot Lead'),
+       (8,'Cold Lead');
 
 SELECT setval('entity_class_id_seq',8);
 
 -- USERS stuff --
 CREATE TABLE users (
-INSERT INTO entity_class (id,class) VALUES (5,'Lead');
     id serial UNIQUE, 
     username varchar(30) primary key,
     notify_password interval not null default '7 days'::interval,
@@ -873,10 +844,6 @@
     CHECK (ar_ap_account_id IS NOT NULL OR entity_id = 0)
 );
 
-CREATE TRIGGER eclass_perms_check ON entity_credit_account
-BEFORE INSERT OR UPDATE OR DELETE 
-EXECUTE PROCEDURE tg_enforce_perms_eclass;
-  
 COMMENT ON TABLE entity IS $$ The primary entity table to map to all contacts $$;
 COMMENT ON TABLE entity_credit_account IS
 $$This table stores information relating to general relationships regarding 
@@ -1769,7 +1736,7 @@
    transdate date NOT NULL,    
    source text, -- may be null 
    ar_trans_id int,  -- would be null if no items were adjusted down
-   ap_trans_id int,  -- would be null if no items were adjusted up
+   ap_trans_id int  -- would be null if no items were adjusted up
 );
 
 CREATE TABLE inventory_report_line (

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/sql/modules/Company.sql	2012-06-18 06:07:47 UTC (rev 4906)
@@ -86,11 +86,11 @@
  WHERE entity_class = $2 AND meta_number = $1;
 $$ language sql;
 
-CREATE OR REPLACE FUNCTION eca_history
+CREATE OR REPLACE FUNCTION eca__history
 (in_name text, in_meta_number text, in_contact_info text, in_address_line text,
  in_city text, in_state text, in_zip text, in_salesperson text, in_notes text, 
  in_country_id int, in_from_date date, in_to_date date, in_type char(1), 
- in_start_from date, in_start_to date, in_account_class int, 
+ in_start_from date, in_start_to date, in_entity_class int, 
  in_inc_open bool, in_inc_closed bool)
 RETURNS SETOF  eca_history_result AS
 $$
@@ -100,7 +100,7 @@
             i.description, i.qty, i.unit::text, i.sellprice, i.discount, 
             i.deliverydate, null::int as project_id, null::text as projectnumber,
             i.serialnumber, 
-            case when $16 = 1 then xr.buy else xr.sell end as exchange_rate,
+            case when $16 = 1 then ex.buy else ex.sell end as exchange_rate,
             ee.id as salesperson_id, 
             ep.last_name || ', ' || ep.first_name as salesperson_name
      FROM (select * from entity_credit_account 
@@ -162,37 +162,36 @@
 LEFT JOIN exchangerate ex ON (ex.transdate = a.transdate)
 LEFT JOIN entity ee ON (a.person_id = ee.id)
 LEFT JOIN person ep ON (ep.entity_id = ee.id)
-     JOIN exchangerate xr ON a.transdate = xr.transdate
     -- these filters don't perform as well on large databases
     WHERE (e.name ilike '%' || $1 || '%' or $1 is null)
           and ($3 is null or eca.id in 
                  (select credit_id from eca_to_contact
                    where contact ilike '%' || $3 || '%'))
-          and (($4 is null and $5 is null and $6 is null and $7 is null)
-               or eca.id in
-                  (select credit_id from eca_to_location 
-                    where location_id in
-                          (select id from location
-                            where ($4 is null or line_one ilike '%' || $4 || '%'
-                                   or line_two ilike '%' || $4 || '%') 
-                                  and ($5 is null or city 
-                                                     ilike '%' || $5 || '%')
-                                  and ($6 is null or state 
-                                                    ilike '%' || $6 || '%')
-                                  and ($7 is null or mail_code 
-                                                    ilike '%' || $7 || '%')
-                                  and ($10 is null or country_id = $10))
-                   )
-              )
-          and (a.transdate >= $11 or $11 is null)
-          and (a.transdate <= $12 or $12 is null)
-          and (eca.startdate >= $14 or $14 is null)
-          and (eca.startdate <= $15 or $15 is null)
-          and (a.notes @@ plainto_tsquery($9) or $9 is null)
+--          and (($4 is null and $5 is null and $6 is null and $7 is null)
+--               or eca.id in
+--                  (select credit_id from eca_to_location 
+--                    where location_id in
+--                          (select id from location
+--                            where ($4 is null or line_one ilike '%' || $4 || '%'
+--                                   or line_two ilike '%' || $4 || '%') 
+--                                  and ($5 is null or city 
+--                                                     ilike '%' || $5 || '%')
+--                                  and ($6 is null or state 
+--                                                    ilike '%' || $6 || '%')
+--                                  and ($7 is null or mail_code 
+--                                                    ilike '%' || $7 || '%')
+--                                  and ($10 is null or country_id = $10))
+--                   )
+--              )
+--          and (a.transdate >= $11 or $11 is null)
+--          and (a.transdate <= $12 or $12 is null)
+--          and (eca.startdate >= $14 or $14 is null)
+--          and (eca.startdate <= $15 or $15 is null)
+--          and (a.notes @@ plainto_tsquery($9) or $9 is null)
  ORDER BY eca.meta_number;
 $$ LANGUAGE SQL;
 
-COMMENT ON FUNCTION eca_history 
+COMMENT ON FUNCTION eca__history 
 (in_name text, in_meta_number text, in_contact_info text, in_address_line text,
  in_city text, in_state text, in_zip text, in_salesperson text, in_notes text,
  in_country_id int, in_from_date date, in_to_date date, in_type char(1),
@@ -205,7 +204,7 @@
 allow for partial matches.  NULL matches all values.$$;
 
 
-CREATE OR REPLACE FUNCTION eca_history_summary
+CREATE OR REPLACE FUNCTION eca__history_summary
 (in_name text, in_meta_number text, in_contact_info text, in_address_line text,
  in_city text, in_state text, in_zip text, in_salesperson text, in_notes text, 
  in_country_id int, in_from_date date, in_to_date date, in_type char(1), 
@@ -217,13 +216,13 @@
        description, sum(qty), unit, null::numeric, null::numeric, null::date, 
        null::int, null::text, null::text, null::numeric,
        null::int, null::text
-FROM   eca_history($1, $2, $3, $4, $5, $6, $7, $8, $9,
+FROM   eca__history($1, $2, $3, $4, $5, $6, $7, $8, $9,
                    $10, $11, $12, $13, $14, $15, $16, $17, $18)
  group by id, name, meta_number, curr, parts_id, partnumber, description, unit
  order by meta_number;
 $$ LANGUAGE SQL;
 
-COMMENT ON FUNCTION eca_history_summary
+COMMENT ON FUNCTION eca__history_summary
 (in_name text, in_meta_number text, in_contact_info text, in_address_line text,
  in_city text, in_state text, in_zip text, in_salesperson text, in_notes text,
  in_country_id int, in_from_date date, in_to_date date, in_type char(1),

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/sql/modules/Roles.sql	2012-06-18 06:07:47 UTC (rev 4906)
@@ -116,16 +116,16 @@
 INSERT INTO entity_class (id,class) VALUES (7,'Hot Lead');
 INSERT INTO entity_class (id,class) VALUES (8,'Cold Lead');
 
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_vendor' WITH INHERIT NOLOGIN;
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_customer' 
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_vendor" WITH INHERIT NOLOGIN;
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_customer" 
 WITH INHERIT NOLOGIN;
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_employee' 
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_employee" 
 WITH INHERIT NOLOGIN;
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_contact' WITH INHERIT NOLOGIN;
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_lead' WITH INHERIT NOLOGIN;
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_hot_lead' 
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_contact" WITH INHERIT NOLOGIN;
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_lead" WITH INHERIT NOLOGIN;
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_hot_lead" 
 WITH INHERIT NOLOGIN;
-CREATE ROLE 'lsmb_<?lsmb dbname ?>__contact_class_cold_lead'
+CREATE ROLE "lsmb_<?lsmb dbname ?>__contact_class_cold_lead"
 WITH INHERIT NOLOGIN;
 
 INSERT INTO menu_acl (node_id, acl_type, role_name) 
@@ -839,8 +839,9 @@
 GRANT ALL ON parts_id_seq, partsgroup_id_seq TO "lsmb_<?lsmb dbname ?>__part_create";
 GRANT INSERT ON partstax TO "lsmb_<?lsmb dbname ?>__part_create";
 
-GRANT ALL ON partsvendor_entry_id_seq TO "lsmb_<?lsmb dbname ?>__part_create", 
-"lsmb_<?lsmb dbname ?>__contact_create";
+GRANT ALL ON partsvendor_entry_id_seq, partscustomer_entry_id_seq
+TO "lsmb_<?lsmb dbname ?>__part_create", 
+   "lsmb_<?lsmb dbname ?>__contact_create";
 
 INSERT INTO menu_acl (node_id, acl_type, role_name)
 values (77, 'allow', 'lsmb_<?lsmb dbname ?>__part_create');
@@ -1783,3 +1784,40 @@
 values (192, 'allow', 'public');
 INSERT INTO menu_acl (node_id, acl_type, role_name)
 values (193, 'allow', 'public');
+
+-- PERMISSIONS ENFORCEMENT PER ENTITY CLASS
+
+CREATE FUNCTION tg_enforce_perms_eclass () RETURNS TRIGGER AS 
+$$
+DECLARE
+   r_eclass entity_class;
+   roll_pfx text;
+BEGIN
+IF TG_OP = 'DELETE' THEN
+   RETURN OLD;
+ELSE 
+   SELECT value INTO roll_pfx FROM defaults WHERE setting_key = 'roll_prefix';
+   SELECT * INTO r_eclass from entity_class WHERE id = NEW.entity_class;
+   IF pg_has_role(SESSION_USER, coalesce(roll_pfx, 
+                                         'lsmb_' || current_database() || '__')
+                                || 'contact_class_' || lower(regexp_replace(
+                                                        r_eclass.class, 
+                                                        ' ', 
+                                                        '_')))
+   THEN
+      RETURN NEW;
+   ELSE
+      RAISE EXCEPTION 'Access Denied for class';
+   END IF;
+END IF;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER eclass_perms_check 
+BEFORE INSERT OR UPDATE OR DELETE ON entity 
+FOR EACH ROW EXECUTE PROCEDURE tg_enforce_perms_eclass();
+  
+CREATE TRIGGER eclass_perms_check 
+BEFORE INSERT OR UPDATE OR DELETE ON entity_credit_account
+FOR EACH ROW EXECUTE PROCEDURE tg_enforce_perms_eclass();
+  


Property changes on: trunk/sql/upgrade/1.2-1.3-manual.sql
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/sql/upgrade/1.2-1.3-manual.sql:3712-4890
/branches/1.3/sql/upgrade/1.2-1.3.sql:3711-3851
/trunk/sql/upgrade/1.2-1.3.sql:858-3710
   + /branches/1.3/sql/upgrade/1.2-1.3-manual.sql:3712-4904
/branches/1.3/sql/upgrade/1.2-1.3.sql:3711-3851
/trunk/sql/upgrade/1.2-1.3.sql:858-3710

Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t	2012-06-17 10:13:17 UTC (rev 4905)
+++ trunk/t/04-template-handling.t	2012-06-18 06:07:47 UTC (rev 4906)
@@ -58,10 +58,6 @@
 	ok(!defined $trap->die,
 		"AM, check_template_name: Template directory, ${ext}");
 }
-$form->{file} = 'css/apples.txt';
..hidden.. = trap{AM->check_template_name($myconfig, $form)};
-ok(!defined $trap->die,
-	'AM, check_template_name: CSS directory, txt');
 $form->{file} = 'test2/apples.txt';
 @r = trap{AM->check_template_name($myconfig, $form)};
 if ( $expStackTrace == 0 )
@@ -196,8 +192,7 @@
 @r = trap{AM->load_template($myconfig, $form)};
 if ( $expStackTrace == 0 )
 {
-    is($trap->die, 'Error: Template not found.  
-         Perhaps you meant to edit the default template instead?
+    is($trap->die, 'Error: Template not found: t/data/04-not-there.txt
 ');
 }
 else

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