From cf7fdd116fc65afd89f187ae2bd4e502e669e1e3 Mon Sep 17 00:00:00 2001 From: Bill Ott Date: Wed, 5 Aug 2015 13:38:09 -0400 Subject: [PATCH] Create grocery bill/payment to track the addition of patron credit. Other than looking at credit_forward_balance in the usr auditor table, there is no other way to see where additional credit was added. ToDo: something other than hard coding billing_type and btype. These must match entries in config.billing_type Signed-off-by: Bill Ott --- .../perlmods/lib/OpenILS/Application/Circ/Money.pm | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm index 30e0ca932e..8b79ca6ce0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm @@ -603,6 +603,34 @@ sub _update_patron_credit { $patron->credit_forward_balance($patron->credit_forward_balance + $credit); return OpenILS::Event->new('NEGATIVE_PATRON_BALANCE') if $patron->credit_forward_balance < 0; $e->update_actor_user($patron) or return $e->die_event; + + if ($credit > 0){ + my $cbill = "Fieldmapper::money::grocery"; + $cbill = $cbill->new; + $cbill->billing_location($e->requestor->ws_ou); + $cbill->note("New credit: $credit"); + $cbill->usr($patron->id); + my $tid = $e->create_money_grocery($cbill); + + my $billobj = "Fieldmapper::money::billing"; + $billobj = $billobj->new; + $billobj->amount($credit); + $billobj->xact($tid); + $billobj->billing_type("Credit Added"); # text field, but for sanity, make it match config.billing_type + $billobj->btype(235); # be sure ID matches config.billing_type id + $e->create_money_billing($billobj) or return $e->die_event; + + my $payobj = "Fieldmapper::money::cash_payment"; + $payobj = $payobj->new; + $payobj->amount($credit); + $payobj->amount_collected($credit); + $payobj->xact($tid); + $payobj->note("New credit: $credit"); + $payobj->accepting_usr($e->requestor->id); + $payobj->cash_drawer($e->requestor->wsid); + $e->create_money_cash_payment($payobj) or return $e->die_event; + } + return undef; } -- 2.11.0