use Modern::Perl; return { bug_number => "31713", description => "Add ACCOUNTS_SUMMARY slip notice", up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; my $slip_content = <<~'END_CONTENT'; [% USE Branches %] [% USE Koha %] [% USE KohaDates %] [% USE Price %] [% PROCESS 'accounts.inc' %] [% IF ( Koha.Preference('LibraryName') ) %] [% END %] [% IF borrower.account.outstanding_debits.total_outstanding %] [% FOREACH debit IN borrower.account.outstanding_debits %] [% END %] [% ELSE %] [% END %] [% IF borrower.account.outstanding_credits.total_outstanding %] [% FOREACH credit IN borrower.account.outstanding_credits %] [% END %] [% ELSE %] [% END %] [% IF ( borrower.account.balance <= 0 ) %] [% ELSE %][% END %]

[% Koha.Preference('LibraryName') | html %]

[% Branches.GetName( borrower.branchcode ) | html %]

Outstanding accounts

Debts

Date Charge Amount Outstanding
[% debit.date | $KohaDates %] [% PROCESS account_type_description account=debit %] [%- IF debit.description %], [% debit.description | html %][% END %] [% debit.amount | $Price %] [% debit.amountoutstanding | $Price %]
There are no outstanding debts on your account

Credits

Date Credit Amount Outstanding
[% credit.date | $KohaDates %] [% PROCESS account_type_description account=credit %] [%- IF credit.description %], [% credit.description | html %][% END %] [% credit.amount *-1 | $Price %] [% credit.amountoutstanding *-1 | $Price %]
There are no outstanding credits on your account
[% IF borrower.account.balance < 0 %] Total credit as of [% today | $KohaDates %]: [% ELSE %] Total outstanding dues as of [% today | $KohaDates %]: [% END %] [% borrower.account.balance * -1 | $Price %][% borrower.account.balance | $Price %]
END_CONTENT $dbh->do(qq{ INSERT IGNORE INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ( 'members', 'ACCOUNTS_SUMMARY', '', 'Account balance slip', 1, 'Account summary for [% borrower.firstname %] [% borrower.surname %]', "$slip_content", 'print', 'default' ) }); say $out "Notice added"; }, };