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

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



Revision: 4273
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4273&view=rev
Author:   einhverfr
Date:     2012-01-20 23:08:38 +0000 (Fri, 20 Jan 2012)
Log Message:
-----------
Merged from branches/1.3

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/Scripts/recon.pm
    trunk/UI/ca-list-selector.html
    trunk/UI/reconciliation/report.html
    trunk/bin/gl.pl
    trunk/dists/rpm/ledgersmb.spec
    trunk/sql/modules/Drafts.sql
    trunk/sql/modules/Fixes.sql
    trunk/sql/modules/Payment.sql

Property Changed:
----------------
    trunk/
    trunk/LedgerSMB/Scripts/admin.pm
    trunk/LedgerSMB/Scripts/employee.pm
    trunk/LedgerSMB/Scripts/file.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-4262
   + /branches/1.3:3711-4271

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/Changelog	2012-01-20 23:08:38 UTC (rev 4273)
@@ -9,6 +9,14 @@
 Initial Release:  Monday, Oct 12 2011
 Supported Presently
 
+Changelog for 1.3.11
+* Fixed outstanding report for payment reversal and partial payments (Chris T)
+* Fixed handling of non-existing roles in menu grants (Chris T)
+* Added reverse_bank_recs setting for those that want to
+  do recs from bank perspective (Chris T)
+* Added "bank register mode" for account transaction lists (Chris T)
+* Fixed join projection issue in draft search routine (Chris T)
+
 Changelog for 1.3.10
 * Fixes for permissions for exchangerate table (Erik H)
 * Fixes for POS cashier permissions.  (Chris T)

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/LedgerSMB/AA.pm	2012-01-20 23:08:38 UTC (rev 4273)
@@ -937,7 +937,7 @@
             $query = qq|
 		   SELECT a.id, a.invnumber, a.ordnumber, a.transdate,
 		          a.duedate, a.netamount, a.amount::numeric(20,$p), 
-		          sum(a.amount::numeric(20,$p)) 
+		          a.amount::numeric(20,$p)
                              - (sum(acs.amount::numeric(20,$p)) 
                                 * CASE WHEN '$table' = 'ar' THEN -1 ELSE 1 END)
                           AS paid,


Property changes on: trunk/LedgerSMB/Scripts/admin.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-4262
/branches/1.3/scripts/admin.pl:3711-3903
   + /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-4271
/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-4262
/branches/1.3/scripts/employee.pl:3842-3843
   + /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-4271
/branches/1.3/scripts/employee.pl:3842-3843


Property changes on: trunk/LedgerSMB/Scripts/file.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4262
/branches/1.3/scripts/file.pl:3711-4138
   + /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4271
/branches/1.3/scripts/file.pl:3711-4138


Property changes on: trunk/LedgerSMB/Scripts/login.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/login.pm:4193-4262
/branches/1.3/scripts/login.pl:3711-4192
   + /branches/1.3/LedgerSMB/Scripts/login.pm:4193-4271
/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:4155-4262
/branches/1.3/scripts/menu.pl:3711-4192
   + /branches/1.3/LedgerSMB/Scripts/menu.pm:4155-4271
/branches/1.3/scripts/menu.pl:3711-4192


Property changes on: trunk/LedgerSMB/Scripts/payment.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/payment.pm:4010-4262
/branches/1.3/scripts/payment.pl:3711-4263
   + /branches/1.3/LedgerSMB/Scripts/payment.pm:4010-4271
/branches/1.3/scripts/payment.pl:3711-4263

Modified: trunk/LedgerSMB/Scripts/recon.pm
===================================================================
--- trunk/LedgerSMB/Scripts/recon.pm	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/LedgerSMB/Scripts/recon.pm	2012-01-20 23:08:38 UTC (rev 4273)
@@ -21,6 +21,7 @@
 
 use LedgerSMB::Template;
 use LedgerSMB::DBObject::Reconciliation;
+use LedgerSMB::Setting;
 
 use Data::Dumper;
 use strict;
@@ -279,6 +280,10 @@
 sub _display_report {
         my $recon = shift;
         $recon->get();
+        my $setting_handle = LedgerSMB::Setting->new(base => $recon);
+        $recon->{reverse} = $setting_handle->get('reverse_bank_recs');
+        delete $recon->{reverse} unless $recon->{account_info}->{category}
+                                        eq 'A';
         $recon->close_form;
         $recon->open_form({commit => 1});
         $recon->add_entries($recon->import_file('csv_file')) if !$recon->{submitted};


Property changes on: trunk/LedgerSMB/Scripts/recon.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/recon.pm:3711-4262
/branches/1.3/scripts/recon.pl:4194-4263
   + /branches/1.3/LedgerSMB/Scripts/recon.pm:3711-4271
/branches/1.3/scripts/recon.pl:4194-4271


Property changes on: trunk/LedgerSMB/Scripts/setup.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/setup.pm:3937-4262
/branches/1.3/scripts/setup.pl:3711-4216
   + /branches/1.3/LedgerSMB/Scripts/setup.pm:3937-4271
/branches/1.3/scripts/setup.pl:3711-4216


Property changes on: trunk/LedgerSMB/Scripts/taxform.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/taxform.pm:4193-4262
/branches/1.3/scripts/taxform.pl:3711-4192
   + /branches/1.3/LedgerSMB/Scripts/taxform.pm:4193-4271
/branches/1.3/scripts/taxform.pl:3711-4192

Modified: trunk/UI/ca-list-selector.html
===================================================================
--- trunk/UI/ca-list-selector.html	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/UI/ca-list-selector.html	2012-01-20 23:08:38 UTC (rev 4273)
@@ -33,6 +33,17 @@
 	  <th align="right"><?lsmb text('To') ?></th>
 	  <td><?lsmb PROCESS input element_data={class => 'date', name => 'dateto' size => '11', title="yyyy-mm-dd"} ?></td>
 	</tr>
+        <tr>
+           <th align="right" colspan="1"><?lsmb text('Bank Register Mode') ?>
+           </th>
+           <td colspan="1" align="left">
+             <select name="bank_register_mode">
+                  <option value="0"><?lsmb text('No') ?></option>
+                  <option value="1"><?lsmb text('Yes') ?></option>
+             </select>
+           </td>
+           <td colspan=2>(<?lsmb text('Swaps debits and credits to match bank statements') ?>)</td>
+        </tr>
 
 <?lsmb IF form.all_department ?>
         <tr>

Modified: trunk/UI/reconciliation/report.html
===================================================================
--- trunk/UI/reconciliation/report.html	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/UI/reconciliation/report.html	2012-01-20 23:08:38 UTC (rev 4273)
@@ -99,10 +99,18 @@
 			<td><?lsmb row.scn ?> </td>
 			<td><?lsmb row.post_date ?></td>
 			<td><?lsmb row.payee ?></td>
-			<td><?lsmb row.our_debits ?></td>
-			<td><?lsmb row.our_credits ?></td>
-			<td><?lsmb row.their_debits ?></td>
-			<td><?lsmb row.their_credits ?></td>
+			<td><?lsmb IF reverse; row.our_credits;
+                                   ELSE; row.our_debits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.our_debits;
+                                   ELSE; row.our_credits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.their_credits;
+                                   ELSE; row.their_debits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.their_debits;
+                                   ELSE; row.their_credits;
+                                   END; ?></td>
 		</tr>
 	<?lsmb i = i + 1 -?>
 	<?lsmb END ?>
@@ -150,10 +158,18 @@
 			<td><?lsmb row.scn ?> </td>
 			<td><?lsmb row.post_date ?></td>
 			<td><?lsmb row.payee ?></td>
-			<td><?lsmb row.our_debits ?></td>
-			<td><?lsmb row.our_credits ?></td>
-			<td><?lsmb row.their_debits ?></td>
-			<td><?lsmb row.their_credits ?></td>
+			<td><?lsmb IF reverse; row.our_credits;
+                                   ELSE; row.our_debits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.our_debits;
+                                   ELSE; row.our_credits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.their_credits;
+                                   ELSE; row.their_debits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.their_debits;
+                                   ELSE; row.their_credits;
+                                   END; ?></td>
 		</tr>
 	<?lsmb i = i + 1 -?>
 	<?lsmb END -?>
@@ -196,8 +212,12 @@
 			<td><?lsmb row.scn ?> </td>
 			<td><?lsmb row.post_date ?></td>
 			<td><?lsmb row.payee ?></td>
-			<td><?lsmb row.our_debits ?></td>
-			<td><?lsmb row.our_credits ?></td>
+			<td><?lsmb IF reverse; row.our_credits;
+                                   ELSE; row.our_debits;
+                                   END; ?></td>
+			<td><?lsmb IF reverse; row.our_debits;
+                                   ELSE; row.our_credits;
+                                   END; ?></td>
 		</tr>
 	<?lsmb i = i + 1 -?>
 	<?lsmb END ?>

Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/bin/gl.pl	2012-01-20 23:08:38 UTC (rev 4273)
@@ -633,11 +633,16 @@
             push @options, $locale->text('Amount') . " <= $option";
         }
     }
-
     @columns =
       $form->sort_columns(
         qw(transdate id reference description notes source memo debit credit accno gifi_accno department)
       );
+    if ($form->{bank_register_mode}){
+        @columns = $form->sort_columns(
+            qw(transdate id reference description notes source memo credit debit accno
+               gifi_accno department)
+        );
+    }
     pop @columns if $form->{department};
 
     if ( $form->{link} =~ /_paid/ ) {
@@ -645,6 +650,12 @@
           $form->sort_columns(
             qw(transdate id reference description notes source memo cleared debit credit accno gifi_accno)
           );
+        if ($form->{bank_register_mode}){
+            @columns = $form->sort_columns(
+                qw(transdate id reference description notes source memo cleared credit
+                   debit credit accno gifi_accno)
+            );
+        }
         $form->{l_cleared} = "Y";
     }
 
@@ -691,6 +702,10 @@
         balance => 'Balance',
         cleared => 'R'
     };
+    if ($form->{bank_register_mode}){
+        $column_names->{credit} = 'Debit';
+        $column_names->{debit} = 'Credit';
+    }
     my $sort_href = "$href&sort";
     my @sort_columns = qw(id transdate reference source memo description department accno gifi_accno);
 

Modified: trunk/dists/rpm/ledgersmb.spec
===================================================================
--- trunk/dists/rpm/ledgersmb.spec	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/dists/rpm/ledgersmb.spec	2012-01-20 23:08:38 UTC (rev 4273)
@@ -17,7 +17,7 @@
 Requires: perl-File-MimeInfo, perl-IO-stringy
 Requires: perl-MIME-Lite, perl-Class-Std >= 0.0.8
 Requires: perl-Locale-Maketext-Lexicon >= 0.62
-Requires: perl-IO-String perl-Config-Std >= 0.007
+Requires: perl-IO-String 
 Requires: perl-Math-BigInt-GMP
 Requires: perl-Log-Log4perl perl-DateTime
 Requires: perl-Config-Std
@@ -68,7 +68,7 @@
 chmod 0644 $(find . -type f)
 chmod 0755 $(find . -type d)
 chmod +x *.pl
-chmod -x pos.conf.pl custom.pl # FIXME: Config???
+chmod -x custom.pl # FIXME: Config???
 chmod +x utils/*/*.pl utils/devel/find-use utils/pos/pos-hardware-client-startup-script
 
 

Modified: trunk/sql/modules/Drafts.sql
===================================================================
--- trunk/sql/modules/Drafts.sql	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/sql/modules/Drafts.sql	2012-01-20 23:08:38 UTC (rev 4273)
@@ -40,7 +40,7 @@
 			WHERE lower(in_type) = 'ar'
 			) trans
 		JOIN acc_trans line ON (trans.id = line.trans_id)
-		JOIN chart ON (line.chart_id = chart.id)
+		JOIN chart ON (line.chart_id = chart.id and charttype = 'A')
            LEFT JOIN voucher v ON (v.trans_id = trans.id)
 		WHERE (in_from_date IS NULL or trans.transdate >= in_from_date)
 			AND (in_to_date IS NULL 

Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/sql/modules/Fixes.sql	2012-01-20 23:08:38 UTC (rev 4273)
@@ -87,4 +87,154 @@
  SET value = 'ship_order'
  WHERE attribute='type'
        AND node_id = (SELECT id FROM menu_node WHERE label = 'Ship');
-COMMIT;
\ No newline at end of file
+COMMIT;
+
+BEGIN;
+-- fix for non-existant role handling in menu_generate() and related
+
+
+CREATE OR REPLACE FUNCTION menu_generate() RETURNS SETOF menu_item AS 
+$$
+DECLARE 
+	item menu_item;
+	arg menu_attribute%ROWTYPE;
+BEGIN
+	FOR item IN 
+		SELECT n.position, n.id, c.level, n.label, c.path, 
+                       to_args(array[ma.attribute, ma.value])
+		FROM connectby('menu_node', 'id', 'parent', 'position', '0', 
+				0, ',') 
+			c(id integer, parent integer, "level" integer, 
+				path text, list_order integer)
+		JOIN menu_node n USING(id)
+                JOIN menu_attribute ma ON (n.id = ma.node_id)
+               WHERE n.id IN (select node_id 
+                                FROM menu_acl
+                                JOIN (select rolname FROM pg_roles
+                                      UNION 
+                                     select 'public') pgr 
+                                     ON pgr.rolname = role_name
+                               WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
+                                                                    'public') 
+                                                                    = 'public'
+                                                      THEN current_user
+                                                      ELSE pgr.rolname
+                                                   END, 'USAGE')
+                            GROUP BY node_id
+                              HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
+                                                   THEN FALSE
+                                                   WHEN acl_type ilike 'ALLOW'
+                                                   THEN TRUE
+                                                END))
+                    or exists (select cn.id, cc.path
+                                 FROM connectby('menu_node', 'id', 'parent', 
+                                                'position', '0', 0, ',')
+                                      cc(id integer, parent integer, 
+                                         "level" integer, path text,
+                                         list_order integer)
+                                 JOIN menu_node cn USING(id)
+                                WHERE cn.id IN 
+                                      (select node_id FROM menu_acl
+                                        JOIN (select rolname FROM pg_roles
+                                              UNION 
+                                              select 'public') pgr 
+                                              ON pgr.rolname = role_name
+                                        WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
+                                                                    'public') 
+                                                                    = 'public'
+                                                      THEN current_user
+                                                      ELSE pgr.rolname
+                                                   END, 'USAGE')
+                                     GROUP BY node_id
+                                       HAVING bool_and(CASE WHEN acl_type 
+                                                                 ilike 'DENY'
+                                                            THEN false
+                                                            WHEN acl_type 
+                                                                 ilike 'ALLOW'
+                                                            THEN TRUE
+                                                         END))
+                                       and cc.path like c.path || ',%')
+            GROUP BY n.position, n.id, c.level, n.label, c.path, c.list_order
+            ORDER BY c.list_order
+                             
+	LOOP
+		RETURN NEXT item;
+	END LOOP;
+END;
+$$ language plpgsql;
+
+COMMENT ON FUNCTION menu_generate() IS
+$$
+This function returns the complete menu tree.  It is used to generate nested
+menus for the web interface.
+$$;
+
+CREATE OR REPLACE FUNCTION menu_children(in_parent_id int) RETURNS SETOF menu_item
+AS $$
+declare 
+	item menu_item;
+	arg menu_attribute%ROWTYPE;
+begin
+        FOR item IN
+		SELECT n.position, n.id, c.level, n.label, c.path, 
+                       to_args(array[ma.attribute, ma.value])
+		FROM connectby('menu_node', 'id', 'parent', 'position', 
+				in_parent_id, 1, ',') 
+			c(id integer, parent integer, "level" integer, 
+				path text, list_order integer)
+		JOIN menu_node n USING(id)
+                JOIN menu_attribute ma ON (n.id = ma.node_id)
+               WHERE n.id IN (select node_id 
+                                FROM menu_acl
+                                JOIN (select rolname FROM pg_roles
+                                      UNION 
+                                      select 'public') pgr 
+                                      ON pgr.rolname = role_name
+                                WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
+                                                                    'public') 
+                                                                    = 'public'
+                                                               THEN current_user
+                                                               ELSE pgr.rolname
+                                                               END, 'USAGE')
+                            GROUP BY node_id
+                              HAVING bool_and(CASE WHEN acl_type ilike 'DENY'
+                                                   THEN FALSE
+                                                   WHEN acl_type ilike 'ALLOW'
+                                                   THEN TRUE
+                                                END))
+                    or exists (select cn.id, cc.path
+                                 FROM connectby('menu_node', 'id', 'parent', 
+                                                'position', '0', 0, ',')
+                                      cc(id integer, parent integer, 
+                                         "level" integer, path text,
+                                         list_order integer)
+                                 JOIN menu_node cn USING(id)
+                                WHERE cn.id IN 
+                                      (select node_id FROM menu_acl
+                                         JOIN (select rolname FROM pg_roles
+                                              UNION 
+                                              select 'public') pgr 
+                                              ON pgr.rolname = role_name
+                                        WHERE pg_has_role(CASE WHEN coalesce(pgr.rolname,
+                                                                    'public') 
+                                                                    = 'public'
+                                                               THEN current_user
+                                                               ELSE pgr.rolname
+                                                               END, 'USAGE')
+                                     GROUP BY node_id
+                                       HAVING bool_and(CASE WHEN acl_type 
+                                                                 ilike 'DENY'
+                                                            THEN false
+                                                            WHEN acl_type 
+                                                                 ilike 'ALLOW'
+                                                            THEN TRUE
+                                                         END))
+                                       and cc.path like c.path || ',%')
+            GROUP BY n.position, n.id, c.level, n.label, c.path, c.list_order
+            ORDER BY c.list_order
+        LOOP
+                return next item;
+        end loop;
+end;
+$$ language plpgsql;
+COMMIT;

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2012-01-20 13:07:58 UTC (rev 4272)
+++ trunk/sql/modules/Payment.sql	2012-01-20 23:08:38 UTC (rev 4273)
@@ -81,21 +81,13 @@
 		JOIN company cp ON (cp.entity_id = e.id)
 			WHERE ec.entity_class = in_account_class
                         AND CASE WHEN in_account_class = 1 THEN
-	           		ec.id IN (SELECT entity_credit_account
-                                            FROM ap
-                                            JOIN acc_trans ac ON ap.id = ac.trans_id
-                                            JOIN account_link al ON acc.chart_id = al.account_id
-                                           WHERE al.description = 'AP'
-                                           GROUP BY entity_credit_account
-                                           HAVING SUM(ac.amount) <> 0)
+	           		ec.id IN (SELECT entity_credit_account FROM ap 
+	           			WHERE amount <> paid
+		   			GROUP BY entity_credit_account)
 		    	       WHEN in_account_class = 2 THEN
-		   		ec.id IN (SELECT entity_credit_account
-                                            FROM ar
-                                            JOIN acc_trans ac ON ar.id = ac.trans_id
-                                            JOIN account_link al ON acc.chart_id = al.account_id
-                                           WHERE al.description = 'AR'
-                                           GROUP BY entity_credit_account
-                                           HAVING SUM(ac.amount) <> 0)
+		   		ec.id IN (SELECT entity_credit_account FROM ar
+		   			WHERE amount <> paid
+		   			GROUP BY entity_credit_account)
 		   	  END
 	LOOP
 		RETURN NEXT out_entity;
@@ -126,6 +118,14 @@
 
 COMMENT ON FUNCTION payment_get_all_accounts(int) IS
 $$ This function takes a single argument (1 for vendor, 2 for customer as 
+	LOOP
+		RETURN NEXT out_entity;
+	END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMENT ON FUNCTION payment_get_all_accounts(int) IS
+$$ This function takes a single argument (1 for vendor, 2 for customer as 
 always) and returns all entities with accounts of the appropriate type. $$;
 
 DROP TYPE IF EXISTS payment_invoice CASCADE;
@@ -395,16 +395,7 @@
 		   WHERE (a.batch_id = in_batch_id
 		          OR (a.invoice_class = in_account_class
 		             AND a.approved
-			 AND (c.business_id = 
-				coalesce(in_business_id, c.business_id)
-				OR in_business_id is null)
-		         AND ((a.transdate >= COALESCE(in_date_from, a.transdate)
-		               AND a.transdate <= COALESCE(in_date_to, a.transdate)))
-		         AND c.entity_class = in_account_class
-		         AND a.curr = in_currency
-		         AND a.entity_credit_account = c.id
-			 AND p.due <> 0
-                         --### short term: ignore fractional differences
+		         AND a.amount <> a.paid 
 			 AND NOT a.on_hold
 		         AND EXISTS (select trans_id FROM acc_trans
 		                      WHERE trans_id = a.id AND
@@ -510,6 +501,15 @@
 			source)
 		SELECT id, 
 		case when $E$ || quote_literal(in_account_class) || $E$ = 1
+				quote_literal(in_transactions[out_count][2])
+				|| $E$)$E$;
+	END LOOP;
+	EXECUTE $E$ 
+		INSERT INTO acc_trans 
+			(trans_id, chart_id, amount, approved, voucher_id, transdate, 
+			source)
+		SELECT id, 
+		case when $E$ || quote_literal(in_account_class) || $E$ = 1
 			THEN $E$ || t_cash_id || $E$
 			WHEN $E$ || quote_literal(in_account_class) || $E$ = 2 
 			THEN $E$ || t_ar_ap_id || $E$
@@ -1290,6 +1290,30 @@
             
       LOOP
            RETURN NEXT out_overpayment;
+    		WHERE available <> 0 AND in_account_class = payment_class
+        LOOP
+                RETURN NEXT out_entity;
+        END LOOP;
+ END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION payment_get_unused_overpayment(
+in_account_class int, in_entity_credit_id int, in_chart_id int)
+returns SETOF overpayments AS
+$$
+DECLARE out_overpayment overpayments%ROWTYPE;
+BEGIN
+      FOR out_overpayment IN
+              SELECT DISTINCT * 
+              FROM overpayments
+              WHERE payment_class  = in_account_class 
+              AND entity_credit_id = in_entity_credit_id 
+              AND available <> 0
+              AND (in_chart_id IS NULL OR chart_id = in_chart_id )
+              ORDER BY payment_date
+            
+      LOOP
+           RETURN NEXT out_overpayment;
       END LOOP;
 END;
 $$ LANGUAGE PLPGSQL;


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-4262
/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-4271
/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.