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

(-)a/t/db_dependent/Koha/Account/Line.t (-2 / +95 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 16;
23
use Test::More tests => 17;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 1470-1473 subtest "cancel() tests" => sub { Link Here
1470
    $schema->storage->txn_rollback;
1470
    $schema->storage->txn_rollback;
1471
};
1471
};
1472
1472
1473
subtest 'debit description from notice' => sub {
1474
    plan tests => 3;
1475
1476
    $schema->storage->txn_begin;
1477
1478
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1479
1480
    # Create a debit type
1481
    my $debit_type = $builder->build_object(
1482
        {
1483
            class => 'Koha::Account::DebitTypes',
1484
            value => {
1485
                code        => 'LUKEG_WAS_HERE',
1486
                description => 'Default description',
1487
                is_system   => 0,
1488
            }
1489
        }
1490
    );
1491
1492
    # Create a notice for this debit type
1493
    my $notice = $builder->build_object(
1494
        {
1495
            class => 'Koha::Notice::Templates',
1496
            value => {
1497
                module                 => 'debit_description',
1498
                code                   => 'LUKEG_WAS_HERE',
1499
                name                   => 'Test fee',
1500
                content                => 'You owe big time buddy, pay up: $[% accountline.amount | format("%.2f") %]',
1501
                branchcode             => '',
1502
                message_transport_type => 'email',
1503
                lang                   => 'default',
1504
            }
1505
        }
1506
    );
1507
1508
    # Create an account line - description should be set from notice
1509
    my $account_line = Koha::Account::Line->new(
1510
        {
1511
            borrowernumber    => $patron->borrowernumber,
1512
            debit_type_code   => 'LUKEG_WAS_HERE',
1513
            amount            => 10.50,
1514
            amountoutstanding => 10.50,
1515
            interface         => 'commandline',
1516
        }
1517
    )->store;
1518
1519
    is( $account_line->description, 'You owe big time buddy, pay up: $10.50', 'Description set from notice template' );
1520
1521
    # Create another line without a notice
1522
    $notice->delete;
1523
1524
    my $account_line2 = Koha::Account::Line->new(
1525
        {
1526
            borrowernumber    => $patron->borrowernumber,
1527
            debit_type_code   => 'LUKEG_WAS_HERE',
1528
            amount            => 5.00,
1529
            amountoutstanding => 5.00,
1530
            interface         => 'commandline',
1531
        }
1532
    )->store;
1533
1534
    is( $account_line2->description, undef, 'No notice, no description' );
1535
1536
    # Create a line with explicit description - should not be overridden
1537
    my $notice2 = $builder->build_object(
1538
        {
1539
            class => 'Koha::Notice::Templates',
1540
            value => {
1541
                module                 => 'debit_description',
1542
                code                   => 'LUKEG_WAS_HERE',
1543
                content                => 'From notice',
1544
                branchcode             => '',
1545
                message_transport_type => 'email',
1546
                lang                   => 'default',
1547
            }
1548
        }
1549
    );
1550
1551
    my $account_line3 = Koha::Account::Line->new(
1552
        {
1553
            borrowernumber    => $patron->borrowernumber,
1554
            debit_type_code   => 'LUKEG_WAS_HERE',
1555
            description       => 'Manual description',
1556
            amount            => 3.00,
1557
            amountoutstanding => 3.00,
1558
            interface         => 'commandline',
1559
        }
1560
    )->store;
1561
1562
    is( $account_line3->description, 'Manual description', 'System defined description is used' );
1563
1564
    $schema->storage->txn_rollback;
1565
};
1566
1473
1;
1567
1;
1474
- 

Return to bug 40255