Bugzilla – Attachment 92885 Details for
Bug 23321
Add 'cash registers' to the accounts system
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23321: Add cash register support to paycollect
Bug-23321-Add-cash-register-support-to-paycollect.patch (text/plain), 10.29 KB, created by
Martin Renvoize (ashimema)
on 2019-09-17 11:26:41 UTC
(
hide
)
Description:
Bug 23321: Add cash register support to paycollect
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-09-17 11:26:41 UTC
Size:
10.29 KB
patch
obsolete
>From 7f0852bfe44298186951b1e57700d17539ee0da1 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 17 Sep 2019 12:24:27 +0100 >Subject: [PATCH] Bug 23321: Add cash register support to paycollect > >This patch ties in the cash registers system to the paycollect payment >pages in the staff client. > >Test plan: >1) Add some manual fees to a test patron >2) Select some fees to pay off >3) Note the addition of a select box for selecting your cash register > upon payment. >4) Set a branch default cash register for the current branch >5) Repeat step 3 and note that the pre-selected cash register is the one > set in step 4. >6) Unset the branch default cash register for the current branch >7) Repeat step 3 and note that there is no cash register pre-selected >8) Set 'UseCashRegisters' to 'Do not' >9) Repeat step 3 and note that there is no longer an option to select a > cash register >10) Signoff > >Sponsored-by: PTFS Europe >Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> >--- > Koha/Account.pm | 49 ++++++++++++------- > Koha/Exceptions/Account.pm | 11 ++++- > .../prog/en/modules/members/paycollect.tt | 31 ++++++++++++ > members/paycollect.pl | 22 ++++++++- > 4 files changed, 93 insertions(+), 20 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 35b438a0e1..719ea1da96 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -70,15 +70,16 @@ Koha::Account->new( { patron_id => $borrowernumber } )->pay( > sub pay { > my ( $self, $params ) = @_; > >- my $amount = $params->{amount}; >- my $description = $params->{description}; >- my $note = $params->{note} || q{}; >- my $library_id = $params->{library_id}; >- my $lines = $params->{lines}; >- my $type = $params->{type} || 'payment'; >- my $payment_type = $params->{payment_type} || undef; >- my $account_type = $params->{account_type}; >- my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment'; >+ my $amount = $params->{amount}; >+ my $description = $params->{description}; >+ my $note = $params->{note} || q{}; >+ my $library_id = $params->{library_id}; >+ my $lines = $params->{lines}; >+ my $type = $params->{type} || 'payment'; >+ my $payment_type = $params->{payment_type} || undef; >+ my $account_type = $params->{account_type}; >+ my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment'; >+ my $cash_register = $params->{cash_register}; > > my $userenv = C4::Context->userenv; > >@@ -86,6 +87,10 @@ sub pay { > > my $manager_id = $userenv ? $userenv->{number} : 0; > my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface; >+ Koha::Exceptions::Account::RegisterRequired->throw() >+ if ( C4::Context->preference("UseCashRegisters") >+ && !defined($cash_register) >+ && ( $interface ne 'opac' ) ); > > my @fines_paid; # List of account lines paid on with this payment > >@@ -227,6 +232,7 @@ sub pay { > manager_id => $manager_id, > interface => $interface, > branchcode => $library_id, >+ register_id => $cash_register, > note => $note, > } > )->store(); >@@ -327,15 +333,16 @@ sub add_credit { > my ( $self, $params ) = @_; > > # amount is passed as a positive value, but we store credit as negative values >- my $amount = $params->{amount} * -1; >- my $description = $params->{description} // q{}; >- my $note = $params->{note} // q{}; >- my $user_id = $params->{user_id}; >- my $interface = $params->{interface}; >- my $library_id = $params->{library_id}; >- my $payment_type = $params->{payment_type}; >- my $type = $params->{type} || 'payment'; >- my $item_id = $params->{item_id}; >+ my $amount = $params->{amount} * -1; >+ my $description = $params->{description} // q{}; >+ my $note = $params->{note} // q{}; >+ my $user_id = $params->{user_id}; >+ my $interface = $params->{interface}; >+ my $library_id = $params->{library_id}; >+ my $cash_register = $params->{cash_register}; >+ my $payment_type = $params->{payment_type}; >+ my $type = $params->{type} || 'payment'; >+ my $item_id = $params->{item_id}; > > unless ( $interface ) { > Koha::Exceptions::MissingParameter->throw( >@@ -343,6 +350,11 @@ sub add_credit { > ); > } > >+ Koha::Exceptions::Account::RegisterRequired->throw() >+ if ( C4::Context->preference("UseCashRegisters") >+ && !defined($cash_register) >+ && ( $payment_type eq 'CASH' ) ); >+ > my $schema = Koha::Database->new->schema; > > my $account_type = $Koha::Account::account_type_credit->{$type}; >@@ -364,6 +376,7 @@ sub add_credit { > manager_id => $user_id, > interface => $interface, > branchcode => $library_id, >+ register_id => $cash_register, > itemnumber => $item_id, > } > )->store(); >diff --git a/Koha/Exceptions/Account.pm b/Koha/Exceptions/Account.pm >index 4c2e2c3ff7..ea2df18f48 100644 >--- a/Koha/Exceptions/Account.pm >+++ b/Koha/Exceptions/Account.pm >@@ -41,8 +41,11 @@ use Exception::Class ( > 'Koha::Exceptions::Account::UnrecognisedType' => { > isa => 'Koha::Exceptions::Account', > description => 'Account type was not recognised' >+ }, >+ 'Koha::Exceptions::Account::RegisterRequired' => { >+ isa => 'Koha::Exceptions::Account', >+ description => 'Account transaction requires a cash register' > } >- > ); > > =head1 NAME >@@ -81,4 +84,10 @@ Exception to be used when a passed credit or debit is not of a recognised type. > > =cut > >+=head2 Koha::Exceptions::Account::RegisterRequired >+ >+Exception to be used when UseCashRegisters is enabled and one is not passed for a transaction. >+ >+=cut >+ > 1; >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 2f0b1679b3..535b66b6cc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt >@@ -122,6 +122,20 @@ > </select> > </li> > [% END %] >+ [% IF Koha.Preference('UseCashRegisters') %] >+ <li> >+ <label for="cash_register">Cash register: </label> >+ <select name="cash_register" id="cash_register"> >+ [% FOREACH register IN registers %] >+ [% IF register.id == registerid %] >+ <option value="[% register.id %]" selected="selected">[% register.name | html %]</option> >+ [% ELSE %] >+ <option value="[% register.id %]">[% register.name | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ [% END %] > </ol> > </fieldset> > >@@ -216,6 +230,7 @@ > <label>Change to give: </label> > <span id="change">0.00</span> > </li> >+ > [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %] > [% IF payment_types %] > <li> >@@ -228,6 +243,22 @@ > </select> > </li> > [% END %] >+ >+ [% IF Koha.Preference('UseCashRegisters') %] >+ <li> >+ <label for="cash_register">Cash register: </label> >+ <select name="cash_register" id="cash_register"> >+ [% FOREACH register IN registers %] >+ [% IF register.id == registerid %] >+ <option value="[% register.id %]" selected="selected">[% register.name | html %]</option> >+ [% ELSE %] >+ <option value="[% register.id %]">[% register.name | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ [% END %] >+ > <li> > <label for="selected_accts_notes">Note: </label> > <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea> >diff --git a/members/paycollect.pl b/members/paycollect.pl >index a25f6a4030..2a1aeb9b0b 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -28,6 +28,7 @@ use C4::Members; > use C4::Accounts; > use C4::Koha; > >+use Koha::Cash::Registers; > use Koha::Patrons; > use Koha::Patron::Categories; > use Koha::AuthorisedValues; >@@ -74,6 +75,21 @@ my $payment_note = uri_unescape scalar $input->param('payment_note'); > my $payment_type = scalar $input->param('payment_type'); > my $accountlines_id; > >+my $registerid = $input->param('registerid'); >+if ( !$registerid ) { >+ $registerid = Koha::Cash::Registers->find( >+ { branch => $library_id, branch_default => 1 }, >+ )->id; >+} >+my $registers = Koha::Cash::Registers->search( >+ { branch => $library_id, archived => 0 }, >+ { order_by => { '-asc' => 'name' } } >+); >+$template->param( >+ registerid => $registerid, >+ registers => $registers, >+); >+ > if ( $pay_individual || $writeoff_individual ) { > if ($pay_individual) { > $template->param( pay_individual => 1 ); >@@ -130,6 +146,7 @@ if ( $total_paid and $total_paid ne '0.00' ) { > note => $payment_note, > interface => C4::Context->interface, > payment_type => $payment_type, >+ cash_register => $registerid > } > ); > print $input->redirect( >@@ -160,6 +177,7 @@ if ( $total_paid and $total_paid ne '0.00' ) { > note => $note, > interface => C4::Context->interface, > payment_type => $payment_type, >+ cash_register => $registerid > } > ); > } >@@ -171,7 +189,9 @@ if ( $total_paid and $total_paid ne '0.00' ) { > library_id => $library_id, > note => $note, > payment_type => $payment_type, >- interface => C4::Context->interface >+ interface => C4::Context->interface, >+ payment_type => $payment_type, >+ cash_register => $registerid > } > ); > } >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23321
:
91596
|
91597
|
91598
|
91599
|
91600
|
91601
|
91602
|
91621
|
92057
|
92058
|
92059
|
92060
|
92061
|
92062
|
92063
|
92064
|
92065
|
92083
|
92084
|
92085
|
92086
|
92087
|
92088
|
92089
|
92090
|
92091
|
92394
|
92395
|
92396
|
92397
|
92398
|
92399
|
92400
|
92401
|
92402
|
92467
|
92468
|
92469
|
92470
|
92471
|
92472
|
92473
|
92474
|
92475
|
92803
|
92804
|
92805
|
92806
|
92807
|
92808
|
92809
|
92810
|
92811
|
92812
|
92813
|
92814
|
92829
|
92879
|
92880
|
92881
|
92882
|
92883
|
92884
|
92885
|
92886
|
92887
|
92888
|
92889
|
93019
|
93020
|
93021
|
93022
|
93023
|
93024
|
93025
|
93026
|
93027
|
93028
|
93029
|
93030
|
93031
|
93032
|
93033
|
93034
|
93035
|
93188