agritheory / beam

General Purpose 2D barcode scanning for ERPNext
https://agritheory.com/documentation/beam/
Other
23 stars 11 forks source link

Demand - Proof of Concept #106

Closed agritheory closed 3 weeks ago

agritheory commented 5 months ago

This feature aligns in part with cases 2 and 3 of this comment of #15. The ideas here need to be refined in order to better understand how it should be used, which is why I'm starting a pull request. As a feature, I think it is likely a prerequisite for performant mobile views, which is why I was developing it in the context of this app, but as a feature, it more strongly aligns with Inventory Tools. We may want to finish the work there and then import it here as a dependency.

The purpose of this feature is to be able to quickly determine if a Work Order or Delivery Note can be started, based on material availability in the required location(s).

I tried several iterations of trying to organize this data in Redis before ultimately giving up - Redis' capabilities for storing structured data is limited and the inability to search by value means that filtering is only possible with the construction a several hash maps, which serve as unsynchronized indexes to other hash maps containing serialized data. It just felt like the wrong tool.

Refactoring to sqllite meant that I could preserve the tabular nature of the data, add indexes and use an ultimately more familiar approach that is still essentially in-memory. Reads from sqllite are notoriously fast and the write operations should be trivial. We may have to implement a write lock or ACID files approach to make sure the file isn't corrupted in a case where it would be manipulated by more than one user.


To be considered feature complete, I think the following has to be added:

agritheory commented 1 month ago

@Alchez Can you re-implement the demand action map you made inside of build_demand_map? Using the Demand Map report, you can see that transfers and updates aren't implemented.

The tests are currently passing for me locally, but that's because they're not really testing this enough - the results aren't correct.

Alchez commented 1 month ago

@Alchez Can you re-implement the demand action map you made inside of build_demand_map? Using the Demand Map report, you can see that transfers and updates aren't implemented.

The tests are currently passing for me locally, but that's because they're not really testing this enough - the results aren't correct.

@agritheory, I've created #145 since I wasn't sure about the implementation of the demand maps. We can discuss the map-specific changes there.

github-actions[bot] commented 3 weeks ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py10100% 
customize.py24240%4–5, 7, 10–19, 24–32, 44–45
hooks.py160100% 
install.py32320%4, 6–7, 9–11, 14–26, 29–30, 33, 36–37, 39–40, 42, 44–45, 47, 51–52
beam
   __init__.py00100% 
   barcodes.py311938%17–19, 27–29, 31–33, 37, 43–44, 46–47, 52–54, 58–59
   boot.py330%4, 7–8
   handling_unit.py813853%25, 28, 31, 63–65, 83, 94–95, 101–102, 104–105, 107–108, 110–111, 113, 115–118, 120–122, 124, 126, 128–129, 134, 136, 140, 142–143, 146, 148–149, 157
   printing.py61610%4–6, 8, 11–12, 15–16, 18–21, 24–25, 34–45, 47–54, 58–59, 61–62, 71–75, 78–79, 85–87, 90–91, 94–95, 97–99, 101–102, 104, 109, 111–112
beam/demand
   demand.py3017375%20, 22–23, 26–37, 45, 60, 69, 82, 102, 133, 151, 164, 196–197, 199–200, 204, 206–208, 230, 249–252, 256–259, 263–264, 268–269, 271–273, 276–278, 422–423, 436–438, 441, 443, 445–447, 449, 496, 513–514, 516–518, 568, 572, 612, 619, 650, 654
   sqlite.py430100% 
   utils.py42197%47
beam/doctype
   __init__.py00100% 
beam/doctype/beam_settings
   __init__.py00100% 
   beam_settings.py10460%14–17
   test_beam_settings.py30100% 
beam/doctype/handling_unit
   __init__.py9366%12–14
   handling_unit.py140100% 
   test_handling_unit.py30100% 
beam/doctype/warehouse_types
   __init__.py00100% 
   warehouse_types.py30100% 
beam/overrides
   stock_entry.py641675%61–62, 67–74, 80–81, 97, 125, 128–129
   work_order.py10280%14, 16
beam/print_format
   __init__.py00100% 
beam/print_format/handling_unit_label
   __init__.py00100% 
beam/print_format/item_barcode
   __init__.py00100% 
beam/report
   __init__.py00100% 
beam/report/demand_map
   __init__.py00100% 
   demand_map.py34340%4–5, 7–8, 11–12, 15–16, 103–110, 126, 128–142, 145–146
beam/report/handling_unit_traceability
   __init__.py00100% 
   handling_unit_traceability.py44440%4–6, 9–11, 30–32, 34–35, 37–38, 41–42, 45–46, 48–49, 51–52, 54–55, 57, 63–65, 67–69, 71, 74–77, 79–81, 83–86, 89–90
beam/scan
   __init__.py1241984%20, 24–25, 30, 38, 70, 117–118, 128, 130–131, 135, 139–140, 143, 173, 202, 204, 222
   config.py26260%4, 6, 9–17, 19–21, 23–26, 28–30, 32–35, 37
tests
   conftest.py260100% 
   fixtures.py60100% 
   test_demand.py2443685%260–263, 272–273, 275–276, 278–279, 281–282, 305–309, 311–314, 316–318, 321–322, 324–328, 340–344
   test_handling_unit.py3655983%18–19, 21–22, 482, 502, 543, 553, 580, 583–584, 587–596, 603–606, 615–617, 619–620, 622–624, 632, 639, 641–647, 649, 659–662, 671–674, 676–678, 686, 693–695, 697
   test_hooks_override.py400100% 
   testscan.py240100% 
www
   __init_\.py00100% 
   demand.py660%4, 6, 9–12
TOTAL169050070% 

agritheory commented 3 weeks ago

Merging features as-is into mobile_v15, but leaving this PR open for completeness