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

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



Revision: 3927
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3927&view=rev
Author:   einhverfr
Date:     2011-10-25 14:01:14 +0000 (Tue, 25 Oct 2011)
Log Message:
-----------
Merging from branches/1.3

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/AA.pm
    trunk/UI/Contact/contact.html
    trunk/bin/aa.pl
    trunk/bin/io.pl
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Employee.sql
    trunk/sql/modules/Person.sql

Added Paths:
-----------
    trunk/sql/modules/Budgetting.sql

Property Changed:
----------------
    trunk/
    trunk/LedgerSMB/Scripts/admin.pm
    trunk/LedgerSMB/Scripts/employee.pm
    trunk/sql/upgrade/1.2-1.3-manual.sql


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-3906
   + /branches/1.3:3711-3926

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/Changelog	2011-10-25 14:01:14 UTC (rev 3927)
@@ -9,6 +9,13 @@
 Initial Release:  Monday, Oct 12 2011
 Supported Presently
 
+Changelog for LedgerSMB 1.3.3
+* Fix for being unable to delete AR/AP drafts (Herman V)
+* Additional button cleanup (Herman V)
+* Fix for is_zero issue with latest Math::BigFloat in AR/AP trans (Chris T)
+* Fix for inability to save employee country (Chris T)
+* API inconsistency fixed (Chris T)
+
 Changelog for LedgerSMB 1.3.2
 * Fixed a few files where suExec fixes were not applied (Chris T)
 * Fixed erroneous buttons marked "Save and Post" showing up (Chris T)
@@ -23,6 +30,7 @@
 * Added check for system configuration before tests begin (Chris T)
 * Clarified password reset interface for user management (Chris T)
 * Added notes on installing on Ubuntu 11.10 (Frans S)
+* Correcting some issues with Perl 5.12 and Math::BigInt (Herman V)
 
 Chris T is Chris Travers
 Herman V is Herman Vierendeels

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/LedgerSMB/AA.pm	2011-10-25 14:01:14 UTC (rev 3927)
@@ -30,6 +30,7 @@
 use LedgerSMB::Sysconfig;
 use LedgerSMB::Log;
 use LedgerSMB::File;
+use Math::BigFloat;
 
 my $logger = Log::Log4perl->get_logger("AA");
 
@@ -747,7 +748,7 @@
 
     $form->audittrail( $dbh, "", \%audittrail );
     my $query = qq|DELETE FROM ac_tax_form WHERE entry_id IN
-                   SELECT entry_id FROM acc_trans WHERE trans_id = ?|;
+                   (SELECT entry_id FROM acc_trans WHERE trans_id = ?)|;
     $dbh->prepare($query)->execute($form->{id}) || $form->dberror($query);
 
     $query = qq|DELETE FROM $table WHERE id = ?|;
@@ -1337,9 +1338,9 @@
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{"$form->{vc}_id"} )
       || $form->dberror($query);
+    my ($credit_rem) = $sth->fetchrow_array;
+    ( $form->{creditremaining} ) -= Math::BigFloat->new($credit_rem);
 
-    ( $form->{creditremaining} ) -= $sth->fetchrow_array;
-
     $sth->finish;
     if ( $form->{vc} ne "customer" ) {
         $form->{vc} = 'vendor';


Property changes on: trunk/LedgerSMB/Scripts/admin.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-3906
/branches/1.3/scripts/admin.pl:3711-3903
   + /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-3926
/branches/1.3/scripts/admin.pl:3711-3903


Property changes on: trunk/LedgerSMB/Scripts/employee.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-3906
/branches/1.3/scripts/employee.pl:3842-3843
   + /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-3926
/branches/1.3/scripts/employee.pl:3842-3843

Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/UI/Contact/contact.html	2011-10-25 14:01:14 UTC (rev 3927)
@@ -8,6 +8,7 @@
 	]
 ?>
 <?lsmb PROCESS 'elements.html' ?>
+<?lsmb IF !country_id; country_id = default_country; END -?>
 <?lsmb 
 # Adding the action requirement to the conditional because otherwise it still
 # breaks.  --CT
@@ -147,12 +148,11 @@
 } ?>
 </div>
 <div class="input_group">
-       <?lsmb IF !country_id; country_id = default_country; END -?>
        <?lsmb country_list.unshift({}) ?>
 		<?lsmb INCLUDE select element_data = {
 			text_attr = "name"
 			value_attr = "id"
-			default_values = [country_id_t]
+			default_values = [country_id]
 			options = country_list
 			name = "country_id"
 			label = text('Country') 
@@ -317,14 +317,13 @@
 	} ?>
 </div>
 <div class="input_group2">
-       <?lsmb IF !country_id_t; country_id_t = default_country; END -?>
        <?lsmb country_list.unshift({}) ?>
 		<?lsmb INCLUDE select element_data = {
 			text_attr = "name"
 			value_attr = "id"
-			default_values = [country_id_t]
+			default_values = [country_id]
 			options = country_list
-			name = "country_id_t"
+			name = "country_id"
 			label = text('Country') 
 	} ?> 
 </div>

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/bin/aa.pl	2011-10-25 14:01:14 UTC (rev 3927)
@@ -992,49 +992,37 @@
                    value => $locale->text('Post as Shown') };
           }
            delete $button{post_as_new};
-           delete $button{print_and_post_as_new};
            delete $button{post};
-           delete $button{print_and_post};
         }
 
         if ($form->{separate_duties} || $form->{batch_id}){
             $button{post}->{value} = $locale->text('Save');
-            $button{print_and_post}->{value} = $locale->text('Save and Post');
             $button{post_as_new}->{value} = $locale->text('Save as New');
-            $button{print_and_post_as_new}->{value} = $locale->text('Save and Post as New');
             $form->hide_form('separate_duties');
         }
         if ( $form->{id} && ($form->{approved} || !$form->{batch_id})) {
             if ( $form->{locked} || ( $transdate && $transdate <= $closedto ) )
             {
-                for ( "post", "print_and_post", "delete" ) {
+                for ( "post","delete" ) {
                     delete $button{$_};
                 }
             }
-
-            if ( !${LedgerSMB::Sysconfig::latex} ) {
-                for ( "print_and_post", "print_and_post_as_new" ) {
-                    delete $button{$_};
-                }
-            }
-
         }
         elsif (!$form->{id}) {
 
-            for ( "post_as_new", "print_and_post_as_new", "delete","save_info",
+            for ( "post_as_new","delete","save_info",
                   "print", 'copy', 'new_screen') {
                 delete $button{$_};
             }
-            delete $button{"print_and_post"} if !${LedgerSMB::Sysconfig::latex};
 
             if ( $transdate && ($transdate <= $closedto) ) {
-                for ( "post", "print_and_post","save_info") { 
+                for ( "post","save_info") { 
                     delete $button{$_};
                 }
             }
         }
         if ($form->{id}){
-            for ( "post_as_new", "print_and_post_as_new"){
+            for ( "post_as_new"){
                delete $button{$_};
             }
             delete $button{'update'} unless $is_draft;
@@ -1219,7 +1207,6 @@
             }
         }
     }
-    $form->debug('/tmp/aa.debug2');
     @taxaccounts = split / /, $form->{taxaccounts};
 
     for (@taxaccounts) {
@@ -2383,7 +2370,7 @@
             $button{'AP--Add Transaction'}{order} = $i++;
             $button{'AP--Vendor Invoice'}{code} =
 qq|<button class="submit" type="submit" name="action" value="vendor_invoice_">|
-              . $locale->text('Vendor Invoice.')
+              . $locale->text('Vendor Invoice')
               . qq|</button> |;
             $button{'AP--Vendor Invoice'}{order} = $i++;
         }

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/bin/io.pl	2011-10-25 14:01:14 UTC (rev 3927)
@@ -241,6 +241,7 @@
         }
         my $moneyplaces = $LedgerSMB::Sysconfig::decimal_places;
         $dec = length $dec;
+        $dec ||= $moneyplaces;
         $form->{"precision_$i"} ||= $dec;
         $dec =  $form->{"precision_$i"};
         $decimalplaces = ( $dec > $moneyplaces ) ? $dec : $moneyplaces;
@@ -261,6 +262,7 @@
                     if ( ( $p * 1 ) && ( $form->{"qty_$i"} >= ( $q * 1 ) ) ) {
                         ($dec) = ( $p =~ /\.(\d+)/ );
                         $dec = length $dec;
+                        $dec ||= $moneyplaces;
                         $decimalplaces = ( $dec > $moneyplaces ) 
                                         ? $dec 
                                         : $moneyplaces;
@@ -644,13 +646,16 @@
             $form->{"partsgroup_$i"} =
               qq|$form->{"new_partsgroup_$j"}--$form->{"new_partsgroup_id_$j"}|;
 
+            my $moneyplaces = $LedgerSMB::Sysconfig::decimal_places;
             ($dec) = ( $form->{"sellprice_$i"} =~ /\.(\d+)/ );
             $dec = length $dec;
-            $decimalplaces1 = ( $dec > 2 ) ? $dec : 2;
+            $dec ||=$moneyplaces;
+            $decimalplaces1 = ( $dec > $moneyplaces ) ? $dec : $moneyplaces;
 
             ($dec) = ( $form->{"lastcost_$i"} =~ /\.(\d+)/ );
             $dec = length $dec;
-            $decimalplaces2 = ( $dec > 2 ) ? $dec : 2;
+            $dec ||=$moneyplaces;
+            $decimalplaces2 = ( $dec > $moneyplaces ) ? $dec : $moneyplaces;
 
             # if there is an exchange rate adjust sellprice
             if ( ( $form->{exchangerate} * 1 ) ) {

Copied: trunk/sql/modules/Budgetting.sql (from rev 3925, addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql)
===================================================================
--- trunk/sql/modules/Budgetting.sql	                        (rev 0)
+++ trunk/sql/modules/Budgetting.sql	2011-10-25 14:01:14 UTC (rev 3927)
@@ -0,0 +1,351 @@
+-- Beginnings of a budget module, released under the GPL v2 or later.
+-- Copyright 2011 The LedgerSMB Core Team 
+-- 
+-- Notes for future versions:
+-- 1:  For 1.4, move to arrays of composites and unnest()
+-- 2:  Move to new input argument semantics
+-- 3:  Add array of composites to budget_info_ext for lines
+-- 4:  Make department_id default to 0 and be not null
+-- 5:  Convert type definitions to views.
+
+
+-- 1.4 note:  Move to Util.sql
+CREATE OR REPLACE FUNCTION project_list_open(in_date date) 
+RETURNS SETOF project AS
+$$ SELECT * FROM project 
+   WHERE $1 BETWEEN coalesce(startdate, $1) AND coalesce(enddate, $1)
+ORDER BY projectnumber;
+$$ language sql;
+
+-- 1.4 note:  Move to Util.sql
+CREATE OR REPLACE FUNCTION department_list()
+RETURNS SETOF department AS
+$$ SELECT * FROM department ORDER BY description $$ language sql;
+
+CREATE TYPE budget_info_ext AS (
+   id INT,
+   start_date date,
+   end_date date ,
+   reference text,
+   description text,
+   entered_by int, 
+   approved_by int,
+   obsolete_by int,
+   entered_at timestamp,
+   approved_at timestamp,
+   obsolete_at timestamp,
+   entered_by_name text,
+   approved_by_name text,
+   obsolete_by_name text,
+   department_id int,
+   department_name text,
+   project_id int,
+   projectnumber text
+);
+
+COMMENT ON TYPE budget_info_ext IS 
+$$ This is the base budget_info type.  In 1.4, it will be renamed budget and
+include an array of lines, but since we support 8.3, we can't do that. 
+
+The id, start_date, end_date, reference, description, entered_by, approved_by,
+entered_at, and approved_at fields reference the budget_info table.  The other
+two fields refer to the possible joins. $$; --'
+
+CREATE OR REPLACE FUNCTION budget__search(
+   in_start_date date,
+   in_end_date date ,
+   in_includes_date date,
+   in_reference text,
+   in_description text,
+   in_entered_by int, 
+   in_approved_by int,
+   in_obsolete_by int,
+   in_department_id int,
+   in_project_id int,
+   in_is_approved bool, in_is_obsolete bool
+) RETURNS SETOF budget_info_ext AS
+$$
+select bi.id, bi.start_date, bi.end_date, bi.reference, bi.description, 
+       bi.entered_by, bi.approved_by, bi.obsolete_by, bi.entered_at, 
+       bi.approved_at, bi.obsolete_at, 
+       ee.name, ae.name, oe.name, bd.department_id, d.description, 
+       bp.project_id, p.projectnumber
+  from budget_info bi 
+  JOIN entity ee ON bi.entered_by = ee.id
+  LEFT JOIN budget_to_department bd ON bd.budget_id = bi.id
+  LEFT JOIN entity ae ON bi.approved_by = ae.id
+  LEFT JOIN entity oe ON bi.obsolete_by = oe.id
+  LEFT JOIN budget_to_project bp ON bp.budget_id = bi.id
+  LEFT JOIN department d ON d.id = bd.department_id
+  LEFT JOIN project p ON bp.project_id = p.id
+ WHERE (start_date = $1 or $1 is null) AND ($2 = end_date or $2 is null) 
+       AND ($3 BETWEEN start_date AND end_date or $2 is null)
+       AND ($4 ilike reference || '%' or $4 is null) 
+       AND (bi.description @@ plainto_tsquery($5) or $5 is null) 
+       AND ($6 = entered_by or $6 is null) 
+       AND ($7 = approved_by or $7 is null) 
+       AND ($8 = obsolete_by or $8 is null) 
+       AND ($9 = department_id OR $9 is null) 
+       AND ($10 = project_id OR  $10 IS NULL)
+       AND ($11 IS NULL OR ($11 = (approved_by IS NOT NULL)))
+       AND ($12 IS NULL OR ($12 = (obsolete_by IS NOT NULL)))
+ ORDER BY department_id, project_id, reference;
+$$ language sql;
+
+COMMENT ON FUNCTION budget__search(
+   in_start_date date,
+   in_end_date date ,
+   in_includes_date date,
+   in_reference text,
+   in_description text,
+   in_entered_by int,
+   in_approved_by int,
+   in_obsolete_by int,
+   in_department_id int,
+   in_project_id int,
+   in_is_approved bool, 
+   in_is_obsolete bool
+)  IS $$ This is a general search for budgets$$;
+
+CREATE OR REPLACE FUNCTION budget__save_info
+(in_id int, in_start_date date, in_end_date date, in_reference text,
+in_description text, in_department_id int, in_project_id int)
+RETURNS budget_info_ext AS
+$$
+DECLARE 
+   retval budget_info_ext;
+   t_id int;
+BEGIN
+  UPDATE budget_info
+     SET start_date = in_start_date,
+         end_date = in_end_date,
+         reference = in_reference,
+         description = in_description
+   WHERE id = in_id and approved_by is null;
+  IF FOUND THEN
+      t_id := in_id;
+  ELSE
+       PERFORM * FROM budget_info WHERE id = in_id and approved_by is not null;
+       IF FOUND THEN
+           RAISE EXCEPTION 'report approved';
+       END IF;
+       INSERT INTO budget_info (start_date, end_date, reference, description)
+            VALUES (in_start_date, in_end_date, in_reference, in_description);
+       t_id = currval('budget_info_id_seq');
+  END IF;
+  IF in_project_id IS NOT NULL THEN
+     UPDATE budget_to_project 
+        SET project_id = in_project_id 
+      WHERE budget_id = t_id;
+
+     IF NOT FOUND THEN
+        INSERT INTO budget_to_project(budget_id, project_id)
+             VALUES (t_id, in_project_id);
+     END IF;
+  END IF;
+  IF in_department_id IS NOT NULL THEN
+     UPDATE budget_to_department 
+        SET department_id = in_department_id 
+      WHERE budget_id = t_id;
+
+     IF NOT FOUND THEN
+        INSERT INTO budget_to_department(budget_id, department_id)
+             VALUES (t_id, in_department_id);
+     END IF;
+  END IF;
+  retval := budget__get_info(t_id);
+  return retval;
+END;
+$$ language plpgsql;
+
+COMMENT ON FUNCTION budget__save_info
+(in_id int, in_start_date date, in_end_date date, in_reference text,
+in_description text, in_department_id int, in_project_id int) IS
+$$Saves the extended budget info passed through to the function.  See the 
+comment on type budget_info_ext for more information.$$;
+
+CREATE OR REPLACE FUNCTION budget__approve(in_id int)
+RETURNS budget_info_ext AS $$
+UPDATE budget_info 
+   set approved_at = now(), approved_by = person__get_my_entity_id()
+ WHERE id = $1;
+
+SELECT budget__get_info($1);
+$$ language sql;
+
+CREATE OR REPLACE FUNCTION budget__save_details(in_id int, in_details text[])
+RETURNS budget_info_ext AS
+$$
+DECLARE
+   loop_count int;
+   retval budget_info_ext;
+BEGIN
+    FOR loop_count in   
+        array_lower(in_details, 1) ..
+        array_upper(in_details, 1)
+    LOOP
+        INSERT INTO budget_line 
+                    (budget_id, 
+                     account_id, 
+                     description, 
+                     amount)
+             VALUES (in_id, 
+                     in_details[loop_count][1]::int, 
+                     in_details[loop_count][2], 
+                     in_details[loop_count][3]::numeric);
+    END LOOP;
+    retval := budget__get_info(in_id);
+    return retval;
+END;
+$$ language plpgsql;
+
+COMMENT ON FUNCTION budget__save_details(in_id int, in_details text[]) IS
+$$ This saves the line items for the budget.  in_details is an array n long
+where each entry is {int account_id, text description, numeric amount}.  The
+in_id parameter is the budget_id.$$;
+
+CREATE OR REPLACE FUNCTION budget__get_info(in_id int)
+returns budget_info_ext AS
+$$ 
+select bi.id, bi.start_date, bi.end_date, bi.reference, bi.description, 
+       bi.entered_by, bi.approved_by, bi.obsolete_by, bi.entered_at, 
+       bi.approved_at, bi.obsolete_at, 
+       ee.name, ae.name, oe.name, bd.department_id, d.description, 
+       bp.project_id, p.projectnumber
+  from budget_info bi
+  JOIN entity ee ON bi.entered_by = ee.id
+  LEFT JOIN budget_to_department bd ON bd.budget_id = bi.id
+  LEFT JOIN entity ae ON bi.approved_by = ae.id
+  LEFT JOIN entity oe ON bi.obsolete_by = oe.id
+  LEFT JOIN budget_to_project bp ON bp.budget_id = bi.id
+  LEFT JOIN department d ON d.id = bd.department_id
+  LEFT JOIN project p ON bp.project_id = p.id
+ where bi.id = $1; 
+$$ language sql;
+
+COMMENT ON FUNCTION budget__get_info(in_id int) IS
+$$ Selects the budget info. $$;
+
+CREATE OR REPLACE FUNCTION budget__get_details(in_id int)
+RETURNS SETOF budget_line AS
+$$
+  SELECT * FROM budget_line where budget_id = $1;
+$$ language sql;
+
+COMMENT ON FUNCTION budget__get_details(in_id int) IS
+$$ This retrieves the budget lines associated with a budget.$$;
+
+CREATE OR REPLACE FUNCTION budget__get_notes(in_id int) 
+RETURNS SETOF budget_note AS
+$$ 
+   SELECT * FROM budget_note WHERE ref_key = $1; 
+$$ LANGUAGE SQL;
+
+COMMENT ON FUNCTION budget__get_notes(in_id int) IS
+$$ Retrieves the notes associated with the budget.$$;
+
+CREATE OR REPLACE FUNCTION budget__save_note
+(in_id int, in_subject text, in_note text)
+RETURNS budget_note AS
+$$
+INSERT INTO budget_note (subject, note, ref_key) 
+     values ($2, $3, $1);
+
+SELECT * FROM budget_note WHERE id = currval('note_id_seq'::regclass);
+$$ language sql;
+
+COMMENT ON FUNCTION budget__save_note
+(in_id int, in_subject text, in_note text) IS
+$$ Saves a note attached to a budget.$$;
+
+CREATE OR REPLACE FUNCTION budget__get_notes(in_id int) 
+RETURNS SETOF budget_note AS
+$$ 
+SELECT * FROM budget_note WHERE ref_key = $1
+ ORDER BY created;
+$$ language sql;
+
+COMMENT ON FUNCTION budget__get_notes(in_id int) IS
+$$ Returns all notes associated with a budget, by default in the order they 
+were created.$$;
+
+CREATE TYPE budget_variance_report AS (
+    accno text,
+    account_label text,
+    account_id int,
+    budget_description text,
+    budget_amount numeric,
+    used_amount numeric,
+    variance numeric
+);
+
+COMMENT ON TYPE budget_variance_report IS
+$$ This is the base type for the budget variance report.$$;
+
+CREATE OR REPLACE FUNCTION budget__variance_report(in_id int) 
+RETURNS SETOF budget_variance_report
+AS
+$$
+   WITH agg_account (amount, id, transdate)
+        AS ( SELECT ac.amount *
+                    CASE WHEN a.contra THEN -1 ELSE 1 END *
+                    CASE WHEN a.category IN ('A', 'E') THEN -1 ELSE 1 END
+                    AS amount,
+                    ac.chart_id, ac.transdate
+               FROM acc_trans ac
+               JOIN account a ON ac.chart_id = a.id
+           )
+   SELECT act.accno, act.description, act.id, b.description, b.amount,
+          coalesce(sum(a.amount), 0), 
+          b.amount - coalesce(sum(a.amount), 0) AS variance
+     FROM budget_info bi
+     JOIN budget_line b ON bi.id = b.budget_id
+     JOIN account act ON act.id = b.account_id
+LEFT JOIN agg_account a ON a.transdate BETWEEN bi.start_date and bi.end_date
+                           AND a.id = b.account_id
+    WHERE bi.id = $1
+ GROUP BY act.accno, act.description, act.id, b.description, b.amount
+ ORDER BY act.accno;
+$$ language sql;
+
+COMMENT ON FUNCTION budget__variance_report(in_id int) IS
+$$ Retrieves a variance report for budget with an id of in_id.$$; 
+
+CREATE OR REPLACE FUNCTION budget__mark_obsolete(in_id int) 
+RETURNS budget_info_ext AS
+$$
+UPDATE budget_info 
+   set obsolete_by = person__get_my_entity_id(), obsolete_at = now()
+ WHERE id = $1 and approved_by is not null;
+SELECT budget__get_info($1)
+$$ language sql;
+
+COMMENT ON FUNCTION budget__mark_obsolete(in_id int) IS
+$$ Marks a budget as obsolete $$;
+
+CREATE OR REPLACE FUNCTION budget__reject(in_id int)
+RETURNS bool AS
+$$
+BEGIN
+
+DELETE FROM budget_line 
+ WHERE budget_id IN (SELECT id from budget_info 
+                      WHERE id = in_id AND approved_by IS NULL);
+
+DELETE FROM budget_to_project
+ WHERE budget_id IN (SELECT id from budget_info 
+                      WHERE id = in_id AND approved_by IS NULL);
+
+DELETE FROM budget_to_department
+ WHERE budget_id IN (SELECT id from budget_info 
+                      WHERE id = in_id AND approved_by IS NULL);
+
+DELETE FROM budget_info WHERE id = in_id AND approved_by IS NULL;
+
+RETURN FOUND;
+END;
+$$ LANGUAGE PLPGSQL SECURITY DEFINER;
+REVOKE EXECUTE ON FUNCTION budget__reject(in_id int) FROM public;
+
+COMMENT ON FUNCTION budget__reject(in_id int) IS
+$$ Deletes unapproved budgets only.$$;

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/sql/modules/Company.sql	2011-10-25 14:01:14 UTC (rev 3927)
@@ -614,7 +614,7 @@
 CREATE OR REPLACE FUNCTION company_save (
     in_id int, in_control_code text, in_entity_class int,
     in_name text, in_tax_id TEXT,
-    in_entity_id int, in_sic_code text,in_country_id_t int
+    in_entity_id int, in_sic_code text,in_country_id int
 ) RETURNS INT AS $$
 DECLARE t_entity_id INT;
 	t_company_id INT;
@@ -638,7 +638,7 @@
 		t_entity_id = in_entity_id;
 	ELSE
 		INSERT INTO entity (name, entity_class, control_code,country_id)
-		VALUES (in_name, in_entity_class, t_control_code,in_country_id_t);
+		VALUES (in_name, in_entity_class, t_control_code,in_country_id);
 		t_entity_id := currval('entity_id_seq');
 	END IF;
 
@@ -661,7 +661,7 @@
 COMMENT ON  FUNCTION company_save (
     in_id int, in_control_code text, in_entity_class int,
     in_name text, in_tax_id TEXT,
-    in_entity_id int, in_sic_code text,in_country_id_t int
+    in_entity_id int, in_sic_code text,in_country_id int
  ) is
 $$ Saves a company.  Returns the id number of the record stored.$$;
 

Modified: trunk/sql/modules/Employee.sql
===================================================================
--- trunk/sql/modules/Employee.sql	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/sql/modules/Employee.sql	2011-10-25 14:01:14 UTC (rev 3927)
@@ -66,6 +66,8 @@
 
 GRANT select ON employees TO public;
 
+DROP TYPE IF EXISTS employee_result CASCADE;
+
 CREATE TYPE employee_result AS (
     entity_id int,
     person_id int,
@@ -82,7 +84,8 @@
     manager_first_name text,
     manager_last_name text,
     employeenumber varchar(32),
-    dob date
+    dob date,
+    country_id int
 );
 
 CREATE OR REPLACE FUNCTION employee__get
@@ -92,9 +95,10 @@
    SELECT p.entity_id, p.id, s.salutation, 
           p.first_name, p.middle_name, p.last_name,
           ee.startdate, ee.enddate, ee.role, ee.ssn, ee.sales, ee.manager_id,
-          mp.first_name, mp.last_name, ee.employeenumber, ee.dob
+          mp.first_name, mp.last_name, ee.employeenumber, ee.dob, e.country_id
      FROM person p
      JOIN entity_employee ee on (ee.entity_id = p.entity_id)
+     JOIN entity e ON (p.entity_id = e.id)
 LEFT JOIN salutation s on (p.salutation_id = s.id)
 LEFT JOIN person mp ON ee.manager_id = p.entity_id
     WHERE p.entity_id = $1;
@@ -113,8 +117,9 @@
 SELECT p.entity_id, p.id, s.salutation,
           p.first_name, p.middle_name, p.last_name,
           ee.startdate, ee.enddate, ee.role, ee.ssn, ee.sales, ee.manager_id,
-          mp.first_name, mp.last_name, ee.employeenumber, ee.dob
+          mp.first_name, mp.last_name, ee.employeenumber, ee.dob, e.country_id
      FROM person p
+     JOIN entity e ON p.entity_id = e.id
      JOIN entity_employee ee on (ee.entity_id = p.entity_id)
 LEFT JOIN salutation s on (p.salutation_id = s.id)
 LEFT JOIN person mp ON ee.manager_id = p.entity_id

Modified: trunk/sql/modules/Person.sql
===================================================================
--- trunk/sql/modules/Person.sql	2011-10-25 13:52:59 UTC (rev 3926)
+++ trunk/sql/modules/Person.sql	2011-10-25 14:01:14 UTC (rev 3927)
@@ -38,7 +38,12 @@
     select * into e from entity where id = in_entity_id and entity_class = 3;
     e_id := in_entity_id; 
     
-    IF NOT FOUND THEN
+    IF FOUND THEN
+        UPDATE entity 
+           SET name = in_first_name || ' ' || in_last_name,
+               country_id = in_country_id
+         WHERE id = in_entity_id; 
+    ELSE
         INSERT INTO entity (name, entity_class, country_id) 
 	values (in_first_name || ' ' || in_last_name, 3, in_country_id);
 	e_id := currval('entity_id_seq');


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-3906
/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-3926
/branches/1.3/sql/upgrade/1.2-1.3.sql:3711-3851
/trunk/sql/upgrade/1.2-1.3.sql:858-3710

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