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

(-)a/installer/data/mysql/atomicupdate/bug_8838.pl (-5 / +9 lines)
Lines 7-22 return { Link Here
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
9
10
        $dbh->do(q{
10
        $dbh->do(
11
            INSERT IGNORE INTO `letter` VALUES (NULL,'reserves','HOLDDGST','','Hold available for pickup (digest)',0,'Hold(s) available for pickup','You have one or more holds available for pickup:\r\n----\r\nTitle: [% hold.biblio.title %]\r\nAuthor: [% hold.biblio.author %]\r\nCopy: [% hold.item.copynumber %]\r\nLocation: [% hold.branch.branchname %]\r\nWaiting since: [% hold.waitingdate %]:\r\n[% hold.branch.branchaddress1 %]\r\n[% hold.branch.branchaddress2 %]\r\n[% hold.branch.branchaddress3 %]\r\n[% hold.branch.branchcity %] [% hold.branch.branchzip %]\r\n----','email','default','2023-08-29 18:42:15');
11
            q{
12
        });
12
            INSERT IGNORE INTO `letter` VALUES (NULL,'reserves','HOLDDGST','','Hold available for pickup (digest)',0,'Hold(s) available for pickup','You have one or more holds available for pickup:\r\n----\r\nTitle: [% hold.biblio.title %]\r\nAuthor: [% hold.biblio.author %]\r\nCopy: [% hold.item.copynumber %]\r\nLocation: [% hold.branch.branchname %]\r\nWaiting since: [% hold.waitingdate %]\r\n[% hold.branch.branchaddress1 %]\r\n[% hold.branch.branchaddress2 %]\r\n[% hold.branch.branchaddress3 %]\r\n[% hold.branch.branchcity %] [% hold.branch.branchzip %]\r\n----','email','default','2023-08-29 18:42:15');
13
        }
14
        );
13
15
14
        $dbh->do(q{
16
        $dbh->do(
17
            q{
15
            INSERT IGNORE INTO message_transports VALUES
18
            INSERT IGNORE INTO message_transports VALUES
16
            ( 4, "email", 1, "reserves", "HOLDDGST", "" ),
19
            ( 4, "email", 1, "reserves", "HOLDDGST", "" ),
17
            ( 4, "sms", 1, "reserves", "HOLDDGST", "" ),
20
            ( 4, "sms", 1, "reserves", "HOLDDGST", "" ),
18
            ( 4, "phone", 1, "reserves", "HOLDDGST", "");
21
            ( 4, "phone", 1, "reserves", "HOLDDGST", "");
19
        });
22
        }
23
        );
20
24
21
        # Print useful stuff here
25
        # Print useful stuff here
22
        # tables
26
        # tables
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (-1 / +1 lines)
Lines 1806-1812 tables: Link Here
1806
            - "Author: [% hold.biblio.author %]"
1806
            - "Author: [% hold.biblio.author %]"
1807
            - "Copy: [% hold.item.copynumber %]"
1807
            - "Copy: [% hold.item.copynumber %]"
1808
            - "Waiting since: [% hold.waitingdate %]"
1808
            - "Waiting since: [% hold.waitingdate %]"
1809
            - "Waitng at: [% hold.branch.branchname %]"
1809
            - "Waiting at: [% hold.branch.branchname %]"
1810
            - "[% hold.branch.branchaddress1 %]"
1810
            - "[% hold.branch.branchaddress1 %]"
1811
            - "[% hold.branch.branchaddress2 %]"
1811
            - "[% hold.branch.branchaddress2 %]"
1812
            - "[% hold.branch.branchaddress3 %]"
1812
            - "[% hold.branch.branchaddress3 %]"
(-)a/t/db_dependent/Reserves.t (-53 / +68 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 79;
20
use Test::More tests => 77;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1819-1885 subtest 'HOLDDGST tests' => sub { Link Here
1819
    plan tests => 2;
1819
    plan tests => 2;
1820
    $schema->storage->txn_begin;
1820
    $schema->storage->txn_begin;
1821
1821
1822
    my $branch = $builder->build_object({
1822
    my $branch = $builder->build_object(
1823
        class => 'Koha::Libraries',
1823
        {
1824
        value => {
1824
            class => 'Koha::Libraries',
1825
            branchemail => 'branch@e.mail',
1825
            value => {
1826
            branchreplyto => 'branch@reply.to',
1826
                branchemail     => 'branch@e.mail',
1827
            pickup_location => 1
1827
                branchreplyto   => 'branch@reply.to',
1828
                pickup_location => 1
1829
            }
1828
        }
1830
        }
1829
    });
1831
    );
1830
    my $item = $builder->build_sample_item({
1832
    my $item = $builder->build_sample_item(
1831
        homebranch => $branch->branchcode,
1833
        {
1832
        holdingbranch => $branch->branchcode
1834
            homebranch    => $branch->branchcode,
1833
    });
1835
            holdingbranch => $branch->branchcode
1834
    my $item2 = $builder->build_sample_item({
1836
        }
1835
        homebranch => $branch->branchcode,
1837
    );
1836
        holdingbranch => $branch->branchcode
1838
    my $item2 = $builder->build_sample_item(
1837
    });
1839
        {
1840
            homebranch    => $branch->branchcode,
1841
            holdingbranch => $branch->branchcode
1842
        }
1843
    );
1838
1844
1839
    my $wants_hold_and_email = {
1845
    my $wants_hold_and_email = {
1840
        wants_digest => '1',
1846
        wants_digest => '1',
1841
        transports => {
1847
        transports   => {
1842
            sms => 'HOLDDGST',
1848
            sms   => 'HOLDDGST',
1843
            email => 'HOLDDGST',
1849
            email => 'HOLDDGST',
1844
            },
1850
        },
1845
        letter_code => 'HOLDDGST'
1851
        letter_code => 'HOLDDGST'
1846
    };
1852
    };
1847
1853
1848
    my $mp = Test::MockModule->new( 'C4::Members::Messaging' );
1854
    my $mp = Test::MockModule->new('C4::Members::Messaging');
1849
1855
1850
    $mp->mock("GetMessagingPreferences",$wants_hold_and_email);
1856
    $mp->mock( "GetMessagingPreferences", $wants_hold_and_email );
1851
1857
1852
    $dbh->do('DELETE FROM letter');
1858
    $dbh->do('DELETE FROM letter');
1853
1859
1854
    my $email_hold_notice = $builder->build({
1860
    my $email_hold_notice = $builder->build(
1861
        {
1855
            source => 'Letter',
1862
            source => 'Letter',
1856
            value => {
1863
            value  => {
1857
                message_transport_type => 'email',
1864
                message_transport_type => 'email',
1858
                branchcode => '',
1865
                branchcode             => '',
1859
                code => 'HOLDDGST',
1866
                code                   => 'HOLDDGST',
1860
                module => 'reserves',
1867
                module                 => 'reserves',
1861
                lang => 'default',
1868
                lang                   => 'default',
1862
            }
1869
            }
1863
        });
1870
        }
1871
    );
1864
1872
1865
    my $sms_hold_notice = $builder->build({
1873
    my $sms_hold_notice = $builder->build(
1874
        {
1866
            source => 'Letter',
1875
            source => 'Letter',
1867
            value => {
1876
            value  => {
1868
                message_transport_type => 'sms',
1877
                message_transport_type => 'sms',
1869
                branchcode => '',
1878
                branchcode             => '',
1870
                code => 'HOLDDGST',
1879
                code                   => 'HOLDDGST',
1871
                module => 'reserves',
1880
                module                 => 'reserves',
1872
                lang=>'default',
1881
                lang                   => 'default',
1873
            }
1882
            }
1874
        });
1883
        }
1884
    );
1875
1885
1876
    my $hold_borrower = $builder->build({
1886
    my $hold_borrower = $builder->build(
1887
        {
1877
            source => 'Borrower',
1888
            source => 'Borrower',
1878
            value => {
1889
            value  => {
1879
                smsalertnumber=>'5555555551',
1890
                smsalertnumber => '5555555551',
1880
                email=>'a@c.com',
1891
                email          => 'a@c.com',
1881
            }
1892
            }
1882
        })->{borrowernumber};
1893
        }
1894
    )->{borrowernumber};
1883
1895
1884
    C4::Reserves::AddReserve(
1896
    C4::Reserves::AddReserve(
1885
        {
1897
        {
Lines 1897-1918 subtest 'HOLDDGST tests' => sub { Link Here
1897
        }
1909
        }
1898
    );
1910
    );
1899
1911
1900
    ModReserveAffect($item->itemnumber, $hold_borrower, 0);
1912
    ModReserveAffect( $item->itemnumber,  $hold_borrower, 0 );
1901
    ModReserveAffect($item2->itemnumber, $hold_borrower, 0);
1913
    ModReserveAffect( $item2->itemnumber, $hold_borrower, 0 );
1902
1914
1903
    my $sms_count = $schema->resultset('MessageQueue')->search({
1915
    my $sms_count = $schema->resultset('MessageQueue')->search(
1904
            letter_code     => 'HOLDDGST',
1916
        {
1917
            letter_code            => 'HOLDDGST',
1905
            message_transport_type => 'sms',
1918
            message_transport_type => 'sms',
1906
            borrowernumber => $hold_borrower,
1919
            borrowernumber         => $hold_borrower,
1907
        })->count;
1920
        }
1908
    is($sms_count, 1 ,"Only one sms hold digest message created for two holds");
1921
    )->count;
1922
    is( $sms_count, 1, "Only one sms hold digest message created for two holds" );
1909
1923
1910
    my $email_count = $schema->resultset('MessageQueue')->search({
1924
    my $email_count = $schema->resultset('MessageQueue')->search(
1911
            letter_code     => 'HOLDDGST',
1925
        {
1926
            letter_code            => 'HOLDDGST',
1912
            message_transport_type => 'email',
1927
            message_transport_type => 'email',
1913
            borrowernumber => $hold_borrower,
1928
            borrowernumber         => $hold_borrower,
1914
        })->count;
1929
        }
1915
    is($email_count, 1 ,"Only one email hold digest message created for two holds");
1930
    )->count;
1931
    is( $email_count, 1, "Only one email hold digest message created for two holds" );
1916
1932
1917
    $schema->txn_rollback;
1933
    $schema->txn_rollback;
1918
};
1934
};
1919
- 

Return to bug 8838