Commit Graph

615 Commits

Author SHA1 Message Date
d9e78e285f lowercase kg 2024-05-14 08:49:23 -04:00
PhilRunninger
025b3b8c12 Update the minimum version number. 2024-04-01 18:09:24 -04:00
PhilRunninger
5033b753ff Make the obsolescence message work in and older version of node. 2024-04-01 18:06:23 -04:00
PhilRunninger
44dd489377 Use streamlined code to get pivot table key fields.
This allows me to get rid of unnecessary (and duplicated) code.
2024-04-01 17:54:09 -04:00
PhilRunninger
5b1333b8c1 Add file location of current workbook to obselescence message.
This is to help the user know where a functioning workbook (the one
they're currently in) needs to be located to continue working.
2024-04-01 17:52:02 -04:00
PhilRunninger
2df666a44f Allow getting the list of changes for director or segment pools. 2024-04-01 17:48:45 -04:00
PhilRunninger
2c46764be2 Updating the binary files recently changed. 2024-04-01 12:24:43 -04:00
PhilRunninger
1505221961 Limit who can use the Shipments sheet. 2024-04-01 12:24:14 -04:00
PhilRunninger
1cf13e4f57 Fix rounding of percent change. 2024-04-01 12:22:50 -04:00
PhilRunninger
ae6b21b197 Simplify parsing the (different) JSON sent to shift_ship_date.sql. 2024-04-01 12:07:30 -04:00
PhilRunninger
9933e66c77 Add code to do ship_date shifting. Workbook changes not finished yet. 2024-04-01 03:14:44 -04:00
PhilRunninger
22c2375f44 Add a mechanism to self-upgrade the workbook.
It's not completely seamless, but it should work adequately well. The
workbook (aka client) inserts the workbook version into the http request
body. The server code compares that version number against its minimum
supported client version.

If the client is too old, an error message is sent back to the client.

When the client receives the "Obsolete" error message, it launches the
https://<server>:<port>/template URL in the default browser, which
enables the user to save the downloaded new workbook file.
2024-03-22 18:33:04 -04:00
PhilRunninger
2454393a1d DRY up the WinHttpRequest calls. One sub now does it all.
Instead of having multiple locations with the same code, the web
interface code now lives in its own module, and is called from multiple
locations.
2024-03-20 17:21:08 -04:00
PhilRunninger
c7789f868c Fix the pscale adjustment factor when adding month data.
Two things were wrong with this code:
1. The exchange rate conversion was backward. Since we work in USD, I
   removed the conversion and used value_usd instead.
2. The calculation of pscale.factor was incorrect. If the old value is
   1000, and we need to get to 1020, the record to be inserted must have
   a value of 20, thus the value for factor needs to be:
   (1020 - 1000) / 1000  =  (1020 / 1000) - 1  =  0.02
   0.02 * 1000  =  20, which is inserted in the new record.

   The subtraction was missing before, which of course caused WAY wrong
   numbers that should have been caught a long time ago. It was doing:
   1020 / 1000  =  1.02
   1.02 * 1000 = 1020 was inserted, doubling the intended adjustment.
2024-03-19 16:24:04 -04:00
PhilRunninger
aa13911c02 Make the VBA handle pivot fields in the filters section.
Tread the PivotTable filters the same as the row headers, making them
part of the WHERE clause in the SQL statement.
2024-03-19 16:21:18 -04:00
PhilRunninger
4c1584af3d Restore the BASIS and BASELINE lists, removing "baseline" from them.
There were too many other locations that needed to be found and changed,
that it was easier to just do:
    update osm_pool set iter='plan' to iter='baseline'
and be done with it. I also informed Jim to make the same change in his
baseline creation scripts.
2024-03-18 21:24:28 -04:00
PhilRunninger
241994cb56 Use a pre-authorized, fixed exchange rate of 0.7409 for forecasting. 2024-03-18 21:23:07 -04:00
PhilRunninger
b73403aef7 Preselect the tag on the Month View sheet if there's only one. 2024-03-15 13:17:09 -04:00
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