Commit Graph

218 Commits

Author SHA1 Message Date
39ed186bca commit: 2025-04-08 09:36:56 2025-04-08 09:36:56 -04:00
e859162b16 commit: 2025-04-08 09:20:32 2025-04-08 09:20:32 -04:00
1a2659d86a commit: 2025-04-08 09:19:33 2025-04-08 09:19:33 -04:00
685f75ffe8 commit: 2025-04-06 03:10:30 2025-04-06 03:10:30 -04:00
e54b42bc83 work on mix change route 2025-04-06 01:45:44 -04:00
ce2fe219f4 commit: 2025-04-05 22:46:04 2025-04-05 22:46:04 -04:00
fb749ffde5 commit: 2025-04-05 21:06:09 2025-04-05 21:06:09 -04:00
db3dc8bc73 increment sql 2025-04-04 13:43:47 -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
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
241994cb56 Use a pre-authorized, fixed exchange rate of 0.7409 for forecasting. 2024-03-18 21:23:07 -04:00
PhilRunninger
aabbf8210b Make SQL changes to advance to the next season. 2024-03-13 09:03:16 -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
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
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
1d5234a8b7 Omit from the list, the one adjustment that can't be undone. 2023-08-30 10:32:57 -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
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
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
eb03d61600 Add options to query by director or segment. Also speed it up A LOT. 2023-05-09 01:24:08 -04:00
PhilRunninger
cecd647ee7 Prevent accidental undo of initial baseline load. 2023-05-03 15:34:17 -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
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
cc656d7c24 increment dates 2023-03-07 17:32:45 -05:00
PhilRunninger
bd8aa18208 Merge branch 'dev' of github.com:The-HC-Companies/forecast_api into dev 2023-03-01 18:00:18 -05:00
PhilRunninger
ed5975daf7 Switch source table from rlarp.itemmv to "CMS.CUSLG".itemm 2023-03-01 17:55:30 -05:00
5dc5a11489 increment year 2023-03-01 17:07:44 -05:00
PhilRunninger
5b507d3d65 Updates to the newest season in scenario_package.sql 2023-02-27 16:15:35 -05:00
ed1cd2b074 change iterations in monthly adjustments 2021-07-30 12:13:34 +00:00
28c14ece67 include plan and diff ase baseline iterations 2021-07-16 09:40:34 -04:00
f548780d9f sort result sets by id 2021-06-02 15:50:21 +00:00
66b74e31cb update all routes to round to 2 decimals for units, value, and cost 2021-04-19 09:20:52 -04:00
e3722193c5 populate dsm when swapping customers, rework pool quate rep snap 2021-04-16 13:57:32 -04:00
d541ee16cc re-assign channel based for customer swaps 2021-04-16 12:04:17 -04:00
60b57263d0 re-asign quata rep and director for customer swaps 2021-04-16 12:04:00 -04:00
d13519c07c trim part number coming from CMS listing in spreadsheet with whitespace at end 2021-04-14 15:26:36 +00:00
fee1b9202f trim white space off part numbers 2021-04-13 16:15:11 -04:00
ab7af8d2ed redefine segment 2021-04-13 16:10:04 -04:00
50da4dfa17 prevent last price iteration from being available to delete, and rebuild price iteration to only look at baseline activity 2021-04-12 15:10:45 -04:00
a328aaeaaf running the SQL was commented out in the router, also the columns were incorrect when swapping customer, and outer join was spelled wrong 2021-04-07 21:23:19 +00:00
f7f26b2804 finish work on customer swap, start testing this 2021-04-07 20:23:12 +00:00
28ee5dfbb4 update history pull to match dev branch 2021-04-07 12:55:35 -04:00
e4604a16f5 merge dev branch 2021-04-07 10:17:12 -04:00
551a4867d6 increment route fiscal years 2021-04-05 19:22:20 +00:00
e4054326d0 increment scenario selector 2021-04-05 12:36:51 -04:00