Bug 22296

Summary: Invoice adjustments are not populating to budget views
Product: Koha Reporter: Nick Clemens <nick>
Component: AcquisitionsAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: major    
Priority: P5 - low CC: fiona.borthwick, janet.mcgowan, josef.moravec, katrin.fischer, kelly, lucas, martin.renvoize
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 22498    
Bug Blocks:    
Attachments: WIP Add Invoice Adjustments to GetBudgetHierarchy
Bug 22296: Add Invoice Adjustments to GetBudgetHierarchy
Bug 22296: Add Invoice Adjustments to GetBudgetHierarchy
Bug 22296: Add Invoice Adjustments to GetBudgetHierarchy

Description Nick Clemens 2019-02-08 20:23:57 UTC
When invoice adjustments were added they were made to populate spent.pl and ordered.pl, however, they are not taken into account on aqui-home.pl or aqbudgets.pl

They must be added in to GetBudgetHierarchy
Comment 1 Nick Clemens 2019-02-08 20:26:56 UTC
Created attachment 84900 [details] [review]
WIP Add Invoice Adjustments to GetBudgetHierarchy

Seems to work but lots of debug code and test are incomplete. I think I
made assumptions about how GetBudgetHierarchy takes a budget_period_id
that are wrong
Comment 2 Nick Clemens 2019-03-12 13:27:36 UTC
Created attachment 86532 [details] [review]
Bug 22296: Add Invoice Adjustments to GetBudgetHierarchy

To test:
1 - prove -v t/db_dependent/Budgets.t
2 - Create some invoices on a single budget
    Invoice 1:
      add a non-encumbered adjustment for 1
      add an encumbered adjustment 2
      leave open
    Invoice 2:
      add a non-encumbered adjustment for 4
      add an encumbered adjustment for 8
3 - View acq home page, should see 2 order and 12 spent for the budget
4 - View the spent and ordered pages, they should show the correct amounts
5 - Add more orders etc and confirm things total correctly
Comment 3 Janet McGowan 2019-03-12 16:46:44 UTC
Hi Nick, 
Testing on our sandbox I'm seeing a problem in that after adding the initial adjustment, every time you subsequently click Update Adjustments it changes the Fund that you want to debit or credit back to No Fund. 
This means I can't really test properly as I can't add a 2nd adjustment line without it changing the Fund to No Fund!
Do you need any more info?
many thanks
Janet
Comment 4 Nick Clemens 2019-03-12 17:03:46 UTC
(In reply to Janet McGowan from comment #3)
> Hi Nick, 
> Testing on our sandbox I'm seeing a problem in that after adding the initial
> adjustment, every time you subsequently click Update Adjustments it changes
> the Fund that you want to debit or credit back to No Fund. 
> This means I can't really test properly as I can't add a 2nd adjustment line
> without it changing the Fund to No Fund!
> Do you need any more info?
> many thanks
> Janet

Looks like I missed updating one variable on the dependent bug 22498 - new patch attached there
Comment 5 Janet McGowan 2019-03-13 10:53:35 UTC
On our sandbox I've tested 22498 and 22296 together following the test plan for 22296 and all work together successfully.
N.B As well as positive amounts I've also tested using minus sign on amounts to apply credits to a fund and this also works.
Comment 6 Martin Renvoize 2019-03-13 11:23:51 UTC
Created attachment 86568 [details] [review]
Bug 22296: Add Invoice Adjustments to GetBudgetHierarchy

To test:
1 - prove -v t/db_dependent/Budgets.t
2 - Create some invoices on a single budget
    Invoice 1:
      add a non-encumbered adjustment for 1
      add an encumbered adjustment 2
      leave open
    Invoice 2:
      add a non-encumbered adjustment for 4
      add an encumbered adjustment for 8
3 - View acq home page, should see 2 order and 12 spent for the budget
4 - View the spent and ordered pages, they should show the correct amounts
5 - Add more orders etc and confirm things total correctly

https://bugs.koha-community.org/show_bug.cgi?id=22296
Signed-off-by: Janet McGowan <janet.mcgowan@ptfs-europe.com>
Comment 7 Martin Renvoize 2019-03-13 11:25:05 UTC
Just doing the honours of uploading Janets signed patch for her.. sandboxes don't like signing of dependants.
Comment 8 Josef Moravec 2019-03-14 10:34:27 UTC
Created attachment 86596 [details] [review]
Bug 22296: Add Invoice Adjustments to GetBudgetHierarchy

To test:
1 - prove -v t/db_dependent/Budgets.t
2 - Create some invoices on a single budget
    Invoice 1:
      add a non-encumbered adjustment for 1
      add an encumbered adjustment 2
      leave open
    Invoice 2:
      add a non-encumbered adjustment for 4
      add an encumbered adjustment for 8
3 - View acq home page, should see 2 order and 12 spent for the budget
4 - View the spent and ordered pages, they should show the correct amounts
5 - Add more orders etc and confirm things total correctly

https://bugs.koha-community.org/show_bug.cgi?id=22296
Signed-off-by: Janet McGowan <janet.mcgowan@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 9 Nick Clemens 2019-03-15 12:48:46 UTC
Awesome work all!

Pushed to master for 19.05
Comment 10 Lucas Gass 2019-03-19 22:57:01 UTC
missing dependency, won't back port to 18.05.x series
Comment 11 Martin Renvoize 2019-03-21 13:46:35 UTC
Pushed to 18.11.x for 18.11.04.. seems I forgot to update bugzilla at the time.