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 354-359 is( $prepared_letter->{content}, q|And also this one:| . output_pref({ dt => $ye Link Here
354
$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>');});
357
$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>');});
355
$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>');});
358
$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>');});
356
359
360
# Test borrowers.account_balance
361
my $account = Koha::Account->new({ patron_id => $borrowernumber });
362
$account->add_debit({ amount => 10, interface => 'test', type => 'OVERDUE'})->store;
363
$account->add_debit({ amount => 15, interface => 'test', type => 'OVERDUE'})->store;
364
365
my $lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber });
366
my $totalfine = $lines->total_outstanding;
367
my $active_currency = Koha::Acquisition::Currencies->get_active;
368
my $currency_format = $active_currency->currency if defined($active_currency);
369
my $totalfine_formatted = currency_format($currency_format, "$totalfine", FMT_SYMBOL);
370
$totalfine_formatted = sprintf("%.2f", $totalfine) unless $totalfine_formatted;
371
372
$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>>.');});
373
$prepared_letter = GetPreparedLetter((
374
    module                 => 'test_fines',
375
    branchcode             => '',
376
    letter_code            => 'test_fines',
377
    tables                 => $tables,
378
    substitute             => $substitute,
379
    repeat                 => $repeat,
380
));
381
is( $prepared_letter->{content}, q|Total of fines is: | . $totalfine_formatted . q|.|, 'Account balance is printed correctly' );
382
357
# Test that _parseletter doesn't modify its parameters bug 15429
383
# Test that _parseletter doesn't modify its parameters bug 15429
358
{
384
{
359
    my $values = { dateexpiry => '2015-12-13', };
385
    my $values = { dateexpiry => '2015-12-13', };
360
- 

Return to bug 13961