Bug 40255: Fixes for translations and updated unit tests
Signed-off-by: Scott Aylett <saylett@spanishfork.gov> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
9a6a5a01f0
commit
6b93327e6c
|
|
@ -28,6 +28,7 @@ use Koha::Database;
|
|||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Koha::Exceptions::Account;
|
||||
use Koha::Patron::Debarments;
|
||||
use Koha::Notice::Templates;
|
||||
use C4::Letters;
|
||||
|
||||
use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields);
|
||||
|
|
@ -1116,21 +1117,42 @@ sub store {
|
|||
}
|
||||
|
||||
#if there is a matching debit description letter, pull that content and render it for the accountline.description
|
||||
if ( $self->is_debit && !$self->in_storage && !$self->description ) {
|
||||
if ( $self->is_debit && !$self->in_storage ) {
|
||||
my $debit_type = $self->debit_type;
|
||||
if ($debit_type) {
|
||||
my $letter = C4::Letters::GetPreparedLetter(
|
||||
module => 'debit_description',
|
||||
letter_code => $debit_type->code,
|
||||
tables => {
|
||||
borrowers => $self->borrowernumber,
|
||||
branches => $self->branchcode,
|
||||
accountline => $self,
|
||||
},
|
||||
);
|
||||
|
||||
if ( $letter && $letter->{content} ) {
|
||||
$self->description( $letter->{content} );
|
||||
# get the patron's prederred lang
|
||||
my $patron = $self->patron;
|
||||
my $lang = $patron ? $patron->lang : 'default';
|
||||
|
||||
# check to make sure the custom notice exists
|
||||
my $notice_exists = Koha::Notice::Templates->search(
|
||||
{
|
||||
module => 'debit_description',
|
||||
code => $debit_type->code,
|
||||
message_transport_type => 'email',
|
||||
lang => $lang,
|
||||
}
|
||||
)->count;
|
||||
|
||||
if ($notice_exists) {
|
||||
my $letter = C4::Letters::GetPreparedLetter(
|
||||
module => 'debit_description',
|
||||
letter_code => $debit_type->code,
|
||||
message_transport_type => 'email',
|
||||
lang => $lang,
|
||||
tables => {
|
||||
borrowers => $self->borrowernumber,
|
||||
branches => $self->branchcode,
|
||||
},
|
||||
substitute => {
|
||||
accountline => $self,
|
||||
},
|
||||
);
|
||||
|
||||
if ( $letter && $letter->{content} ) {
|
||||
$self->description( $letter->{content} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1581,7 +1581,14 @@ subtest 'debit description from notice' => sub {
|
|||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $patron = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => {
|
||||
lang => 'default',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
# Create a debit type
|
||||
my $debit_type = $builder->build_object(
|
||||
|
|
@ -1665,7 +1672,7 @@ subtest 'debit description from notice' => sub {
|
|||
}
|
||||
)->store;
|
||||
|
||||
is( $account_line3->description, 'Manual description', 'System defined description is used' );
|
||||
is( $account_line3->description, 'From notice', 'Notice overrides manual description' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue