Commit Graph

597 Commits

Author SHA1 Message Date
PhilRunninger
b10a3ac655 Add a function to treat 1x1 ranges as an array, not a scalar value.
The Range.Value function does not consistently return a 2-D array. If
the range is a single cell, it returns just the value in that cell. When
initializing a Userform listbox, it needs to be an array, so this
function was born.
2024-03-15 10:09:56 -04:00
PhilRunninger
a821f15c32 Update DSM, Tags, Basis, and Baseline lists.
I got DSM list from ubm.rlarp.osm_pool, not CMSInterfaceIn.lgdat.CODE.
Made the list of Tags contain just "Volume".
Added "baseline" to the Basis and Baseline lists.
2024-03-15 10:06:57 -04:00
PhilRunninger
f70a733624 Not exactly sure what changes were made here. Bringing repo up to date.
VBA changes will be easier to track after the recent addition to the
repo of the exported code.
2024-03-13 09:04:25 -04:00
PhilRunninger
aabbf8210b Make SQL changes to advance to the next season. 2024-03-13 09:03:16 -04:00
PhilRunninger
337f5425e2 Save the exported VBA code in the repo. This is its initial commit. 2024-03-13 08:55:39 -04:00
PhilRunninger
f8f1433546 Make debugging statements in SQL files more informative.
I added the CTE's name as the new first column of the
`SELECT * FROM <cte>` statement.
2024-03-13 08:50:50 -04:00
PhilRunninger
cc7726758b Show more of the response in the journal. 2024-03-13 08:45:21 -04:00
PhilRunninger
e87c0ecc62 Remove incorrect calculation percent change factor for value.
This was causing a double dipping of value changes. Along with this
change was a manual purge of the changes that mistakenly were made.
Luckily they were easy to find:
    l.doc->>'type' = 'scale_vp'
    iter = 'adj price'
2023-09-12 20:54:24 -04:00
PhilRunninger
3fa2cb07f5 Batch error messages and identify period to which they apply.
This happens on the Monthly view, and it's possible to get multiple
error messages, even among other successful month adjustments. There was
no way of knowing which month was the offending one or if any had
succeeded when an error was shown.

This change collects all the error messages into one message with the
period so that it's more intuitive and less obtrusive.
2023-08-31 17:07:58 -04:00
PhilRunninger
7bd8cc2674 If no history, hide form before showing message. 2023-08-31 17:07:17 -04:00
PhilRunninger
395da4671b Add 'plan' to the list of iterations we can base new business on. 2023-08-31 09:56:37 -04:00
PhilRunninger
f5a79f16b6 Fix divide by zero errors when no adjustment can be made. 2023-08-31 09:51:30 -04:00
PhilRunninger
80c8b5b159 Fix typo left in from debugging a query. This was a big oops! 2023-08-31 09:50:34 -04:00
PhilRunninger
8ab2e26937 Not sure what these changes were for. They happened too long ago. 2023-08-31 09:49:43 -04:00
PhilRunninger
1d5234a8b7 Omit from the list, the one adjustment that can't be undone. 2023-08-30 10:32:57 -04:00
PhilRunninger
123da3ea11 Fix r_currency and c_currency. They were swapped. :( 2023-08-29 20:30:36 -04:00
PhilRunninger
f0ec96fe2a Change WHERE clause to remove tag[= or <>]'open-orders' condition.
Now that we think we know what we're doing, I'm using a more rigorous
approach to defining iterations and tags, and this condition is no
longer necessary, and in fact, may be harmful. This I'm removing it.

The initial load of data will have these values.

iter    | tag         | purpose
--------|-------------|-------------------------------------------------
plan    | baseline    | Adjustments will be made to these values only.
actuals | open-orders | Ordered before 2024 season, still open.
actuals | booked      | Ordered in 2024 season so far
2023-08-29 20:02:46 -04:00
PhilRunninger
5e83df9e5c Change timestamps to local time zone. 2023-08-29 14:01:53 -04:00
PhilRunninger
42e5e939e9 Add some highlighting to the output for increased visibility. 2023-08-29 13:45:18 -04:00
PhilRunninger
853196bd65 Assuage my obsession for less lines of code. 2023-08-29 11:59:19 -04:00
PhilRunninger
b171b4d7ac More refactoring. Code is much DRY-er.
I removed a bunch of duplication by:
1. Moving `if (!where)` logic into the build_where function - sending
   the "No body was sent." message back in the HTTP response object.
2. Putting all file read operations into a dedicated function -
   process_route. This takes a callback function that handles the
   remaining logic of each route after successfully reading the SQL
   file.
2023-08-29 11:52:55 -04:00
PhilRunninger
d5738cc7af Refactor, and add additional logging statements. 2023-08-28 22:01:24 -04:00
PhilRunninger
e726349c98 Simplify code. Add backdoor to openf form. Fix integer overflow in undo. 2023-05-17 15:09:08 -04:00
PhilRunninger
0d83f19e33 Fix percent change calculation for price adjustment.
I shouldn't be coding on zero hours sleep!
2023-05-17 10:04:46 -04:00
PhilRunninger
47d1baffc5 Handle the case where baseline is zero (units or value).
This happens when a customer places identical orders and specifies that
they be shipped in different seasons. We end up with one order shipped
in 2023 and one open for 2024. Under our current operating procedures,
open orders are subtracted from shipped orders and are presented as
baseline for the next forecast. The zero that appears in the baseline in
this case was causing all kinds of issues in the SQL scripts for
inserting the adjustments, ranging from finding zero rows to adjust to
division by zero.

Another change required to correct this was updating the iter value of
the open orders from 'actuals' to 'copy':

    UPDATE rlarp.osm_pool
    SET iter = 'copy'
    WHERE tag = 'open-orders'
2023-05-17 05:28:21 -04:00
PhilRunninger
7e82b37fb1 Merge branch 'master' of github.com:The-HC-Companies/forecast_api 2023-05-09 01:26:10 -04:00
PhilRunninger
eb03d61600 Add options to query by director or segment. Also speed it up A LOT. 2023-05-09 01:24:08 -04:00
f47571c1e2 Extend minimum order_date back one additional year in the past. 2023-05-08 10:05:55 -04:00
PhilRunninger
cecd647ee7 Prevent accidental undo of initial baseline load. 2023-05-03 15:34:17 -04:00
PhilRunninger
9e1299e49c Minor tweaks to the spreadsheet, version 17.0 in Teams. No VBA changes. 2023-05-03 15:33:52 -04:00
PhilRunninger
5fe17549ab Fix bug caused by my putting headers where they shouldn't be. 2023-05-01 21:03:32 -04:00
PhilRunninger
da28aa485f Keep Data sheet visible. This coincides with version 13.0 in Teams. 2023-05-01 13:49:13 -04:00
PhilRunninger
4504cbaa2a Improve log messages in the server console log.
* More informative.
* Better timing in the code, so always displayed.
* Used string interpolation instead of concatenation for readability.
2023-04-28 10:27:27 -04:00
PhilRunninger
86225ea7e5 Get pounds to update for each forecast adjustment.
Lots of cleanup here too, removing large swaths of code that are no
longer needed. Many improvements the Excel workbook, which is kept in
Teams, not git. These changes may or may not have had accompanying VBA
changes.
2023-04-27 16:54:37 -04:00
PhilRunninger
fde6c97964 Too many changes, too few commits.
A lot has changed here, including:
1. Adding pounds to the data available for display in pivot table.
2. Visual improvements
3. Code simplification
4. Hiding / showing sheets as needed. A developer's backdoor allows for
   easy toggling for debugging purposes: Ctrl+RightClick on the Forecast
   Adjustment form's "Selected Scenario" label.
5. Fixed a bug that happened when deleting rows from the basket. The
   definition of the Target variable was lost in some cases.
6. Made use of the Cancel and Default form properties to purge some
   unnecessary code.
7. Added a sheet that contains Help text for the users.
8. Replacing more harcoded range reference with range names.
9. Refactor checks for division by zero errors, and improve error
   messages for users.
10. Remove manual formatting. It's already done and saved in the
    workbook; there's no need to redo it in code.
11. Added more data validation before Save operation proceeds.
12. Added a new IntersectsWith function to simplify If statements.
2023-04-24 21:46:13 -04:00
PhilRunninger
81174b5d57 UI and UX Changes
1. Remove/Hide Swap Part
2. Remove/Hide Swap Customer
3. Improved the location of controls on fpvt form.
4. Make user experience more intuitive on the Month sheet
5. Make more and better use of named ranges in place of hardcoded cell
   locations.
6. Added error checking to ensure Tag is entered and at least one month
   has a forecast on Month sheet.
2023-04-05 17:51:50 -04:00
12c17b0be6 adjust rep source to rlarp.repc, adjust join logic to match current osm definition 2023-04-05 13:02:53 -04:00
PhilRunninger
480adef789 Update some 2022 references to 2024, and fix round() function calls. 2023-04-05 12:37:35 -04:00
PhilRunninger
bbac2ec390 Remove the code from the Walk sheet. Actually, just comment it out. 2023-03-22 12:05:36 -04:00
PhilRunninger
85829efd1d Clean up the VBA. This coincides with version 10.0 in Teams.
WARNING!  Do not assume the Excel file in this repo matches the VBA in
the repo. The decision was made to use Teams for managing changes to the
Excel tamplate because Git is ill-suited for binary files. The Excel
file will be updated from time to time, but only when something major
happens with the application as a whole.

1. Use the sheets' codenames to refer to them in code. This prevents
   breakage if the user changes the sheet name while working with the
   workbook.
2. Give the pivot tables proper, if not descriptive, names.
3. Simplify the code that detects a double-click in the pivot table.
4. Remove Windows_API as it was not being used.
5. Pare down TheBigOne to just the essential functions in Utils.
6. Refer to the data sources for the userforms' listboxes by using the
   worksheet.ListObjects collection.
2023-03-09 10:32:58 -05:00
ef8a21d319 update rebuild script 2023-03-08 08:48:02 -05:00
cc656d7c24 increment dates 2023-03-07 17:32:45 -05:00
5e7ad3b208 swap everything for a 2109 baseline 2023-03-07 16:45:55 -05:00
15da8aecd4 reports 2023-03-07 16:07:55 -05:00
6f88ed618d include all foreast since the piece labeled actuals actually forms a current year forecast 2023-03-07 15:44:25 -05:00
d79feebaa5 dont load anything to staged forecast that has "actuals" in it 2023-03-07 15:27:33 -05:00
0ae9f604c1 change version to b23 2023-03-07 12:39:30 -05:00
a0c5482f6c update convert pool to target osmfs in its current state 2023-03-07 11:44:22 -05:00
ef0c9175cd increment years and target iterations 2023-03-06 09:38:57 -05:00
304aeababa include Phils new modules 2023-03-03 17:07:28 -05:00