sul-dlss / FOLIO-Project-Stanford

Task management for Stanford’s analysis of FOLIO.
2 stars 0 forks source link

Run fix encumbrance script #640

Closed ahafele closed 1 month ago

ahafele commented 4 months ago

SUL would like to run a community provided script ahead of rollover - and likely on a regular schedule after.

https://folio-org.atlassian.net/wiki/spaces/FOLIJET/pages/1396182/Fix+encumbrances+especially+after+a+Lotus+rollover

Include Law also.

shelleydoljack commented 4 months ago

Ran for SUL and Lane in normal mode for folio-stage. Ran from sul-libsys-deploy server. The script requires prompting, so not sure we can run it from an airflow DAG.

ahafele commented 2 months ago

Acq would like to have this run as soon as possible on production and 1x a week till rollover. Darsi suggests waiting till Shelley returns from vacation.

ahafele commented 2 months ago

Alert Suzette before running so she can export ledger details before (and then after)

ahafele commented 2 months ago

Update: After rollover test on stage Suzette noticed some problems with encumbrance transactions being linked to the incorrect fiscal year and creating duplicates when editing open orders. Per Dennis' suggestion here, we'd like to rerun the encumbrance script on stage to see if it fixes some of the issues. Did we run it with all options the first time? After running, SUL would like to do another rollover test with settings that will roll one-time orders. See comments on testing from Suzette below.

in open pols, it is referencing the fy24 encumbrance id instead of fy25. we also tried editing a law order now that we know about the expense class, and it did create 2 encumbrances. so now we know it has nothing to do with law's rollover settings. but we took a look at the law order that you edited that only had the fy25 encumbrance correctly, and it did look like it was updated by the encumbrance script correctly. so it seems like the encumbrance script didnt run correctly for sul and lane, and only ran correctly for some orders for law? it's very strange. regardless, we would want to try running the script again to see if it fixes the encumbrance ids. if it fixes it, great. but if it doesn't then worse case is to update all the open pols with the fy25 encumbrance ids as for running rollover again, we'd like to try rolling over one-time encumbrances. i know that i said what happened above is not affected by whether you roll over encumbrances or not, but we would still like to test this because 1) we may want to do this actually after all to get a better sense of the budget commitments and 2) we are curious how long it would actually take if we do

shelleydoljack commented 2 months ago

I ran "run all fixes" last time I did this. I'll do that again (run all fixes") on stage. But which fiscal year should it run against? both? The script instructions say "Fiscal year code (use the current fiscal year when fixing issues with the fiscal year rollover)" so I guess that means FY25?

ahafele commented 2 months ago

Yes I would say FY25 cc @scanedastanford

shelleydoljack commented 2 months ago

Started the fix encumbrances script for SUL2025 all fixes in stage.

shelleydoljack commented 2 months ago

Done:

1) Dry-run mode (read-only, will not apply fixes)
2) Normal mode (will apply fixes)
Choose an option: Normal mode. All fixes *will* be applied.

1) Run all fixes (can be long)
2) Remove duplicate encumbrances
3) Fix order line - encumbrance relations
4) Fix encumbrance order status for closed orders
5) Unrelease open order encumbrances with nonzero amounts
6) Release open order encumbrances with negative amounts
7) Release cancelled order line encumbrances
8) Recalculate all budget encumbered amounts (avoid any transaction while this is running!)
9) Release unreleased encumbrances for closed orders
10) Quit
Choose an option: Logged in successfully.
Retrieving closed order ids...
  Closed orders: 22963
Retrieving open order ids...
  Open orders: 67024
Removing duplicate encumbrances...
    e14ceff8-b1f4-59b1-bb95-3e40cd44bb2c
    8e5d2319-81a2-5ac9-8ec7-e0fa1849bda7
    f6d9fa02-98ab-5be3-aaa8-7aa65c43bf7b
  Removed 3 encumbrance(s).
Fixing poline-encumbrance links...
Fixing encumbrance order status for closed orders...
  Fixed order status for 0 encumbrance(s).
Unreleasing open orders encumbrances with non-zero amounts...
  Unreleased 0 open order encumbrance(s) with non-zero amounts.
Releasing open orders encumbrances with negative amounts...
  Released 0 open order encumbrance(s) with negative amounts.
Releasing cancelled order line encumbrances...
  Released 0 cancelled order line encumbrance(s).
Recalculating budget encumbered for 89987 orders ...
  Updating budgets...
    Budget "SPAPOR-SUL-SUL2025": changing encumbered from -20.59 to 10.0
    Budget "EDUC-SUL-SUL2025": changing encumbered from 103.21 to 62.0
    Budget "AFRICA-SUL-SUL2025": changing encumbered from 523.23 to 0.0
  Edited 3 budget(s).
  Done recalculating budget encumbered.
Releasing unreleased encumbrances for closed orders...
  Released 0 encumbrance(s).
Elapsed time: 0 hour(s), 31 minute(s) and 10 second(s).
ahafele commented 2 months ago

@shelleydoljack could you try running it for fy24. Suzette reports that the orders are still linked to the previous fy transactions.

shelleydoljack commented 2 months ago

Ok, I kicked it off for SUL2024. Should be about 30 minutes I guess.

ahafele commented 2 months ago

Thanks, Suzette will take a look. Further, if vague, response from Dennis here - https://folio-project.slack.com/archives/C217N937A/p1721683968756139?thread_ts=1721345183.942149&cid=C217N937A

ahafele commented 2 months ago

Per Rollover meeting - Please remove condition ("float(enc['amount']) != 0.0" from line 416) and run that version of the script both before and after rollover on the current fiscal year, e.g. now 24 and then 25 Should be run for all libraries and weekly until rollover.

shelleydoljack commented 1 month ago

Closing this ticket since we have cronjobs running it Monday nights.