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

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



Revision: 2398
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2398&view=rev
Author:   einhverfr
Date:     2008-11-14 01:53:25 +0000 (Fri, 14 Nov 2008)

Log Message:
-----------
Correcting check printing, adding appropriate test cases

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Payment.pm
    trunk/LedgerSMB/Sysconfig.pm
    trunk/LedgerSMB/Template.pm
    trunk/scripts/payment.pl
    trunk/t/04-template-handling.t

Modified: trunk/LedgerSMB/DBObject/Payment.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Payment.pm	2008-11-13 22:39:52 UTC (rev 2397)
+++ trunk/LedgerSMB/DBObject/Payment.pm	2008-11-14 01:53:25 UTC (rev 2398)
@@ -64,7 +64,6 @@
 
 sub text_amount {
     use LedgerSMB::Num2text;
-    print STDERR "num2text\n";
     my ($self, $value) = @_;
     $self->{locale} = $self->{_locale};
     $self->init();

Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm	2008-11-13 22:39:52 UTC (rev 2397)
+++ trunk/LedgerSMB/Sysconfig.pm	2008-11-14 01:53:25 UTC (rev 2398)
@@ -81,10 +81,7 @@
 $localepath = 'locale/po';
 
 # available printers
-%printer = (
-    Laser => 'lpr -Plaser',
-    Epson => 'lpr -PEpson',
-);
+%printer;
 
 my %config;
 read_config( 'ledgersmb.conf' => %config ) or die;

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2008-11-13 22:39:52 UTC (rev 2397)
+++ trunk/LedgerSMB/Template.pm	2008-11-14 01:53:25 UTC (rev 2398)
@@ -290,7 +290,7 @@
 		$self->_email_output;
 	} elsif ('print' eq lc $method) {
 		$self->_lpr_output;
-	} elsif (defined $self->{output} or $method = 'Screen') {
+	} elsif (defined $self->{output} or lc $method eq 'screen') {
 		$self->_http_output;
 		exit;
 	} elsif (defined $method) {
@@ -401,7 +401,7 @@
 	}
 	my $lpr = $LedgerSMB::Sysconfig::printer{$args->{media}};
 
-	open(LPR, '|-', $lpr);
+	open (LPR, '|-', $lpr);
 
 	# Output is not defined here.  In the future we should consider
 	# changing this to use the system command and hit the file as an arg.

Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl	2008-11-13 22:39:52 UTC (rev 2397)
+++ trunk/scripts/payment.pl	2008-11-14 01:53:25 UTC (rev 2398)
@@ -282,7 +282,6 @@
 
     if ($payment->{multiple}){
         $payment->{checks} = [];
-        print "Multiple checks printing";
         for my $line (1 .. $payment->{contact_count}){
             my $id = $payment->{"contact_$line"};
             next if !defined $payment->{"id_$id"};
@@ -337,14 +336,15 @@
 	    no_auto_output => 1,
             output_args => $payment,
         );
-        try {
+        #try {
             $template->render($payment);
             $template->output(%$payment);
-        }
-        catch Error::Simple with {
-            my $E = shift;
-            $payment->error( $E->stacktrace );
-        };
+        #}
+        #catch Error::Simple with {
+        #    my $E = shift;
+        #    $payment->error( $E->stacktrace );
+        #};
+        display_payments(@_);
 
     } else {
 
@@ -402,7 +402,7 @@
     for (keys %LedgerSMB::Sysconfig::printer){
          push @{$payment->{media_options}}, 
               {text  => $_,
-               value => $LedgerSMB::Sysconfig::printer{$_}};
+               value => $_};
     }
     if ($LedgerSMB::Sysconfig::latex){
         @{$payment->{format_options}} = (

Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t	2008-11-13 22:39:52 UTC (rev 2397)
+++ trunk/t/04-template-handling.t	2008-11-14 01:53:25 UTC (rev 2398)
@@ -421,7 +421,21 @@
 is(grep (/value="1000" selected/, @output), 1, 'Select box Value 1000 selected');
 is(grep (/<td class="description">dtest1/, @output), 1, 'Contact description shows');
 
+# LPR PRinting Tests
+use LedgerSMB::Sysconfig;
+%LedgerSMB::Sysconfig::printer = ('test' => 'cat > t/var/04-lpr-test');
 
+$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'PDF', 
+	'template' => '04-template', 'locale' => $locale, no_auto_output => 1);
+$template->render({media => 'test'});
+$template->output(media => 'test');
+
+ok (open (LPR_TEST, '<', 't/var/04-lpr-test'), 'LedgerSMB::Template::_output_lpr output file opened successfully');
+
+my $line1 = <LPR_TEST>;
+
+like($line1, qr/^%PDF/, 'output file is pdf');
+
 # Functions
 sub get_output_line_array {
         my $FH;


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