Bugzilla – Attachment 76300 Details for
Bug 20980
Manual credit offsets are stored as debits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20980: Make mancredit.pl use Koha::Account::add_credit
Bug-20980-Make-mancreditpl-use-KohaAccountaddcredi.patch (text/plain), 4.20 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-06-22 15:57:21 UTC
(
hide
)
Description:
Bug 20980: Make mancredit.pl use Koha::Account::add_credit
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-06-22 15:57:21 UTC
Size:
4.20 KB
patch
obsolete
>From 5a9680145313c8eec93f5d43a53dd4f173077d8b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 22 Jun 2018 12:23:47 -0300 >Subject: [PATCH] Bug 20980: Make mancredit.pl use Koha::Account::add_credit > >This patch makes creating a manual credit from the UI record the account >offset as 'Manual Credit', and properly set account_offsets.credit_id >instead of account_offsets.debit_id. > >To test: >- Create a manual credit (of 'Credit' type) for a known patron (acevedo?) >- Run: > $ sudo koha-mysql kohadev > > SELECT * FROM account_offsets; >=> FAIL: The account offset for the manual credit has type=Manual Debit, > credit_id=NULL and debit_id=accountlines_id >- Run the atomic update: > $ updatedatabase >- Run: > $ sudo koha-mysql kohadev > > SELECT * FROM account_offsets; >=> SUCCESS: The account offset has been corrected and now has >type=Manual Credit, credit_id=accountlines_id and debit_id=NULL >- Create a new manual credit (of 'Forgiven' type) for a known patron >- Run: > $ sudo koha-mysql kohadev > > SELECT * FROM account_offsets; >=> SUCCESS: The account offset has been stored correctly as a credit! >- Sign off :-D >--- > .../prog/en/modules/members/mancredit.tt | 4 +-- > members/mancredit.pl | 32 +++++++++++++------ > 2 files changed, 24 insertions(+), 12 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >index 305910f0da..9aca8b52c7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >@@ -37,8 +37,8 @@ > <fieldset class="rows"> > <legend>Manual credit</legend><ol> > <li><label for="type">Credit type: </label><select name="type" id="type"> >-<option value="C">Credit</option> >-<option value="FOR">Forgiven</option> >+<option value="credit">Credit</option> >+<option value="forgiven">Forgiven</option> > </select></li> > <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li> > <li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li> >diff --git a/members/mancredit.pl b/members/mancredit.pl >index 0e8ac3e637..f1d388d577 100755 >--- a/members/mancredit.pl >+++ b/members/mancredit.pl >@@ -32,8 +32,9 @@ use C4::Members; > use C4::Accounts; > use C4::Items; > use C4::Members::Attributes qw(GetBorrowerAttributes); >-use Koha::Patrons; > >+use Koha::Account; >+use Koha::Patrons; > use Koha::Patron::Categories; > use Koha::Token; > >@@ -50,7 +51,10 @@ unless ( $patron ) { > my $add=$input->param('add'); > > if ($add){ >- if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) { >+ >+ my ( $user_id ) = checkauth( $input, 0, $flagsrequired, 'intranet' ); >+ >+ if ( $user_id ) { > > die "Wrong CSRF token" > unless Koha::Token->new->check_csrf( { >@@ -61,16 +65,24 @@ if ($add){ > # Note: If the logged in user is not allowed to see this patron an invoice can be forced > # Here we are trusting librarians not to hack the system > my $barcode = $input->param('barcode'); >- my $itemnum; >+ my $item_id; > if ($barcode) { >- $itemnum = GetItemnumberFromBarcode($barcode); >+ $item_id = GetItemnumberFromBarcode($barcode); > } >- my $desc = $input->param('desc'); >- my $note = $input->param('note'); >- my $amount = $input->param('amount') || 0; >- $amount = -$amount; >- my $type = $input->param('type'); >- manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note ); >+ my $description = $input->param('desc'); >+ my $note = $input->param('note'); >+ my $amount = $input->param('amount') || 0; >+ my $type = $input->param('type'); >+ >+ Koha::Account->new({ patron_id => $borrowernumber })->add_credit({ >+ amount => $amount, >+ description => $description, >+ item_id => $item_id, >+ note => $note, >+ type => $type, >+ user_id => $user_id >+ }); >+ > print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); > } > } else { >-- >2.18.0
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 20980
:
76299
|
76300
|
76301
|
76322
|
76323
|
76324
|
76325
|
76401
|
76402
|
76403
|
76404
|
76442
|
76443
|
76444
|
76445
|
76728
|
76729
|
76730
|
76731
|
76732
|
76734