From 2edce150831dc75054a74c2e333cf044eb59892f Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Tue, 26 Sep 2017 11:02:21 -0400 Subject: [PATCH] Bug 5620 - Capture mode of payment. Correction to template files Patch is rebased, should now apply. --- Koha/Account.pm | 4 +++ Koha/Schema/Result/Accountline.pm | 2 ++ .../atomicupdate/bug5620_Add_Mode_Of_Payment.sql | 6 +++++ installer/data/mysql/kohastructure.sql | 1 + .../prog/en/modules/members/boraccount.tt | 3 +++ .../prog/en/modules/members/paycollect.tt | 31 +++++++++++++++++----- members/paycollect.pl | 8 +++--- 7 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql diff --git a/Koha/Account.pm b/Koha/Account.pm index 9ec1c1b..1b7855f 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -68,6 +68,7 @@ sub pay { my $library_id = $params->{library_id}; my $lines = $params->{lines}; my $type = $params->{type} || 'payment'; + my $paymentmode = $params->{paymentmode}; my $userenv = C4::Context->userenv; @@ -121,6 +122,7 @@ sub pay { accountno => $fine->accountno, manager_id => $manager_id, note => $note, + paymentmode => $paymentmode, } ) ); @@ -164,6 +166,7 @@ sub pay { accountno => $fine->accountno, manager_id => $manager_id, note => $note, + paymentmode => $paymentmode, } ) ); @@ -192,6 +195,7 @@ sub pay { amountoutstanding => 0 - $balance_remaining, manager_id => $manager_id, note => $note, + paymentmode => $paymentmode, } )->store(); diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm index d3fa5b3..cd50c5c 100644 --- a/Koha/Schema/Result/Accountline.pm +++ b/Koha/Schema/Result/Accountline.pm @@ -169,6 +169,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "manager_id", { data_type => "integer", is_nullable => 1 }, + "paymentmode", + {data_type => "text", is_nullable => 0 }, ); =head1 PRIMARY KEY diff --git a/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql b/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql new file mode 100644 index 0000000..b3e8196 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug5620_Add_Mode_Of_Payment.sql @@ -0,0 +1,6 @@ +ALTER table accountlines ADD COLUMN paymentmode TEXT NOT NULL; +INSERT INTO authorised_value_categories VALUES ('PAYMODE'); +INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES +('PAYMODE','CASH', 'Cash', 'Cash'), +('PAYMODE','CC', 'Credit Card', 'Credit Card'), +('PAYMODE','DEBIT', 'Debit', 'Debit'); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 2edd371..561016c 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2726,6 +2726,7 @@ CREATE TABLE `accountlines` ( `notify_level` int(2) NOT NULL default 0, `note` text NULL default NULL, `manager_id` int(11) NULL, + `paymentmode` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`accountlines_id`), KEY `acctsborridx` (`borrowernumber`), KEY `timeidx` (`timestamp`), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index ec79237..1eb2e43 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -2,6 +2,7 @@ [% USE KohaDates %] [% USE ColumnsSettings %] [% USE Price %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %] Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %] [% INCLUDE 'doc-head-close.inc' %] @@ -68,6 +69,7 @@ $(document).ready(function() { Date Description of charges Note + Payment mode Amount Outstanding [% IF ( reverse_col ) %] @@ -109,6 +111,7 @@ $(document).ready(function() { [%- IF account.description %], [% account.description %][% END %]  [% IF ( account.itemnumber ) %][% account.title |html %][% END %] [% account.note | html_line_break %] + [% AuthorisedValues.GetByCode('PAYMODE',account.paymentmode) %] [% IF ( account.amountcredit ) %][% ELSE %][% END %][% account.amount | $Price %] [% IF ( account.amountoutstandingcredit ) %][% ELSE %][% END %][% account.amountoutstanding | $Price %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index a1458b5..3e52214 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE Branches %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %] Koha › Patrons › Collect fine payment for [% borrower.firstname %] [% borrower.surname %] [% INCLUDE 'doc-head-close.inc' %] @@ -147,6 +148,14 @@ function moneyFormat(textObj) { +
  • + + +
  • @@ -206,15 +215,23 @@ function moneyFormat(textObj) { Total amount outstanding: [% total | format('%.2f') %] -
  • - - - -
  • -
  • +
  • + + + +
  • +
  • + + +
  • +
  • -
  • +
    diff --git a/members/paycollect.pl b/members/paycollect.pl index f880f57..d107dc7 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -64,6 +64,7 @@ my $branch = C4::Context->userenv->{'branch'}; my ( $total_due, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber); my $total_paid = $input->param('paid'); +my $paymentmode = $input->param('paymentmode'); my $individual = $input->param('pay_individual'); my $writeoff = $input->param('writeoff_individual'); @@ -123,7 +124,8 @@ if ( $total_paid and $total_paid ne '0.00' ) { lines => [$line], amount => $total_paid, library_id => $branch, - note => $payment_note + note => $payment_note, + paymentmode => $paymentmode, } ); print $input->redirect( @@ -135,7 +137,6 @@ if ( $total_paid and $total_paid ne '0.00' ) { } my @acc = split /,/, $select; my $note = $input->param('selected_accts_notes'); - my @lines = Koha::Account::Lines->search( { borrowernumber => $borrowernumber, @@ -154,13 +155,14 @@ if ( $total_paid and $total_paid ne '0.00' ) { amount => $total_paid, lines => \@lines, note => $note, + paymentmode => $paymentmode, } ); } else { my $note = $input->param('selected_accts_notes'); Koha::Account->new( { patron_id => $borrowernumber } ) - ->pay( { amount => $total_paid, note => $note } ); + ->pay( { amount => $total_paid, note => $note, paymentmode => $paymentmode } ); } print $input->redirect( -- 2.7.4