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

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



Revision: 2414
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2414&view=rev
Author:   einhverfr
Date:     2008-11-22 21:38:18 +0000 (Sat, 22 Nov 2008)

Log Message:
-----------
Batch numbers assigned at batch creation phase.  Tests working.

Modified Paths:
--------------
    trunk/LedgerSMB/Batch.pm
    trunk/LedgerSMB/DBTest.pm
    trunk/LedgerSMB/Setting.pm
    trunk/scripts/vouchers.pl
    trunk/t/62-api.t
    trunk/t/data/62-request-data
    trunk/templates/demo/check_multiple.tex

Modified: trunk/LedgerSMB/Batch.pm
===================================================================
--- trunk/LedgerSMB/Batch.pm	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/LedgerSMB/Batch.pm	2008-11-22 21:38:18 UTC (rev 2414)
@@ -1,8 +1,17 @@
 
 
 package LedgerSMB::Batch;
+use LedgerSMB::Setting;
 use base qw(LedgerSMB::DBObject);
 
+sub get_new_info {
+    $self = shift @_;
+    my $cc_object = LedgerSMB::Setting->new({base => $self});
+    $cc_object->{key} = 'batch_cc';
+    $self->{batch_number} = $cc_object->increment;
+    $self->{dbh}->commit;
+}
+
 sub create {
     $self = shift @_;
     my ($ref) = $self->exec_method(funcname => 'batch_create');

Modified: trunk/LedgerSMB/DBTest.pm
===================================================================
--- trunk/LedgerSMB/DBTest.pm	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/LedgerSMB/DBTest.pm	2008-11-22 21:38:18 UTC (rev 2414)
@@ -95,6 +95,19 @@
     return $self;
 }
 
+sub commit {
+    my ($self) = shift;
+    my $sth = $self->{_dbh}->prepare('SELECT 1');
+    $sth->execute;
+    my ($retval) = $sth->fetchrow_array;
+    return $retval;
+}
+
+sub selectrow_array {
+    my ($self) = shift;
+    return $self->{_dbh}->selectrow_array(@_);
+}
+
 sub disconnect {
     my ($self) = @_;
     $self->rollback;

Modified: trunk/LedgerSMB/Setting.pm
===================================================================
--- trunk/LedgerSMB/Setting.pm	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/LedgerSMB/Setting.pm	2008-11-22 21:38:18 UTC (rev 2414)
@@ -23,8 +23,6 @@
 
 =item get ($self->{key})
 
-=item get_default_accounts() (via AUTOLOAD) returns a list of accounts.
-
 =item set ($self->{key}, $self->{value})
 
 =item parse_increment ($self->{key})
@@ -58,7 +56,7 @@
     $self->merge( $hashref, 'value' );
 }
 
-sub parse_increment {
+sub increment {
 
     my $self     = shift;
     my $myconfig = shift;
@@ -68,26 +66,26 @@
 
     # Replaces Form::UpdateDefaults
 
-    $_ = $self->incriment;
-
+    my ($retval) = $self->exec_method('funcname' => 'setting_increment');
+    my $value = $retval->{setting_increment};
 # check for and replace
 # <?lsmb DATE ?>, <?lsmb YYMMDD ?>, <?lsmb YEAR ?>, <?lsmb MONTH ?>, <?lsmb DAY ?> or variations of
 # <?lsmb NAME 1 1 3 ?>, <?lsmb BUSINESS ?>, <?lsmb BUSINESS 10 ?>, <?lsmb CURR... ?>
 # <?lsmb DESCRIPTION 1 1 3 ?>, <?lsmb ITEM 1 1 3 ?>, <?lsmb PARTSGROUP 1 1 3 ?> only for parts
 # <?lsmb PHONE ?> for customer and vendors
 
-    my $dbvar = $_;
-    my $var   = $_;
+    my $dbvar = $value;
+    my $var   = $value;
     my $str;
     my $param;
 
-    if (/<\?lsmb /) {
+    if ($value =~ /<\?lsmb /) {
 
-        while (/<\?lsmb /) {
+        while ($value =~ /<\?lsmb /) {
 
-            s/<\?lsmb .*? \?>//;
+            $value =~ s/(<\?lsmb .*? \?>)//;
             last unless $&;
-            $param = $&;
+            $param = $1;
             $str   = "";
 
             if ( $param =~ /<\?lsmb date \?>/i ) {

Modified: trunk/scripts/vouchers.pl
===================================================================
--- trunk/scripts/vouchers.pl	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/scripts/vouchers.pl	2008-11-22 21:38:18 UTC (rev 2414)
@@ -41,6 +41,7 @@
 
     my $batch = LedgerSMB::Batch->new({base => $request});
     $batch->{class_id} = $batch->get_class_id($batch->{batch_type});
+    $batch->get_new_info;
     $batch->get_search_results({mini => 1});
 
     my $template = LedgerSMB::Template->new(

Modified: trunk/t/62-api.t
===================================================================
--- trunk/t/62-api.t	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/t/62-api.t	2008-11-22 21:38:18 UTC (rev 2414)
@@ -5,8 +5,6 @@
 	use LedgerSMB::DBTest;
 }
 
-our $api_test_cases = {
-};
 
 if (defined $ENV{LSMB_TEST_DB}){
 	if (defined $ENV{LSMB_NEW_DB}){
@@ -56,14 +54,20 @@
 		$request->merge($test);
 		my $script = $test->{module};
 		$request->{dbh} = $dbh;
+		if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
+			$request->{_test_cases} = 
+				$api_test_cases->{"$test->{_test_id}"};
+		}
+		delete $api_test_cases->{"$test->{_test_id}"};
 		$script =~ s/\.pl$//;
 		is(ref "LedgerSMB::Scripts::$script"->can($request->{action}), 
 			'CODE',
 			"$test->{_test_id}: Action ($request->{action}) Defined");
 		ok("LedgerSMB::Scripts::$script"->can($request->{action})->($request), "$test->{_test_id}: Action Successful");
 	}
-	for (@{$api_test_cases->{"$test->{_test_id}"}}){
-		&$_;
+	if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
+		$request->{_test_cases} = 
+			$api_test_cases->{"$test->{_test_id}"};
 	}
 	ok($dbh->rollback, "$test->{_test_id}: rollback");
 }
@@ -72,6 +76,10 @@
 
 # Don't render templates.  Just return so we can run tests on data structures.
 sub render {
+	my ($self, $data) = @_;
+	if (ref $data->{_test_cases} eq 'CODE'){
+		$data->{_test_cases}($data);
+	}
 	return 1;
 }
 

Modified: trunk/t/data/62-request-data
===================================================================
--- trunk/t/data/62-request-data	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/t/data/62-request-data	2008-11-22 21:38:18 UTC (rev 2414)
@@ -1,4 +1,4 @@
-
+use Test::More;
 our $test_request_data = [
 	# AR/AP Transaction Screen Tests
 	{
@@ -49,8 +49,42 @@
 		'batch_type' => 'gl',
 		'module'     => 'vouchers.pl',
 	},
+#	{
+#		'_test_id'      => 'Payment print total',
+#		'_codebase'     => 'new',
+#		'action'        => 'print',
+#		'module'        => 'payment.pl',
+#		'account_class' => 1,
+#		'currency'      => 'USD',
+#		'multiple'      => 1,
+#		'format'	=> 
+#                
+#	},
 ];
 
+our $pre_test_subs = {};
+our $api_test_cases = {
+	'AR Transaction Voucher Screen' => sub {
+		my $request = shift;
+		ok($request->{batch_number}, 'Batch Number is Defined');
+	},
+	'AP Transaction Voucher Screen' => sub {
+		my $request = shift;
+		ok($request->{batch_number}, 'Batch Number is Defined');
+	},
+	'Payment Transaction Voucher Screen' => sub {
+		my $request = shift;
+		ok($request->{batch_number}, 'Batch Number is Defined');
+	},
+	'Payment Reversal Transaction Voucher Screen' => sub {
+		my $request = shift;
+		ok($request->{batch_number}, 'Batch Number is Defined');
+	},
+	'GL Transaction Voucher Screen' => sub {
+		my $request = shift;
+		ok($request->{batch_number}, 'Batch Number is Defined');
+	},
+};
 
 opendir (D62, 't/data/62.d');
 for my $testfile (readdir(D62)){

Modified: trunk/templates/demo/check_multiple.tex
===================================================================
--- trunk/templates/demo/check_multiple.tex	2008-11-21 22:02:08 UTC (rev 2413)
+++ trunk/templates/demo/check_multiple.tex	2008-11-22 21:38:18 UTC (rev 2414)
@@ -26,6 +26,7 @@
 	city = check.city
 	state = check.state
 	mail_code = check.mail_code
+	country = check.country
 	memo = check.memo
 	invoices = check.invoices
 ?>


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