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

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



Revision: 2422
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2422&view=rev
Author:   einhverfr
Date:     2008-12-01 02:15:53 +0000 (Mon, 01 Dec 2008)

Log Message:
-----------
Default country can now be set.

Modified Paths:
--------------
    trunk/LedgerSMB/AM.pm
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/LedgerSMB/Setting.pm
    trunk/UI/Contact/contact.html
    trunk/UI/am-defaults.html
    trunk/bin/am.pl
    trunk/t/04-template-handling.t

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/LedgerSMB/AM.pm	2008-12-01 02:15:53 UTC (rev 2422)
@@ -1815,7 +1815,7 @@
         fxgain_accno_id fxloss_accno_id glnumber sinumber vinumber
         sonumber ponumber sqnumber rfqnumber partnumber employeenumber
         customernumber vendornumber projectnumber yearend curr
-        weightunit businessnumber)
+        weightunit businessnumber default_country)
       )
     {
         my $val = $form->{$_};
@@ -2416,7 +2416,15 @@
     while ( ( $skey, $value ) = $sth->fetchrow_array() ) {
         $form->{$skey} = $value;
     }
-
+    $sth->finish;
+    $query = "select id, name from country order by name";
+    $sth = $dbh->prepare($query);
+    $sth->execute;
+    $form->{countries} = [];
+    while ($ref = $sth->fetchrow_hashref('NAME_lc')) {
+        push @{$form->{countries}}, $ref;
+    }
+    $sth->finish;
     $self->defaultaccounts( undef, $form );
     $dbh->commit;
 }

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/LedgerSMB/DBObject/Company.pm	2008-12-01 02:15:53 UTC (rev 2422)
@@ -11,6 +11,7 @@
 
 package LedgerSMB::DBObject::Company;
 
+use LedgerSMB::Setting;
 use base qw(LedgerSMB::DBObject);
 use strict;
 
@@ -165,7 +166,10 @@
 
     @{$self->{contact_class_list}} = 
          $self->exec_method(funcname => 'entity_list_contact_class');
-
+    my $country_setting = LedgerSMB::Setting->new({base => $self, copy => 'base'});
+    $country_setting->{key} = 'default_country';
+    $country_setting->get;
+    $self->{default_country} = $country_setting->{value};
 }
 
 sub save_contact {

Modified: trunk/LedgerSMB/Setting.pm
===================================================================
--- trunk/LedgerSMB/Setting.pm	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/LedgerSMB/Setting.pm	2008-12-01 02:15:53 UTC (rev 2422)
@@ -52,8 +52,8 @@
 
 sub get {
     my $self = shift;
-    my $hashref = shift @{ $self->exec_method( funcname => 'setting_get' ) };
-    $self->merge( $hashref, 'value' );
+    my ($hashref) = $self->exec_method( funcname => 'setting_get' ) ;
+    $self->{value} = $hashref->{setting_get};
 }
 
 sub increment {

Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/UI/Contact/contact.html	2008-12-01 02:15:53 UTC (rev 2422)
@@ -592,6 +592,7 @@
 		} #' ?>
 	</div>
 	<div> <!-- TODO:  Move to elements.html -CT -->
+		<?lsmb IF !country; country = default_country; END -?>
 		<?lsmb INCLUDE select element_data = {
 			text_attr = "name"
 			value_attr = "id"

Modified: trunk/UI/am-defaults.html
===================================================================
--- trunk/UI/am-defaults.html	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/UI/am-defaults.html	2008-12-01 02:15:53 UTC (rev 2422)
@@ -69,6 +69,12 @@
 <?lsmb PROCESS select element_data=selects.FX_loss ?>
          </td>
 	</tr>
+	<tr>
+          <th align="right" nowrap="nowrap"><?lsmb text('Default Country') ?></th>
+	  <td>
+<?lsmb PROCESS select element_data=selects.default_country ?>
+         </td>
+	</tr>
       </table>
     </td>
   </tr>

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/bin/am.pl	2008-12-01 02:15:53 UTC (rev 2422)
@@ -1471,6 +1471,12 @@
         'IC_income' => {name => 'IC_income', options => []},
         'IC_inventory' => {name => 'IC_inventory', options => []},
         'IC' => {name => 'IC', options => []},
+	'default_country' => {name   => 'default_country', 
+			     options => $form->{countries},
+			     default_values => [$form->{'default_country'}],
+			     text_attr => 'name',
+			     value_attr => 'id',
+		},
         );
     foreach $key ( keys %{ $form->{accno} } ) {
         foreach $accno ( sort keys %{ $form->{accno}{$key} } ) {

Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t	2008-11-25 18:53:02 UTC (rev 2421)
+++ trunk/t/04-template-handling.t	2008-12-01 02:15:53 UTC (rev 2422)
@@ -395,6 +395,7 @@
         meta_number  => 'test1',
 	credit_id    => '1',
         entity_class => 1,
+        default_country => 4,
         credit_list  => [{ entity_class => 1,
                            meta_number => 'test1',
                         }],
@@ -404,6 +405,13 @@
         business_id  => 1000,
         business_types => [{ id => 1,    description => 'test1' },
                            { id => 1000, description => 'test2' }],
+	country_list => [{id => 1, name => 'country1'},
+		{id => 2, name => 'country2'},
+		{id => 3, name => 'country3'},
+		{id => 4, name => 'country4'},
+		{id => 5, name => 'country5'},
+		{id => 6, name => 'country6'},
+		]
 }; # Company with Credit Accounts and business types.
 
 my $contact_template = LedgerSMB::Template->new(
@@ -417,10 +425,10 @@
 $contact_template->render($contact_request);
 
 my @output =  get_output_line_array($contact_template);
-is(grep (/value="1" selected/, @output), 0, 'Select box Value 1 unselected');
-is(grep (/value="1000" selected/, @output), 1, 'Select box Value 1000 selected');
+is(grep (/value="1" selected="selected">test1/, @output), 0, 'Select box Value 1 unselected');
+is(grep (/value="1000" selected="selected">test2/, @output), 1, 'Select box Value 1000 selected');
 is(grep (/<td class="description">dtest1/, @output), 1, 'Contact description shows');
-
+is(grep (/value="4" selected="selected">country4/, @output), 1, 'Default Country Set');
 # bulk payment template tests
 my $payment = LedgerSMB->new();
 $payment->merge({
@@ -438,7 +446,7 @@
 );
 
 $payment_template->render($payment);
-my @output =  get_output_line_array($payment_template);
..hidden.. =  get_output_line_array($payment_template);
 cmp_ok(grep(/101<\/td>/, @output), '>', 0, 'Invoice row exists');
 is(grep(/name="payment_101"/, @output), 0, 'Invoice locked');
 is(grep(/Locked by/, @output), 1, 'Invoice locked label shown');


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