From b1a91a610749fdd4098991e68ba10e22cdbd1c90 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 23 Oct 2017 12:35:46 -0400 Subject: [PATCH] Bug 12768 [QA Followup] - Only set non-Manual Invoice offset type if manualinvoice isn't actually being used for manual invoices --- C4/Accounts.pm | 13 ++-- Koha/Schema/Result/Accountoffset.pm | 135 +++++++++++++++++++++++++----------- 2 files changed, 103 insertions(+), 45 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 5fcbba0..704ef98 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -159,11 +159,11 @@ sub chargelostitem{ unless ($existing_charges) { #add processing fee if ($processfee && $processfee > 0){ - manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1); + manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1, 1); } #add replace cost if ($replacementprice > 0){ - manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1); + manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1, 1); } } } @@ -171,7 +171,7 @@ sub chargelostitem{ =head2 manualinvoice &manualinvoice($borrowernumber, $itemnumber, $description, $type, - $amount, $note); + $amount, $note, $skip_notify, $is_automatic); C<$borrowernumber> is the patron's borrower number. C<$description> is a description of the transaction. @@ -179,6 +179,8 @@ C<$type> may be one of C, C, C, C, C, C, C, or C. C<$itemnumber> is the item involved, if pertinent; otherwise, it should be the empty string. +C<$is_automatic> should be true if manual invoice isn't really being used +to create a manual invoice ( e.g. it's use in chargelostitem is automatic ) =cut @@ -195,7 +197,7 @@ should be the empty string. # sub manualinvoice { - my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $skip_notify ) = @_; + my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $skip_notify, $automatic ) = @_; my $manager_id = 0; $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; my $dbh = C4::Context->dbh; @@ -231,7 +233,8 @@ sub manualinvoice { )->store(); my $offset_type = - $type eq 'L' ? 'Lost Item' + !$automatic ? 'Manual Debit' + : $type eq 'L' ? 'Lost Item' : $type eq 'PF' ? 'Processing Fee' : 'Manual Debit'; diff --git a/Koha/Schema/Result/Accountoffset.pm b/Koha/Schema/Result/Accountoffset.pm index e9d8c2f..892c095 100644 --- a/Koha/Schema/Result/Accountoffset.pm +++ b/Koha/Schema/Result/Accountoffset.pm @@ -1,12 +1,12 @@ use utf8; -package Koha::Schema::Result::Accountoffset; +package Koha::Schema::Result::AccountOffset; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE =head1 NAME -Koha::Schema::Result::Accountoffset +Koha::Schema::Result::AccountOffset =cut @@ -15,40 +15,46 @@ use warnings; use base 'DBIx::Class::Core'; -=head1 TABLE: C +=head1 TABLE: C =cut -__PACKAGE__->table("accountoffsets"); +__PACKAGE__->table("account_offsets"); =head1 ACCESSORS -=head2 borrowernumber +=head2 id data_type: 'integer' - default_value: 0 - is_foreign_key: 1 + is_auto_increment: 1 is_nullable: 0 -=head2 accountno +=head2 credit_id - data_type: 'smallint' - default_value: 0 - is_nullable: 0 + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 -=head2 offsetaccount +=head2 debit_id - data_type: 'smallint' - default_value: 0 + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +=head2 type + + data_type: 'varchar' + is_foreign_key: 1 is_nullable: 0 + size: 16 -=head2 offsetamount +=head2 amount data_type: 'decimal' - is_nullable: 1 - size: [28,6] + is_nullable: 0 + size: [26,6] -=head2 timestamp +=head2 created_on data_type: 'timestamp' datetime_undef_if_invalid: 1 @@ -58,20 +64,17 @@ __PACKAGE__->table("accountoffsets"); =cut __PACKAGE__->add_columns( - "borrowernumber", - { - data_type => "integer", - default_value => 0, - is_foreign_key => 1, - is_nullable => 0, - }, - "accountno", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "offsetaccount", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "offsetamount", - { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "timestamp", + "id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "credit_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "debit_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "type", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 16 }, + "amount", + { data_type => "decimal", is_nullable => 0, size => [26, 6] }, + "created_on", { data_type => "timestamp", datetime_undef_if_invalid => 1, @@ -80,27 +83,79 @@ __PACKAGE__->add_columns( }, ); +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + =head1 RELATIONS -=head2 borrowernumber +=head2 credit + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "credit", + "Koha::Schema::Result::Accountline", + { accountlines_id => "credit_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 debit + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "debit", + "Koha::Schema::Result::Accountline", + { accountlines_id => "debit_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 type Type: belongs_to -Related object: L +Related object: L =cut __PACKAGE__->belongs_to( - "borrowernumber", - "Koha::Schema::Result::Borrower", - { borrowernumber => "borrowernumber" }, + "type", + "Koha::Schema::Result::AccountOffsetType", + { type => "type" }, { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OTfcUiJCPb5aU/gjqAb/bA +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-10-20 16:27:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tPPrIug2c7PbDO7LCxCJAA -# You can replace this text with custom content, and it will be preserved on regeneration +# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; -- 2.10.2