[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1891] trunk
- Subject: SF.net SVN: ledger-smb: [1891] trunk
- From: ..hidden..
- Date: Thu, 22 Nov 2007 11:44:24 -0800
Revision: 1891
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1891&view=rev
Author: tetragon
Date: 2007-11-22 11:44:24 -0800 (Thu, 22 Nov 2007)
Log Message:
-----------
Some work towards getting metatrontech's preprocess function to work
Modified Paths:
--------------
trunk/LedgerSMB/Template.pm
trunk/t/04-template-handling.t
Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm 2007-11-22 06:19:05 UTC (rev 1890)
+++ trunk/LedgerSMB/Template.pm 2007-11-22 19:44:24 UTC (rev 1891)
@@ -205,8 +205,9 @@
if (UNIVERSAL::isa($vars, 'Math::BigFloat')){
$vars =
LedgerSMB::format_amount('LedgerSMB',
- {amount => $vars.
- user => $self->{myconfig} });
+ amount => $vars,
+ user => $self->{myconfig},
+ precision => 2);
}
my $type = ref($vars);
Modified: trunk/t/04-template-handling.t
===================================================================
--- trunk/t/04-template-handling.t 2007-11-22 06:19:05 UTC (rev 1890)
+++ trunk/t/04-template-handling.t 2007-11-22 19:44:24 UTC (rev 1891)
@@ -344,6 +344,31 @@
'Template, render (PDF): testfile removed');
}
+#########################################
+## LedgerSMB::Template private methods ##
+#########################################
+
+use Math::BigFloat;
+$template = undef;
+$template = new LedgerSMB::Template('user' => {numberformat => '1.000,00'},
+ 'format' => 'HTML', 'template' => '04-template', 'no_auto_output' => 1);
+ok(defined $template,
+ 'Template, private (_preprocess): Object creation with format and template');
+isa_ok($template, 'LedgerSMB::Template',
+ 'Template, private (_preprocess): Object creation with format and template');
+my $number = Math::BigFloat->new(17.5);
+isa_ok($number, 'Math::BigFloat',
+ 'Template, private (_preprocess): number');
+$template->_preprocess($number);
+cmp_ok($number, 'eq', '17,50',
+ 'Template, private (_preprocess): Math::BigFloat conversion');
+$number = [Math::BigFloat->new(1008.51), 'hello'];
+$template->_preprocess($number);
+cmp_ok($number->[0], 'eq', '1.008,51',
+ 'Template, private (_preprocess): Math::BigFloat conversion (array)');
+cmp_ok($number->[1], 'eq', 'hello',
+ 'Template, private (_preprocess): no conversion (array)');
+
###################################
## LedgerSMB::Template::Elements ##
###################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.