summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/Batch.pm9
-rw-r--r--LedgerSMB/DBTest.pm13
-rw-r--r--LedgerSMB/Setting.pm20
-rw-r--r--scripts/vouchers.pl1
-rw-r--r--t/62-api.t16
-rw-r--r--t/data/62-request-data36
-rw-r--r--templates/demo/check_multiple.tex1
7 files changed, 80 insertions, 16 deletions
diff --git a/LedgerSMB/Batch.pm b/LedgerSMB/Batch.pm
index 8c4e397b..f18200c8 100644
--- a/LedgerSMB/Batch.pm
+++ b/LedgerSMB/Batch.pm
@@ -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');
diff --git a/LedgerSMB/DBTest.pm b/LedgerSMB/DBTest.pm
index b9eb6ae2..594dfa82 100644
--- a/LedgerSMB/DBTest.pm
+++ b/LedgerSMB/DBTest.pm
@@ -95,6 +95,19 @@ sub connect{
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;
diff --git a/LedgerSMB/Setting.pm b/LedgerSMB/Setting.pm
index 57630c97..f9fc122c 100644
--- a/LedgerSMB/Setting.pm
+++ b/LedgerSMB/Setting.pm
@@ -23,8 +23,6 @@ The following methods are passed through to stored procedures:
=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 @@ sub get {
$self->merge( $hashref, 'value' );
}
-sub parse_increment {
+sub increment {
my $self = shift;
my $myconfig = shift;
@@ -68,26 +66,26 @@ sub parse_increment {
# 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 ) {
diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl
index d6ed9b23..f21d2e42 100644
--- a/scripts/vouchers.pl
+++ b/scripts/vouchers.pl
@@ -41,6 +41,7 @@ sub create_batch {
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(
diff --git a/t/62-api.t b/t/62-api.t
index f05eb072..740a1fcb 100644
--- a/t/62-api.t
+++ b/t/62-api.t
@@ -5,8 +5,6 @@ BEGIN {
use LedgerSMB::DBTest;
}
-our $api_test_cases = {
-};
if (defined $ENV{LSMB_TEST_DB}){
if (defined $ENV{LSMB_NEW_DB}){
@@ -56,14 +54,20 @@ for my $test (@$test_request_data){
$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 @@ package LedgerSMB::Template;
# 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;
}
diff --git a/t/data/62-request-data b/t/data/62-request-data
index ae8c6d0e..e3c6108b 100644
--- a/t/data/62-request-data
+++ b/t/data/62-request-data
@@ -1,4 +1,4 @@
-
+use Test::More;
our $test_request_data = [
# AR/AP Transaction Screen Tests
{
@@ -49,8 +49,42 @@ our $test_request_data = [
'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)){
diff --git a/templates/demo/check_multiple.tex b/templates/demo/check_multiple.tex
index 87bddf84..dab08372 100644
--- a/templates/demo/check_multiple.tex
+++ b/templates/demo/check_multiple.tex
@@ -26,6 +26,7 @@
city = check.city
state = check.state
mail_code = check.mail_code
+ country = check.country
memo = check.memo
invoices = check.invoices
?>