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

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



Revision: 5183
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5183&view=rev
Author:   einhverfr
Date:     2012-11-10 13:17:00 +0000 (Sat, 10 Nov 2012)
Log Message:
-----------
Merging from branches/1.3

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/Scripts/setup.pm
    trunk/UI/Contact/divs/credit.html
    trunk/UI/setup/upgrade_info.html
    trunk/sql/upgrade/1.2-1.4.sql

Property Changed:
----------------
    trunk/
    trunk/LedgerSMB/Scripts/setup.pm
    trunk/sql/upgrade/1.2-1.4.sql


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3:3711-5169
   + /branches/1.3:3711-5181

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-11-10 13:10:24 UTC (rev 5182)
+++ trunk/Changelog	2012-11-10 13:17:00 UTC (rev 5183)
@@ -85,9 +85,16 @@
 * Fixed invoice date not printing on checks (Chris T, h/t Neil S)
 * Changed INSTALL to do make test, not of make install (Chris T h/t Kevin B)
 * Fixed framework for printing parts tumbnails in invoices (Chris T)
+* Upgrade now handles nulls in model field of makemodel (Chris T)
+* Fixed issue with comment in account.sql (Chris T)
+* Removed unused Subcontractor GIFI field (Chris T, h/t Erik H)
+* Changed upgrade screen to pull AR/AP numbers (Erik H)
+* Rebuild modules after upgrade, ensuring upgrade to latest version (Chris T)
+* Fixed credit limit usage calculations (Chris T, h/t Erik H)
 
-berend T is Berend Tober
+Berend T is Berend Tober
 Chris T is Chris Travers
+Erik H is Erik Huelsmann
 Havard S is Havard Sorli
 Kevin B is Kevin Bailey
 Neil S is Neil Smith

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2012-11-10 13:10:24 UTC (rev 5182)
+++ trunk/LedgerSMB/AA.pm	2012-11-10 13:17:00 UTC (rev 5183)
@@ -889,41 +889,25 @@
 
     $form->{creditremaining} = $form->{creditlimit};
     $query = qq|
-		SELECT SUM(amount - paid)
+                SELECT sum(used) FROM (
+		SELECT SUM(amount - paid) as used
 		  FROM $arap
-		 WHERE id = ?|;
+		 WHERE entity_credit_account = ?
+                 UNION 
+                SELECT sum(o.amount * coalesce(e.$buysell, 1)) as used
+                  FROM oe o
+             LEFT JOIN exchangerate e ON o.transdate = e.transdate
+                 WHERE not closed and oe_class_id in (1, 2)
+                       and entity_credit_account = ?) s|;
 
     $sth = $dbh->prepare($query);
-    $sth->execute( $form->{"$form->{vc}_id"} )
+    $sth->execute( $form->{"$form->{vc}_id"}, $form->{"$form->{vc}_id"})
       || $form->dberror($query);
     my ($credit_rem) = $sth->fetchrow_array;
     ( $form->{creditremaining} ) -= Math::BigFloat->new($credit_rem);
 
     $sth->finish;
-    if ( $form->{vc} ne "customer" ) {
-        $form->{vc} = 'vendor';
-    }
 
-    $query = qq|
-		SELECT o.amount, (SELECT e.$buysell FROM exchangerate e
-		                   WHERE e.curr = o.curr
-		                         AND e.transdate = o.transdate)
-		  FROM oe o
-		 WHERE o.entity_id = ?
-		       AND o.quotation = '0' AND o.closed = '0'|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{"$form->{vc}_id"} ) || $form->dberror($query);
-
-    while ( my @ref = $sth->fetchrow_array ) {
-        $form->db_parse_numeric(sth => $sth, arrayref => ..hidden..);
-        my ($amount, $exch) = @ref;
-        $exch = 1 unless $exch;
-        $form->{creditremaining} -= $amount * $exch;
-    }
-
-    $sth->finish;
-
     # get shipto if we did not converted an order or invoice
     if ( !$form->{shipto} ) {
 

Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm	2012-11-10 13:10:24 UTC (rev 5182)
+++ trunk/LedgerSMB/Scripts/setup.pm	2012-11-10 13:17:00 UTC (rev 5183)
@@ -1,4 +1,3 @@
-
 =head1 NAME
 
 LedgerSMB::Scripts::setup
@@ -19,6 +18,7 @@
 #
 package LedgerSMB::Scripts::setup;
 
+use Locale::Country;
 use LedgerSMB::Auth;
 use LedgerSMB::Database;
 use LedgerSMB::App_State;
@@ -216,6 +216,8 @@
         $request->error($request->{_locale}->text('Invalid backup request'));
     }
 
+    $backupfile or $request->error($request->{_locale}->text('Error creating backup file'));
+
     if ($request->{backup_type} eq 'email'){
         my $csettings = $LedgerSMB::Company_Config::settings;
 	my $mail = new LedgerSMB::Mailer(
@@ -339,6 +341,34 @@
 
 }
 
+=item _get_linked_accounts
+
+Returns an array of hashrefs with keys ('id', 'accno', 'desc') identifying
+the accounts.
+
+Assumes a connected database.
+
+=cut
+
+sub _get_linked_accounts {
+    my ($request, $link) = @_;
+    my @accounts;
+
+    my $sth = $request->{dbh}->prepare("select id, accno, description
+                                          from chart
+                                         where link = '$link'");
+    $sth->execute();
+    while (my $row = $sth->fetchrow_hashref('NAME_lc')) {
+        push @accounts, { accno => $row->{accno},
+                          desc => "$row->{accno} - $row->{description}",
+                          id => $row->{id}
+        };
+    }
+
+    return @accounts;
+}
+
+
 =item upgrade 
 
 Beginning of the upgrade from 1.2 logic
@@ -375,6 +405,22 @@
              _failed_check($request, $check, $sth);
         }
     }
+
+    @{$request->{ar_accounts}} = _get_linked_accounts($request, "AR");
+    @{$request->{ap_accounts}} = _get_linked_accounts($request, "AP");
+    unshift @{$request->{ar_accounts}}, {};
+    unshift @{$request->{ap_accounts}}, {};
+
+    @{$request->{countries}} = ();
+    foreach my $iso2 (all_country_codes()) {
+        push @{$request->{countries}}, { code    => uc($iso2),
+                                         country => code2country($iso2) };
+    }
+    @{$request->{countries}} =
+        sort { $a->{country} cmp $b->{country} } @{$request->{countries}};
+    unshift @{$request->{countries}}, {};
+
+
     my $template = LedgerSMB::Template->new(
             path => 'UI/setup',
             template => 'upgrade_info',
@@ -714,13 +760,9 @@
         $request->error($request->{_locale}->text('No Permissions Assigned'));
    }
    $request->{dbh}->commit;
+
+   rebuild_modules($request);
    
-    my $template = LedgerSMB::Template->new(
-            path => 'UI/setup',
-            template => 'complete',
-	    format => 'HTML',
-    );
-    $template->render($request);
 }
 
 =item run_upgrade


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

Modified: trunk/UI/Contact/divs/credit.html
===================================================================
--- trunk/UI/Contact/divs/credit.html	2012-11-10 13:10:24 UTC (rev 5182)
+++ trunk/UI/Contact/divs/credit.html	2012-11-10 13:17:00 UTC (rev 5183)
@@ -146,15 +146,6 @@
 			maxlength = 3
 		} ?> <?lsmb text('days') ?>
             </td>
-            <td>
-		<?lsmb INCLUDE input element_data = {
-			label = text('Subcontract GIFI'),
-			name = "gifi_accno",
-			value = credit_act.gifi_accno,
-			type = "text",
-			size = "19"
-		} #' ?>
-            </td>
         </tr>
         <tr id="account-link-row">
            <td> <?lsmb INCLUDE select element_data = {

Modified: trunk/UI/setup/upgrade_info.html
===================================================================
--- trunk/UI/setup/upgrade_info.html	2012-11-10 13:10:24 UTC (rev 5182)
+++ trunk/UI/setup/upgrade_info.html	2012-11-10 13:17:00 UTC (rev 5183)
@@ -12,31 +12,65 @@
    value = database
 } ?>
 <div class="form">
+<p>
+  LedgerSMB has introduced three new system wide default values which
+  you will need to set as part of the upgrade process.
+</p>
+<p>
+  In addition to these new defaults LedgerSMB 1.3 adds stricter
+  checks on data validity in the database. Because of these stricter checks
+  it's no longer valid to leave companies without a country or customers
+  without accounts receivable reference. The defaults you choose below will
+  be used to add values where these are currently missing but required.
+</p>
 <div class="input_row">
-<?lsmb INCLUDE input element_data = {
+<?lsmb INCLUDE select element_data = {
+                          options = countries
+                       value_attr = 'code'
+                        text_attr = 'country'
                             name  = 'default_country'
-                            type  = 'text'
                            label  = text('Default Country') #'
                             class = 'country'
 } ?>
 </div>
 <div class="input_row">
-<?lsmb INCLUDE input element_data = {
+<p>
+  LedgerSMB supports multiple <em>Accounts receivable (AR)</em> accounts
+per company. One of those must be the system default. Please select
+your default below in case of multiple. If the list below is empty,
+your database is in an inconsistent state and needs to be fixed first.
+</p>
+<?lsmb INCLUDE select element_data = {
                             name  = 'default_ar'
-                            type  = 'text'
                            label  = text('Default AR') #'
                             class = 'accno'
+                            options = ar_accounts
+                            value_attr = 'accno'
+                            text_attr = 'desc'
 } ?>
 </div>
 <div class="input_row">
-<?lsmb INCLUDE input element_data = {
+<p>
+  LedgerSMB supports multiple <em>Accounts payable (AP)</em> accounts
+per company. One of those must be the system default. Please select
+your default below in case of multiple. If the list below is empty,
+your database is in an inconsistent state and needs to be fixed first.
+</p>
+<?lsmb INCLUDE select element_data = {
                             name  = 'default_ap'
-                            type  = 'text'
                            label  = text('Default AP') #'
                             class = 'accno'
+                            options = ap_accounts
+                            value_attr = 'accno'
+                            text_attr = 'desc'
 } ?>
 </div>
 <div class="input_row">
+<p>
+  Note that the process invoked by hitting the button below might
+  take long to complete as it will run the upgrade process and will
+  copy all data from the 1.2 tables into the 1.3 tables.
+</p>
 <?lsmb INCLUDE button element_data = {
     text = text('Upgrade') 
     name = 'action'

Modified: trunk/sql/upgrade/1.2-1.4.sql
===================================================================
--- trunk/sql/upgrade/1.2-1.4.sql	2012-11-10 13:10:24 UTC (rev 5182)
+++ trunk/sql/upgrade/1.2-1.4.sql	2012-11-10 13:17:00 UTC (rev 5183)
@@ -381,6 +381,9 @@
 
 -- must rebuild this table due to changes since 1.2
 
+-- needed to handle null values
+UPDATE lsmb12.makemodel set model = '' where model is null;
+
 INSERT INTO makemodel
 SELECT * FROM lsmb12.makemodel;
 


Property changes on: trunk/sql/upgrade/1.2-1.4.sql
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/1.3/sql/upgrade/1.2-1.3.sql:3711-5135
/branches/1.3/sql/upgrade/1.2-1.4.sql:3711-5135
   + /branches/1.3/sql/upgrade/1.2-1.3.sql:3711-5182
/branches/1.3/sql/upgrade/1.2-1.4.sql:3711-5135

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