View | Details | Raw Unified | Return to bug 13961
Collapse All | Expand All

(-)a/t/db_dependent/Letters.t (-2 / +27 lines)
Lines 18-28 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 73;
21
use Test::More tests => 74;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use MARC::Record;
25
use MARC::Record;
26
use Locale::Currency::Format;
26
27
27
my %mail;
28
my %mail;
28
my $module = new Test::MockModule('Mail::Sendmail');
29
my $module = new Test::MockModule('Mail::Sendmail');
Lines 50-55 use Koha::Libraries; Link Here
50
use Koha::Notice::Templates;
51
use Koha::Notice::Templates;
51
use Koha::Patrons;
52
use Koha::Patrons;
52
use Koha::Subscriptions;
53
use Koha::Subscriptions;
54
use Koha::Account;
55
use Koha::Account::Lines;
53
my $schema = Koha::Database->schema;
56
my $schema = Koha::Database->schema;
54
$schema->storage->txn_begin();
57
$schema->storage->txn_begin();
55
58
Lines 355-360 is( $prepared_letter->{content}, q|And also this one:| . output_pref({ dt => $ye Link Here
355
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimacquisition','TESTACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
358
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimacquisition','TESTACQCLAIM','Acquisition Claim','Item Not Received','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
356
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('orderacquisition','TESTACQORDER','Acquisition Order','Order','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
359
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('orderacquisition','TESTACQORDER','Acquisition Order','Order','<<aqbooksellers.name>>|<<aqcontacts.name>>|<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (<<aqorders.quantity>> ordered)</order>');});
357
360
361
# Test borrowers.account_balance
362
my $account = Koha::Account->new({ patron_id => $borrowernumber });
363
$account->add_debit({ amount => 10, interface => 'test', type => 'OVERDUE'})->store;
364
$account->add_debit({ amount => 15, interface => 'test', type => 'OVERDUE'})->store;
365
366
my $lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber });
367
my $totalfine = $lines->total_outstanding;
368
my $active_currency = Koha::Acquisition::Currencies->get_active;
369
my $currency_format = $active_currency->currency if defined($active_currency);
370
my $totalfine_formatted = currency_format($currency_format, "$totalfine", FMT_SYMBOL);
371
$totalfine_formatted = sprintf("%.2f", $totalfine) unless $totalfine_formatted;
372
373
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test_fines','TEST_FINES','Test total of fines','','Total of fines is: <<borrowers.account_balance>>.');});
374
$prepared_letter = GetPreparedLetter((
375
    module                 => 'test_fines',
376
    branchcode             => '',
377
    letter_code            => 'test_fines',
378
    tables                 => $tables,
379
    substitute             => $substitute,
380
    repeat                 => $repeat,
381
));
382
is( $prepared_letter->{content}, q|Total of fines is: | . $totalfine_formatted . q|.|, 'Account balance is printed correctly' );
383
358
# Test that _parseletter doesn't modify its parameters bug 15429
384
# Test that _parseletter doesn't modify its parameters bug 15429
359
{
385
{
360
    my $values = { dateexpiry => '2015-12-13', };
386
    my $values = { dateexpiry => '2015-12-13', };
361
- 

Return to bug 13961