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

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



Revision: 4439
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4439&view=rev
Author:   einhverfr
Date:     2012-03-11 00:36:00 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
Merging from branches/1.3

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/Scripts/setup.pm
    trunk/UI/reconciliation/search.html
    trunk/UI/reconciliation/upload.html
    trunk/UI/setup/select_coa.html
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Reconciliation.sql

Property Changed:
----------------
    trunk/
    trunk/LedgerSMB/Scripts/account.pm
    trunk/LedgerSMB/Scripts/admin.pm
    trunk/LedgerSMB/Scripts/customer.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/LedgerSMB/Scripts/vendor.pm
    trunk/sql/upgrade/1.2-1.3-manual.sql


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-4434
   + /branches/1.3:3711-4438

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/Changelog	2012-03-11 00:36:00 UTC (rev 4439)
@@ -44,6 +44,7 @@
 * Changes in the single payment UI to minimize mouse movements (Erik H)
 * Adding link to employee edit screen from user page (h/t H Sorli) (Chris T)
 * Fixed: Can't designate managers (Chris T, bug  3486840)
+* Can now skip adding the chart of accounts (Erik H)
 
 Changelog for 1.3.12
 * Corrected processing of <?lsmb tags in order/invoice numbers (Chris T)


Property changes on: trunk/LedgerSMB/Scripts/account.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/account.pm:4369-4434
/branches/1.3/scripts/account.pl:3711-4368
   + /branches/1.3/LedgerSMB/Scripts/account.pm:4369-4438
/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:3901-4434
/branches/1.3/scripts/admin.pl:3711-3903,4273-4287
   + /branches/1.3/LedgerSMB/Scripts/admin.pm:3901-4438
/branches/1.3/scripts/admin.pl:3711-3903,4273-4287


Property changes on: trunk/LedgerSMB/Scripts/customer.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/customer.pm:4288-4434
/branches/1.3/scripts/customer.pl:4273-4287
   + /branches/1.3/LedgerSMB/Scripts/customer.pm:4288-4438
/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-4434
/branches/1.3/scripts/employee.pl:3842-3843,4273-4287,4289-4310
   + /branches/1.3/LedgerSMB/Scripts/employee.pm:3712-4438
/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-4434
/branches/1.3/scripts/file.pl:3711-4138
   + /branches/1.3/LedgerSMB/Scripts/file.pm:3711-4438
/branches/1.3/scripts/file.pl:3711-4138


Property changes on: trunk/LedgerSMB/Scripts/journal.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/journal.pm:4288-4434
/branches/1.3/scripts/journal.pl:3711-4328
   + /branches/1.3/LedgerSMB/Scripts/journal.pm:4288-4438
/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:4193-4434
/branches/1.3/scripts/login.pl:3711-4192
   + /branches/1.3/LedgerSMB/Scripts/login.pm:4193-4438
/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-4434
/branches/1.3/scripts/menu.pl:3711-4192,4273-4287
   + /branches/1.3/LedgerSMB/Scripts/menu.pm:4155-4438
/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:4010-4434
/branches/1.3/scripts/payment.pl:3711-4310
   + /branches/1.3/LedgerSMB/Scripts/payment.pm:4010-4438
/branches/1.3/scripts/payment.pl:3711-4310


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

Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/LedgerSMB/Scripts/setup.pm	2012-03-11 00:36:00 UTC (rev 4439)
@@ -594,6 +594,84 @@
     $template->render($request);
 }
 
+
+=item skip_coa
+
+Entry point when on the CoA selection screen the 'Skip' button
+is being pressed.  This allows the user to load a CoA later.
+
+The CoA loaded at a later time may be a self-defined CoA, i.e. not
+one distributed with the LSMB standard distribution.  The 'Skip'
+button facilitates that scenario.
+
+=cut
+
+sub skip_coa {
+    my ($request) = @_;
+
+    _render_new_user($request);
+}
+
+
+=item _render_new_user
+
+Renders the new user screen. Common functionality to both the
+select_coa and skip_coa functions.
+
+=cut
+
+sub _render_new_user {
+    my ($request) = @_;
+
+    # One thing to remember here is that the setup.pl does not get the
+    # benefit of the automatic db connection.  So in order to build this
+    # form, we have to manage that ourselves. 
+    #
+    # However we get the benefit of having had to set the environment
+    # variables for the Pg connection above, so don't need to pass much
+    # info. 
+    #
+    # Also I am opting to use the lower-level call_procedure interface
+    # here in order to avoid creating objects just to get argument
+    # mapping going. --CT
+
+    my $creds = LedgerSMB::Auth::get_credentials();
+    
+    # ENVIRONMENT NECESSARY
+    $ENV{PGUSER} = $creds->{login};
+    $ENV{PGPASSWORD} = $creds->{password};
+    $ENV{PGDATABASE} = $request->{database};
+
+
+
+
+    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    $request->{dbh}->{AutoCommit} = 0;
+
+    @{$request->{salutations}} 
+    = $request->call_procedure(procname => 'person__list_salutations' ); 
+    
+    @{$request->{countries}} 
+    = $request->call_procedure(procname => 'location_list_country' ); 
+
+    my $locale = $request->{_locale};
+
+    @{$request->{perm_sets}} = (
+        {id => '0', label => $locale->text('Manage Users')},
+        {id => '1', label => $locale->text('Full Permissions')},
+        );
+
+    my $template = LedgerSMB::Template->new(
+        path => 'UI/setup',
+        template => 'new_user',
+        format => 'HTML',
+           );
+
+    $template->render($request);
+}
+
+
+
 =item save_user
 
 Saves the administrative user, and then directs to the login page.


Property changes on: trunk/LedgerSMB/Scripts/setup.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/setup.pm:3937-4434
/branches/1.3/scripts/setup.pl:3711-4391
   + /branches/1.3/LedgerSMB/Scripts/setup.pm:3937-4438
/branches/1.3/scripts/setup.pl:3711-4438


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


Property changes on: trunk/LedgerSMB/Scripts/vendor.pm
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/LedgerSMB/Scripts/vendor.pm:4288-4434
/branches/1.3/scripts/vendor.pl:4273-4287
   + /branches/1.3/LedgerSMB/Scripts/vendor.pm:4288-4438
/branches/1.3/scripts/vendor.pl:4273-4287

Modified: trunk/UI/reconciliation/search.html
===================================================================
--- trunk/UI/reconciliation/search.html	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/UI/reconciliation/search.html	2012-03-11 00:36:00 UTC (rev 4439)
@@ -1,7 +1,7 @@
 <?lsmb PROCESS 'ui-header.html' ?>
 <?lsmb PROCESS 'elements.html' ?>
 
-<div class="title">Search Reconciliation Reports</div>
+<div class="title"><?lsmb text('Search Reconciliation Reports') ?></div>
         
 <div class="body">
         <form name="reconciliation__search" method="post" action="recon.pl" id="reconciliation__search">

Modified: trunk/UI/reconciliation/upload.html
===================================================================
--- trunk/UI/reconciliation/upload.html	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/UI/reconciliation/upload.html	2012-03-11 00:36:00 UTC (rev 4439)
@@ -38,6 +38,15 @@
 		size = 14
 	} ?>
 	</div>
+        <div id="fx_row">
+        <?lsmb INCLUDE input element_data = {
+           label = text('Reconcile as FX') #'
+           value = 1
+           type = "checkbox"
+           checked = recon_fx
+           name = "recon_fx"
+        } ?>
+        </div>
 	<div id="button-row">
 	<?lsmb INCLUDE button element_data = {
 		type = "submit",

Modified: trunk/UI/setup/select_coa.html
===================================================================
--- trunk/UI/setup/select_coa.html	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/UI/setup/select_coa.html	2012-03-11 00:36:00 UTC (rev 4439)
@@ -47,7 +47,16 @@
     text = text('Next') 
 } ?>
 </div>
+<div class="inputrow">
+<?lsmb INCLUDE button element_data = {
+    name = 'action'
+   value = 'skip_coa'
+    type = 'submit'
+   class = 'submit'
+    text = text('Skip') 
+} ?>
 </div>
+</div>
 </form>
 </div>
 </body>

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/sql/Pg-database.sql	2012-03-11 00:36:00 UTC (rev 4439)
@@ -1049,6 +1049,7 @@
     deleted_by int references entity(id),
     approved_by int references entity(id),
     approved_username text,
+    recon_fx bool default false,
     CHECK (deleted is not true or approved is not true)
 );
 

Modified: trunk/sql/modules/Reconciliation.sql
===================================================================
--- trunk/sql/modules/Reconciliation.sql	2012-03-11 00:21:52 UTC (rev 4438)
+++ trunk/sql/modules/Reconciliation.sql	2012-03-11 00:36:00 UTC (rev 4439)
@@ -1,3 +1,5 @@
+BEGIN;
+
 CREATE OR REPLACE FUNCTION reconciliation__submit_set(
 	in_report_id int, in_line_ids int[]) RETURNS bool AS
 $$
@@ -99,6 +101,8 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+DROP TRIGGER IF EXISTS block_change_when_approved ON cr_report;
+
 CREATE TRIGGER block_change_when_approved BEFORE UPDATE OR DELETE ON cr_report
 FOR EACH ROW EXECUTE PROCEDURE cr_report_block_changing_approved();
 
@@ -200,9 +204,10 @@
 
 -- XXX Badly named, rename for 1.4.  --CT
 CREATE OR REPLACE FUNCTION reconciliation__new_report_id 
-(in_chart_id int, in_total numeric, in_end_date date) returns INT as $$
+(in_chart_id int, in_total numeric, in_end_date date, in_recon_fx) returns INT as $$
 
-    INSERT INTO cr_report(chart_id, their_total, end_date) values ($1, $2, $3);
+    INSERT INTO cr_report(chart_id, their_total, end_date, recon_fx) 
+    values ($1, $2, $3, $4);
     SELECT currval('cr_report_id_seq')::int;
 
 $$ language 'sql';
@@ -361,38 +366,60 @@
 that within each category, one submits in order of amount.  We should therefore
 wrap it in another function which can operate on a set, perhaps in 1.4....$$;
 
+
 create or replace function reconciliation__pending_transactions 
 (in_end_date DATE, in_chart_id int, in_report_id int, in_their_total numeric) 
 RETURNS int as $$
     
     DECLARE
         gl_row RECORD;
+        t_recon_fx BOOL;
     BEGIN
+                SELECT recon_fx INTO t_recon_fx FROM cr_report WHERE id = in_report_id;
+ 
 		INSERT INTO cr_report_line (report_id, scn, their_balance, 
 			our_balance, "user", voucher_id, ledger_id, post_date)
 		SELECT in_report_id, 
 		       COALESCE(ac.source, gl.ref),
 		       0, 
-		       sum(amount) AS amount,
+		       sum(amount / CASE WHEN t_recon_fx IS NOT TRUE OR gl.table = 'gl'
+                                         THEN 1
+                                         WHEN t_recon_fx and gl.table = 'ap' 
+                                         THEN ex.sell
+                                         WHEN t_recon_fx and gl.table = 'ar' 
+                                         THEN ex.buy
+                                    END) AS amount,
 				(select entity_id from users 
 				where username = CURRENT_USER),
 			ac.voucher_id, min(ac.entry_id), ac.transdate
 		FROM acc_trans ac
 		JOIN transactions t on (ac.trans_id = t.id)
-		JOIN (select id, entity_credit_account::text as ref, 'ar' as table FROM ar where approved
+		JOIN (select id, entity_credit_account::text as ref, curr, 
+                             transdate, 'ar' as table 
+                        FROM ar where approved
 			UNION
-		      select id, entity_credit_account::text, 'ap' as table FROM ap WHERE approved
+		      select id, entity_credit_account::text, curr, 
+                             transdate, 'ap' as table 
+                        FROM ap WHERE approved
 			UNION
-		      select id, reference, 'gl' as table FROM gl WHERE approved) gl 
+		      select id, reference, '', 
+                             transdate, 'gl' as table 
+                        FROM gl WHERE approved) gl 
 			ON (gl.table = t.table_name AND gl.id = t.id)
 		LEFT JOIN cr_report_line rl ON (rl.report_id = in_report_id
 			AND ((rl.ledger_id = ac.entry_id 
 				AND ac.voucher_id IS NULL) 
 				OR (rl.voucher_id = ac.voucher_id)))
+                LEFT JOIN exchangerate ex ON gl.transdate = ex.transdate
 		WHERE ac.cleared IS FALSE
 			AND ac.approved IS TRUE
 			AND ac.chart_id = in_chart_id
 			AND ac.transdate <= in_end_date
+                        AND ((t_recon_fx is not true 
+                                and ac.fx_transaction is not true) 
+                            OR (t_recon_fx is true 
+                                AND (gl.table <> 'gl' OR ac.fx_transaction
+                                                      IS TRUE))) 
 		GROUP BY gl.ref, ac.source, ac.transdate,
 			ac.memo, ac.voucher_id, gl.table
 		HAVING count(rl.id) = 0;
@@ -503,6 +530,8 @@
 exact matches.
 $$;
 
+DROP TYPE IF EXISTS recon_accounts CASCADE;
+
 create type recon_accounts as (
     name text,
     accno text,
@@ -589,3 +618,5 @@
 
 COMMENT ON FUNCTION reconciliation__report_details_payee (in_report_id INT) IS
 $$ Pulls the payee information for the reconciliation report.$$;
+
+COMMIT;


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-4434
/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-4438
/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.