InvenTree/InvenTree/order/migrations
Oliver 06266b48af
Part pricing cache (#3710)
* Create new model for storing Part pricing data

Currently this model does not "do" anything but will be used for caching pre-calculated pricing information

* Define function for accessing pricing information for a specific part

* Adds admin site support for new PartPricing model

* Specify role for PartPricing model

* Allow blank values for PartPricing model fields

* Add some TODO entries

* Update migration files to sync with latest master

* Expose API endpoint for viewing part pricing information

* Update migration file

* Improvements:

- Updated model with new fields
- Code for calculating BOM price
- Code for calculating internal price
- Code for calculating supplier price
- Updated unit testing

* Fix (and test) for API serializer

* Including min/max pricing data in part serializer

* Bump API version

* Add pricing overview information in part table

- Adds helper function for formatting currency data
- No longer pre-render "price strings" on the server

* Overhaul of BOM API

- Pricing data no longer calculated "on the fly"
- Remove expensive annotation operations
- Display cached price range information in BOM table

* Filter BOM items by "has pricing"

* Part API endpoint can be filtered by price range

* Updpated API version notes

* Improvements for price caching calculations

- Handle null price values
- Handle case where conversion rates are missing
- Allow manual update via API

* Button to manually refresh pricing

* Improve rendering of price-break table

* Update supplier part pricing table

* Updated js functions

* Adds background task to update assembly pricing whenever a part price cache is changed

* Updates for task offloading

* HTML tweaks

* Implement calculation of historical purchase cost

- take supplier part pack size into account
- improve unit tests

* Improvements for pricing tab rendering

* Refactor of pricing page

- Move javascript functions out into separate files
- Change price-break tables to use bar graphs
- Display part pricing history table and chart
- Remove server-side rendering for price history data
- Fix rendering of supplier pricing table
- Adds extra filtering options to the SupplierPriceBreak API endpoint

* Refactor BOM pricing chart / table

- Display as bar chart with min/max pricing
- Display simplified BOM table

* Update page anchors

* Improvements for BOM pricing table display

* Refactoring sales data tables

- Add extra data and filter options to sales order API endpoints
- Display sales order history table and chart

* Add extra fields to PartPricing model:

- sale_price_min
- sale_price_max
- sale_history_min
- sale_history_max

* Calculate and cache sale price data

* Update part pricing when PurchaseOrder is completed

* Update part pricing when sales order is completed

* Signals for updating part pricing cache

- Whenever an internal price break is created / edited / deleted
- Whenever a sale price break is created / edited / deleted

* Also trigger part pricing update when BomItem is created  / edited / deleted

* Update part pricing whenever a supplier price break is updated

* Remove has_complete_bom_pricing method

* Export min/max pricing data in BOM file

* Fix pricing data in BOM export

- Calculate total line cost
- Use more than two digits

* Add pricing information to part export

Also some improvements to part exporting

* Allow download of part category table

* Allow export of stock location data to file

* Improved exporting of StockItem data

* Add cached variant pricing data

- New fields in part pricing model
- Display variant pricing overview in "pricing" tab

* Remove outdated "PART_SHOW_PRICE_HISTORY" setting

* Adds scheduled background task to periodically update part pricing

* Internal prices can optionally override other pricing

* Update js file checks

* Update price breaks to use 6 decimal places

* Fix for InvenTreeMoneySerializer class

- Allow 6 decimal places through the API

* Update for supplier price break table

* javascript linting fix

* Further js fixes

* Unit test updates

* Improve rendering of currency in templates

- Do not artificially limit to 2 decimal places

* Unit test fixes

* Add pricing information to part "details" tab

* Tweak for money formatting

* Enable sort-by-price in BOM table

* More unit test tweaks

* Update BOM exporting

* Fixes for background worker process

- To determine if worker is running, look for *any* successful task, not just heartbeat
- Heartbeat rate increased to 5 minute intervals
- Small adjustments to django_q settings

Ref: https://github.com/inventree/InvenTree/issues/3921
(cherry picked from commit cb26003b92)

* Force background processing of heartbeat task when server is started

- Removes the ~5 minute window in which the server "thinks" that the worker is not actually running

* Adjust strategy for preventing recursion

- Rather than looking for duplicate parts, simply increment a counter
- Add a "scheduled_for_update" flag to prevent multiple updates being scheduled
- Consolidate migration files

* Adds helper function for rendering a range of prices

* Include variant cost in calculations

* Fixes for "has_pricing" API filters

* Ensure part pricing status flags are reset when the server restarts

* Bug fix for BOM API filter

* Include BOM quantity in BOM pricing chart

* Small tweaks to pricing tab

* Prevent caching when looking up settings in background worker

- Caching across mnultiple processes causes issues
- Need to move to something like redis to solve this
- Ref: https://github.com/inventree/InvenTree/issues/3921

* Fixes for /part/pricing/ detail API endpoint

* Update pricing tab

- Consistent naming

* Unit test fixes

* Prevent pricing updates when loading test fixtures

* Fix for Part.pricing

* Updates for "check_missing_pricing"

* Change to pie chart for BOM pricing

* Unit test fix

* Updates

- Sort BOM pie chart correctly
- Simplify PartPricing.is_valid
- Pass "limit" through to check_missing_pricing
- Improved logic for update scheduling

* Add option for changing how many decimals to use when displaying pricing data

* remove old unused setting

* Consolidate settings tabs for pricing and currencies

* Fix CI after changing settings page

* Fix rendering for "Supplier Pricing"

- Take unit pricing / pack size into account

* Extra filtering / ordering options for the SupplierPriceBreak API endpoint

* Fix for purchase price history graph

- Use unit pricing (take pack size into account)

* JS fixes
2022-11-14 15:58:22 +11:00
..
0001_initial.py Create initial models for 'Order' 2019-06-04 22:19:04 +10:00
0002_auto_20190604_2224.py Allow blank PO description and add URL field 2019-06-04 22:26:19 +10:00
0003_auto_20190604_2226.py Fix related name 2019-06-04 22:26:40 +10:00
0004_purchaseorder_status.py Add order status field 2019-06-04 23:09:51 +10:00
0005_purchaseorderlineitem_part.py Updates for purchase order line items 2019-06-05 20:59:30 +10:00
0006_auto_20190605_2056.py Updates for purchase order line items 2019-06-05 20:59:30 +10:00
0007_auto_20190605_2138.py List purchase orders for a given part 2019-06-05 21:47:22 +10:00
0008_auto_20190605_2140.py List purchase orders for a given part 2019-06-05 21:47:22 +10:00
0009_auto_20190606_2133.py Form / view for creating a new purchase order 2019-06-06 21:39:04 +10:00
0010_purchaseorderlineitem_notes.py Add notes field to purchase order line item 2019-06-13 21:57:35 +10:00
0011_auto_20190615_1928.py Implement POST for receiving items 2019-06-15 19:39:57 +10:00
0012_auto_20190617_1943.py Improve the 'creation date' for order 2019-06-17 19:44:36 +10:00
0013_auto_20191118_2323.py Convert some more fields to decimal 2019-11-19 10:30:04 +11:00
0014_auto_20191118_2328.py Convert some more fields to decimal 2019-11-19 10:30:04 +11:00
0015_auto_20200201_2346.py Remove reliance on django-markdownx (#3231) 2022-06-20 22:20:04 +10:00
0016_purchaseorderattachment.py Add PurchaseOrderAttachment model 2020-03-22 18:02:53 +11:00
0017_auto_20200331_1000.py Change POLineItem quantity to a rounding decimal field 2020-03-31 21:23:57 +11:00
0018_auto_20200406_0151.py Rename Order.URL to Order.link 2020-04-06 11:56:52 +10:00
0019_purchaseorder_supplier_reference.py Add "supplier_reference" field to PurchaseOrder 2020-04-15 13:32:14 +10:00
0020_auto_20200420_0940.py Remove reliance on django-markdownx (#3231) 2022-06-20 22:20:04 +10:00
0021_auto_20200420_1010.py API endpoint for serializing SalesOrder objects 2020-04-20 20:11:21 +10:00
0022_salesorderlineitem_part.py Add "part" reference to SalesOrderLineItem model 2020-04-21 08:33:32 +10:00
0023_auto_20200420_2309.py Add a 'sales order' view for each part 2020-04-21 09:15:01 +10:00
0024_salesorderallocation.py Create "SalesOrderAllocation" object 2020-04-22 12:12:48 +10:00
0025_auto_20200422_0222.py Update definition for StockItemAllocation model 2020-04-22 13:11:19 +10:00
0026_auto_20200422_0224.py Update definition for StockItemAllocation model 2020-04-22 13:11:19 +10:00
0027_auto_20200422_0236.py Update definition for StockItemAllocation model 2020-04-22 13:11:19 +10:00
0028_auto_20200423_0956.py Separate concept of "OrderStatus" into "SalesOrderStatus" and "PurchaseOrderStatus" 2020-04-23 20:38:09 +10:00
0029_auto_20200423_1042.py Order date adjustment 2020-04-23 20:42:59 +10:00
0030_auto_20200426_0551.py More work 2020-04-26 16:38:29 +10:00
0031_auto_20200426_0612.py More work 2020-04-26 16:38:29 +10:00
0032_auto_20200427_0044.py Add some unit testing for the SalesOrder model 2020-04-27 11:32:20 +10:00
0033_auto_20200512_1033.py Add 'user' field to attachment 2020-05-12 20:50:03 +10:00
0034_auto_20200512_1054.py Add "upload date" field to fileattachment base class 2020-05-12 20:57:41 +10:00
0035_auto_20200513_0016.py Drag and drop for order attachments 2020-05-13 11:28:45 +10:00
0036_auto_20200831_0912.py Order: Improve help text(s) 2020-08-31 19:13:24 +10:00
0037_auto_20201110_0911.py Remove defunct 'build_order' field from StockItem model 2020-11-10 20:12:39 +11:00
0038_auto_20201112_1737.py Add "purchase price" field to PurchaseOrderLineItem table 2020-11-12 18:05:24 +11:00
0039_auto_20201112_2203.py Add missing migration file 2020-11-12 22:04:50 +11:00
0040_salesorder_target_date.py Add 'target_date' field to SalesOrder model 2020-12-18 12:19:16 +11:00
0041_auto_20210114_1728.py Add "target_date" field to PurchaseOrder 2021-01-14 17:28:57 +11:00
0042_auto_20210310_1619.py Add "responsible" field to PO and SO models 2021-03-10 16:19:44 +11:00
0043_auto_20210330_0013.py Remove "unique" constraint for part / order relationship 2021-03-30 00:14:47 +11:00
0044_auto_20210404_2016.py Remove reliance on django-markdownx (#3231) 2022-06-20 22:20:04 +10:00
0045_auto_20210504_1946.py Add in sale price model 2021-05-04 21:56:25 +02:00
0046_purchaseorderlineitem_destination.py feat(purchase orders): show the preferred location for each PO Line 2021-06-09 09:06:03 -06:00
0047_auto_20210701_0509.py added clean migration steps for all price fields 2021-07-01 07:11:15 +02:00
0048_auto_20210702_2321.py Reference fields (#3267) 2022-07-11 00:01:46 +10:00
0049_alter_purchaseorderlineitem_unique_together.py Improved creation of purchase order line items from file upload 2021-08-12 14:27:00 -04:00
0050_alter_purchaseorderlineitem_destination.py Add migration file 2021-09-02 11:11:25 +10:00
0051_auto_20211014_0623.py Add a 'reference_int' field to the models, to be used as a secondary index 2021-10-14 17:45:43 +11:00
0052_auto_20211014_0631.py Int migration fix (#3323) 2022-07-15 11:57:27 +10:00
0053_auto_20211128_0151.py adds a "link" field to the InvenTree attachment model 2021-11-28 12:53:01 +11:00
0053_salesordershipment.py Remove reliance on django-markdownx (#3231) 2022-06-20 22:20:04 +10:00
0054_auto_20211201_2139.py use BigIntegerField for a hugher range ;-) 2021-12-01 22:39:53 +01:00
0054_salesorderallocation_shipment.py Add 'shipment' foreign-key field to SalesOrderAllocation model 2021-10-25 17:42:56 +11:00
0055_auto_20211025_0645.py fix trailing 2022-05-20 13:20:55 +02:00
0056_alter_salesorderallocation_shipment.py Add list and detail API endpoints for SalesOrderShipment 2021-10-25 23:34:58 +11:00
0057_salesorderlineitem_shipped.py Adds "shipped" field to SalesOrderLineItem 2021-11-26 23:20:27 +11:00
0058_auto_20211126_1210.py upgrade to pyhton 3.9 syntax 2022-05-01 21:53:12 +02:00
0059_salesordershipment_tracking_number.py Merge branch 'master' into partial-shipment 2021-11-29 22:59:36 +11:00
0060_auto_20211129_1339.py Allow shipment numbers to be non-unique for different sales orders 2021-11-30 00:42:30 +11:00
0061_merge_0054_auto_20211201_2139_0060_auto_20211129_1339.py Merge conflicting migrations 2021-12-03 00:43:10 +11:00
0062_auto_20220228_0321.py Adds "target_date" field to PurchaseOrderLineItem and SalesOrderLineItem models 2022-02-28 14:26:01 +11:00
0063_alter_purchaseorderlineitem_unique_together.py Remove unique_together requirement for purchaseorderlineitem 2022-02-28 15:27:56 +11:00
0064_purchaseorderextraline_salesorderextraline.py ignore coverage on reverse conversion 2022-05-03 20:11:41 +02:00
0065_alter_purchaseorderlineitem_part.py add missing migrations 2022-03-29 00:03:19 +02:00
0066_alter_purchaseorder_supplier.py move migrations 2022-05-02 22:10:50 +02:00
0067_auto_20220516_1120.py Adds metadata fields to PurchaseOrder and SalesOrder models 2022-05-16 21:21:32 +10:00
0068_alter_salesorderallocation_unique_together.py Remove unique_together requirement on SalesOrderAllocation model 2022-05-17 00:36:30 +10:00
0069_auto_20220524_0508.py SalesOrderShipment improvements (#3058) 2022-05-25 11:00:19 +10:00
0070_auto_20220620_0728.py Remove reliance on django-markdownx (#3231) 2022-06-20 22:20:04 +10:00
0071_auto_20220628_0133.py Virtual part fix (#3265) 2022-06-28 13:39:27 +10:00
0072_alter_salesorder_reference.py Reference fields (#3267) 2022-07-11 00:01:46 +10:00
0073_alter_purchaseorder_reference.py Reference fields (#3267) 2022-07-11 00:01:46 +10:00
0074_auto_20220709_0108.py Reference fields (#3267) 2022-07-11 00:01:46 +10:00
0075_auto_20221110_0108.py Remove client-side length validation in form inputs (#3911) 2022-11-10 12:51:15 +11:00
0076_auto_20221111_0153.py Part pricing cache (#3710) 2022-11-14 15:58:22 +11:00
__init__.py Create initial models for 'Order' 2019-06-04 22:19:04 +10:00