From b74625f46284574445bb9c013a64c463bfe4d90e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 20 Nov 2019 07:53:05 +0000 Subject: [PATCH] Bug 23354: (follow-up) Update for bugs 23049 and 23805 Remove all mentions of accounttype and replace with debit_type_code and credit_type_code as appropriate. --- Koha/Charges/Sales.pm | 4 ++-- installer/data/mysql/account_credit_types.sql | 3 ++- installer/data/mysql/atomicupdate/bug_23354.perl | 10 ++++++++-- installer/data/mysql/en/mandatory/sample_notices.sql | 5 +++-- t/db_dependent/Koha/Charges/Sales.pm | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Koha/Charges/Sales.pm b/Koha/Charges/Sales.pm index bd88423d6a..4ffb35e29f 100644 --- a/Koha/Charges/Sales.pm +++ b/Koha/Charges/Sales.pm @@ -210,7 +210,7 @@ sub purchase { my $debit = Koha::Account::Line->new( { amount => $amount, - accounttype => $item->{code}, + debit_type_code => $item->{code}, amountoutstanding => 0, note => $item->{quantity}, manager_id => $self->{staff_id}, @@ -235,7 +235,7 @@ sub purchase { $credit = Koha::Account::Line->new( { amount => 0 - $total_owed, - accounttype => 'Purchase', + credit_type_code => 'PURCHASE', payment_type => $self->{payment_type}, amountoutstanding => 0, manager_id => $self->{staff_id}, diff --git a/installer/data/mysql/account_credit_types.sql b/installer/data/mysql/account_credit_types.sql index bdfa4abbba..67bf817e7e 100644 --- a/installer/data/mysql/account_credit_types.sql +++ b/installer/data/mysql/account_credit_types.sql @@ -5,6 +5,7 @@ INSERT INTO account_credit_types ( code, description, can_be_added_manually, is_ ('CREDIT', 'Credit', 1, 1), ('DISCOUNT', 'A discount applied to a patrons fine', 0, 1), ('REFUND', 'A refund applied to a patrons fine', 0, 1), -('LOST_RETURN', 'Lost item fee refund', 0, 1); +('LOST_RETURN', 'Lost item fee refund', 0, 1), +('PURCHASE', 'Purchase', 0, 1); INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('PAYMENT_TYPE','CASH','Cash'); diff --git a/installer/data/mysql/atomicupdate/bug_23354.perl b/installer/data/mysql/atomicupdate/bug_23354.perl index 2e920c459d..717eaa5e42 100644 --- a/installer/data/mysql/atomicupdate/bug_23354.perl +++ b/installer/data/mysql/atomicupdate/bug_23354.perl @@ -5,6 +5,11 @@ if( CheckVersion( $DBversion ) ) { INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Purchase' ); }); + $dbh->do(q{ + INSERT INTO account_credit_types ( code, description, can_be_added_manually, is_system ) + VALUES ('PURCHASE', 'Purchase', 0, 1); + }); + my $sth = $dbh->prepare(q{ SELECT COUNT(*) FROM authorised_values WHERE category = 'PAYMENT_TYPE' AND authorised_value = 'CASH' }); @@ -40,7 +45,8 @@ if( CheckVersion( $DBversion ) ) { $dbh->do(q{ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES -('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', ' +('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '[% PROCESS "accounts.inc" %] +
[% IF ( LibraryName ) %] - + [% END %] diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql index a970969bfd..1fea0039ad 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ b/installer/data/mysql/en/mandatory/sample_notices.sql @@ -318,7 +318,8 @@ INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title` ('circulation', 'SR_SLIP', '', 'Stock rotation slip', 0, 'Stock rotation report', 'Stock rotation report for [% branch.name %]:\r\n\r\n[% IF branch.items.size %][% branch.items.size %] items to be processed for this branch.\r\n[% ELSE %]No items to be processed for this branch\r\n[% END %][% FOREACH item IN branch.items %][% IF item.reason != \'in-demand\' %]Title: [% item.title %]\r\nAuthor: [% item.author %]\r\nCallnumber: [% item.callnumber %]\r\nLocation: [% item.location %]\r\nBarcode: [% item.barcode %]\r\nOn loan?: [% item.onloan %]\r\nStatus: [% item.reason %]\r\nCurrent library: [% item.branch.branchname %] [% item.branch.branchcode %]\r\n\r\n[% END %][% END %]', 'email'); INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES -('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '
@@ -83,7 +89,7 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, [% FOREACH offset IN offsets %]
[% offset.debit.accounttype %][% PROCESS account_type_description account=offset.debit %] [% offset.amount * -1 | $Price %]
+('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '[% PROCESS "accounts.inc" %] +
[% IF ( LibraryName ) %] - + [% END %] diff --git a/t/db_dependent/Koha/Charges/Sales.pm b/t/db_dependent/Koha/Charges/Sales.pm index e4dbdd366e..54fe37c7ca 100644 --- a/t/db_dependent/Koha/Charges/Sales.pm +++ b/t/db_dependent/Koha/Charges/Sales.pm @@ -250,7 +250,7 @@ subtest 'purchase tests' => sub { is(ref($credit), 'Koha::Account::Line', "Koha::Account::Line returned"); ok($credit->is_credit, "return is a credit for payment"); - is($credit->accounttype, 'Purchase', "accounttype set correctly to 'Purchase' for payment"); + is($credit->credit_type_code, 'PURCHASE', "credit_type_code set correctly to 'PURCHASE' for payment"); is($credit->amount, -5.00, "amount is calculated correctly for payment"); is($credit->amountoutstanding, 0.00, "amountoutstanding is set to zero for payment"); is($credit->manager_id, $staff->borrowernumber, "manager_id set correctionly for payment"); -- 2.20.1
@@ -361,7 +362,7 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, [% FOREACH offset IN offsets %]
[% offset.debit.accounttype %][% PROCESS account_type_description account=offset.debit %] [% offset.amount * -1 | $Price %]