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

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



Revision: 2463
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2463&view=rev
Author:   einhverfr
Date:     2009-02-25 22:23:27 +0000 (Wed, 25 Feb 2009)

Log Message:
-----------
Reconciliation changes:  search by approved and submitted, proper handling of 0, accounts order by gl account number in list

Modified Paths:
--------------
    trunk/LedgerSMB.pm
    trunk/UI/reconciliation/search.html
    trunk/scripts/recon.pl
    trunk/sql/modules/Reconciliaton.sql
    trunk/t/02-number-handling.t

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2009-02-24 23:09:32 UTC (rev 2462)
+++ trunk/LedgerSMB.pm	2009-02-25 22:23:27 UTC (rev 2463)
@@ -376,7 +376,6 @@
     my $places   = $args{precision};
     my $dash     = $args{neg_format};
     my $format   = $args{format};
-
     if (!defined $format){
        $format = $myconfig->{numberformat}
     }
@@ -385,11 +384,11 @@
     }
 
     my $negative;
-    if ($amount) {
+    if (defined $amount and ! UNIVERSAL::isa($amount, 'Math::BigFloat' )) {
         $amount = $self->parse_amount( 'user' => $myconfig, 'amount' => $amount );
-        $negative = ( $amount < 0 );
-        $amount =~ s/-//;
     }
+    $negative = ( $amount < 0 );
+    $amount->babs();
 
     if ( $places =~ /\d+/ ) {
 
@@ -403,7 +402,7 @@
 
     my ( $ts, $ds ) = ( $1, $2 );
 
-    if ($amount) {
+    if (defined $amount) {
 
         if ( $format ) {
 
@@ -492,7 +491,7 @@
     }
 
     if ( UNIVERSAL::isa( $amount, 'Math::BigFloat' ) )
-    {    # Amount may not be an object
+    {   #Avoiding double-parse issues 
         return $amount;
     }
     my $numberformat = $myconfig->{numberformat};
@@ -583,7 +582,7 @@
     $query =~ s/\(\)/($argstr)/;
     my $sth = $self->{dbh}->prepare($query);
     if (scalar @call_args){
-        $sth->execute(@call_args) || $self->dberror($self->{dbh}->errstr);
+        $sth->execute(@call_args) || $self->dberror($self->{dbh}->errstr . ": " . $query);
     } else {
         $sth->execute() || $self->dberror($self->{dbh}->errstr . ':' . $query);
     }

Modified: trunk/UI/reconciliation/search.html
===================================================================
--- trunk/UI/reconciliation/search.html	2009-02-24 23:09:32 UTC (rev 2462)
+++ trunk/UI/reconciliation/search.html	2009-02-25 22:23:27 UTC (rev 2463)
@@ -52,16 +52,48 @@
 		} ?>
             </div>
             <div>
+		<?lsmb IF show_approved ?>
+			<?lsmb- approved_options = [
+				{id = undef, label = undef },
+				{id = '1', label = text('Approved') },
+				{id = '0', label = text('Not Approved') } #'
+			];
+			PROCESS select element_data = {
+				name = 'approved',
+				label = text('Approval Status'), #'
+				options = approved_options
+				text_attr = 'label',
+				value_attr = 'id',
+				class = 'status'
+			} -?>
+		<?lsmb ELSE ?>
 		<?lsmb INCLUDE input element_data = {
 			type = "hidden",
 			name = "approved",
 			value = approved
 		} ?>
+		<?lsmb END ?>
+		<?lsmb IF show_submitted ?>
+			<?lsmb- submitted_options = [
+				{id = undef, label = undef },
+				{id = '1', label = text('Submitted') },
+				{id = '0', label = text('Not Submitted') } #'
+			];
+			PROCESS select element_data = {
+				name = 'submitted',
+				label = text('Submission Status'), #'
+				options = submitted_options
+				text_attr = 'label',
+				value_attr = 'id',
+				class = 'status'
+			} -?>
+		<?lsmb ELSE ?>
 		<?lsmb INCLUDE input element_data = {
 			type = "hidden",
 			name = "submitted",
 			value = submitted
 		} ?>
+		<?lsmb END ?>
             </div>
 		<?lsmb INCLUDE button element_data = {
 			type = "submit",

Modified: trunk/scripts/recon.pl
===================================================================
--- trunk/scripts/recon.pl	2009-02-24 23:09:32 UTC (rev 2462)
+++ trunk/scripts/recon.pl	2009-02-25 22:23:27 UTC (rev 2463)
@@ -95,6 +95,12 @@
 }
 sub get_results {
     my ($request) = @_;
+        if ($request->{approved} ne '1' and $request->{approved} ne '0'){
+		$request->{approved} = undef;
+        }
+        if ($request->{submitted} ne '1' and $request->{submitted} ne '0'){
+		$request->{submitted} = undef;
+        }
         my $search = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy => 'all');
         my @results = $search->search();
         my @accounts = $search->get_accounts();
@@ -159,7 +165,10 @@
 
         
         my $recon = LedgerSMB::DBObject::Reconciliation->new(base=>$request, copy=>'all');
-        
+	if (!$recon->{hide_status}){
+            $recon->{show_approved} = 1;        
+            $recon->{show_submitted} = 1;        
+        }
         @{$recon->{account_list}} = $recon->get_accounts();
 	unshift @{$recon->{account_list}}, {id => '', name => '' };
         my $template = LedgerSMB::Template->new(

Modified: trunk/sql/modules/Reconciliaton.sql
===================================================================
--- trunk/sql/modules/Reconciliaton.sql	2009-02-24 23:09:32 UTC (rev 2462)
+++ trunk/sql/modules/Reconciliaton.sql	2009-02-25 22:23:27 UTC (rev 2463)
@@ -363,7 +363,8 @@
         coa.accno || ' ' || coa.description as name,
         coa.accno, coa.id as id
     FROM chart coa, cr_coa_to_account cta
-    WHERE cta.chart_id = coa.id;
+    WHERE cta.chart_id = coa.id
+    ORDER BY coa.accno;
 $$ language sql;
 
 CREATE OR REPLACE FUNCTION reconciliation__get_current_balance

Modified: trunk/t/02-number-handling.t
===================================================================
--- trunk/t/02-number-handling.t	2009-02-24 23:09:32 UTC (rev 2462)
+++ trunk/t/02-number-handling.t	2009-02-25 22:23:27 UTC (rev 2463)
@@ -93,6 +93,59 @@
 	%myconfig = (numberformat => $formats[$format][0]);
 	my $thou = $formats[$format][1];
 	my $dec = $formats[$format][2];
+	foreach my $rawValue ('10t000d00', '9t999d99', '333d33', 
+			'7t777t777d77', '-12d34', '0d00', '0') {
+		$expected = $rawValue;
+		if ($expected eq '0'){
+			$expected = '0d00';
+                }
+		$expected =~ s/t/$thou/gx;
+		$expected =~ s/d/$dec/gx;
+		my $value = $rawValue;
+		$value =~ s/t//gx;
+		$value =~ s/d/\./gx;
+		##$value = Math::BigFloat->new($value);
+		$LedgerSMB::Sysconfig::decimal_places = 2;
+		$value = $lsmb->parse_amount(user =>\%myfooconfig, 
+			amount =>$value);
+		is($form->format_amount(\%myconfig, $value, 2, '0'), $expected,
+			"form: $value formatted as $formats[$format][0] - $expected");
+		is($lsmb->format_amount('user' => \%myconfig, 
+			'amount' => $value, 'money' => 1, 
+			'neg_format' => '0'), $expected,
+			"lsmb(money): $value formatted as $formats[$format][0] - $expected");
+	}
+}
+
+foreach my $format (0 .. $#formats) {
+	%myconfig = (numberformat => $formats[$format][0]);
+	my $thou = $formats[$format][1];
+	my $dec = $formats[$format][2];
+	foreach my $rawValue ('10t000d00', '9t999d99', '333d33', 
+			'7t777t777d77', '-12d34', '0d00') {
+		$expected = $rawValue;
+		$expected =~ s/t/$thou/gx;
+		$expected =~ s/d/$dec/gx;
+		my $value = $rawValue;
+		$value =~ s/t//gx;
+		$value =~ s/d/\./gx;
+                my $val2 = $value;
+		##$value = Math::BigFloat->new($value);
+		$value = $form->parse_amount(\%myfooconfig,$value);
+		my $value2 = $lsmb->parse_amount(user => \%myfooconfig, amount => $val2);
+		is($form->format_amount(\%myconfig, $value, 2, '0'), $expected,
+			"form: $value formatted as $formats[$format][0] - $expected");
+		is($lsmb->format_amount('user' => \%myconfig, 
+			'amount' => $value2, 'precision' => 2, 
+			'neg_format' => '0'), $expected,
+			"lsmb: $value formatted as $formats[$format][0] - $expected");
+	}
+}
+
+foreach my $format (0 .. $#formats) {
+	%myconfig = (numberformat => $formats[$format][0]);
+	my $thou = $formats[$format][1];
+	my $dec = $formats[$format][2];
 	my $rawValue = '6d00';
 	$expected = $rawValue;
 	$expected =~ s/d/$dec/gx;


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