From 517a0b11710671b4aa1ee8a3ef76179ec83e4489 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Fri, 30 Nov 2018 09:45:19 -0300
Subject: [PATCH] Bug 21915: Call reconcile_balance on manual invoice creation

This patch makes the manual invoice creation step call
Koha::Account::reconcile_balance when the AccountAutoReconcile syspref
is set.

To test:
- Apply the patch
- Have some outstanding credit
- Create a manual invoice
=> SUCCESS: Same behaviour as always
- Set AccountAutoReconcile
- Create a manual invoice
=> SUCCESS: Reconcillation happened
- Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 members/maninvoice.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/members/maninvoice.pl b/members/maninvoice.pl
index db7a447ffa..e101d07fe2 100755
--- a/members/maninvoice.pl
+++ b/members/maninvoice.pl
@@ -87,6 +87,11 @@ if ($add){
             $template->param( 'ERROR' => $error );
             output_html_with_http_headers $input, $cookie, $template->output;
         } else {
+
+            if ( C4::Context->preference('AccountAutoReconcile') ) {
+                $patron->account->reconcile_balance;
+            }
+
             print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
             exit;
         }
-- 
2.19.2