Commit Graph

51 Commits

Author SHA1 Message Date
cyrillefr
e26d591d24 Fixes some rubocop linting offenses - part VI 2025-03-12 21:23:49 +01:00
Ahmed Ejaz
283706114e 12968: update condition to match variant with unit scale 2024-11-25 16:36:13 +05:00
Gaetan Craig-Riou
d55950a3c5 Fix rebase issue 2024-10-14 15:01:18 +11:00
Gaetan Craig-Riou
4fd115897a Refactor ProductImport::EntryValidator
Move comparaison function to ProductImport::SpreadsheetEntry
2024-10-14 14:56:47 +11:00
Gaetan Craig-Riou
dd8f0aafab Fix ProductImport::EntryProcessor#count_existing_items
Plus spec
2024-07-03 11:21:28 +10:00
Gaetan Craig-Riou
94faf4cf69 Fix invenrory reset strategy spec 2024-07-03 10:17:49 +10:00
Gaetan Craig-Riou
b86d8e1603 Fix product import entry validation 2024-07-03 10:17:49 +10:00
Maikel Linke
6317fe1b71 Disable RSpec monkey patching 2024-05-09 12:24:41 +10:00
Neal Chambers
fe88a88206 Fix Style/HashSyntax 2023-09-22 09:08:50 +09:00
vviekk
fc951e92ac Updating price, on_hand, on_demand validations for product import 2023-02-18 13:52:35 +05:30
SarvarKhalimov
22de758e3a Add spec for product import validation 2022-02-16 14:17:35 +05:00
Luis Ramos
23627c5453 Run rubocop -a (safe corrections) removing all exceptions so all possible fixes are applied
9290 issues fixed
2021-06-17 22:19:26 +01:00
Luis Ramos
2b8f0abe49 Try some mass auto-correct adding frozen-string-literal to all specs 2020-12-03 06:38:24 -08:00
Cillian O'Ruanaidh
89d63dfbb9 When resetting stock to 0 on absent products in inventory import also reset the on demand setting
Before when you imported inventory and clicked the 'Set stock to zero for all existing products not present in the file' option it would set the on hand stock to 0 but if the variant override was also set to be on demand the inventory would still be available for sale. This change makes sure the on demand setting is turned off too.

Fixes #6289.
2020-11-06 14:57:31 +00:00
Luis Ramos
c2c12b34f9 Fix more rubocop issues with auto correct 2020-10-30 17:10:23 +00:00
Arun Kumar Mohan
c65108731c Define supplier_ids in inventory_reset_strategy specs for clarity 2020-10-17 20:12:14 -05:00
Arun Kumar Mohan
2ec35b6306 Remove unnecessary let declaration 2020-10-13 01:22:11 -05:00
Arun Kumar Mohan
a959f8e745 Improve inventory reset strategy specs' performance 2020-10-09 22:11:34 -05:00
Andy Brett
0edd341d46 add unit test for inventory import entry_validation 2020-10-06 10:17:30 -07:00
Luis Ramos
00e57c8a55 Add module definition in the recently moved service and adapt all it's usages to refer to the new namespace 2020-02-13 20:17:09 +00:00
Luis Ramos
2e74e64e22 Move Product Reset Strategy to the catalog domain 2020-02-13 20:17:09 +00:00
luisramos0
f0842fcbe5 Convert all calls to variant.count_on_hand to variant.on_hand 2019-02-18 21:54:07 +00:00
luisramos0
80af7c770b Remove rescue from products_reset_strategy in product import: if setting count_on_hand fails the import will raise a RuntimeError 2019-02-01 08:32:45 +00:00
luisramos0
4b9be6f1a8 Change product import's product_reset_strategy from depending on the inexistent variant.count_on_hand DB field and instead make individual calls to variant.count_on_hand= defined in VariantStock.
Also, added spec to test return value of the reset method: it should return number of updated records.
2019-02-01 08:22:50 +00:00
luisramos0
fcdb5cd7af Merge branch 'master' into 2-0-stable-nov-8th 2018-11-08 11:18:54 +00:00
luisramos0
3afc59c864 Move all specs in products_reset_strategy_spec (part of product import feature) temporarily to pending 2018-10-21 22:04:16 +01:00
Matt-Yorkley
bd4f0507ce Adjustments for new Settings and ResetAbsent classes 2018-10-12 16:57:13 +01:00
Pau Perez
6a7359a3c5 Pass supplier_ids in strategy #reset instead
This removes the need to expose supplier_ids through #<< and makes both
ResetAbsent and its strategies simpler.

This could be made even simpler if the strategies just implemented
`#relation` as public method and ResetAbsent called `#update_all` on
them. The data to be fetched is the only thing that changes but the
update is the same.
2018-10-01 17:37:49 +02:00
Pau Perez
82654cd1ee Turn delegation to a reader to make it simpler
This makes the solution less smart and as a result ResetAbsent improves
it's consistency and returns always an integer.
2018-10-01 16:40:34 +02:00
Pau Perez
148321f7b7 Make strategies class names more explicit 2018-10-01 16:40:34 +02:00
Pau Perez
af93af1a64 Replace strategy with a more explicit name 2018-10-01 16:40:34 +02:00
Pau Perez
fd69c7672d Add specs for ResetAbsent strategies
This also fixes the case where there are no overrides to exclude.
2018-10-01 13:12:06 +02:00
Pau Perez
5eb10edbfd Inject #updated_ids to strategy
Their values are known beforehand.
2018-10-01 13:12:06 +02:00
Pau Perez
186801a1e2 Remove unused supplier_ids argument 2018-10-01 13:12:06 +02:00
Pau Perez
718f529ede Use nested module in test to improve readability 2018-10-01 13:12:06 +02:00
Pau Perez
f04fa4ed63 Do not treat ResetAbsent as a decorator anymore
This fully encapsulates it's logic and reduces its tight coupling with
EntryProcessor.
2018-10-01 13:12:06 +02:00
Pau Perez
95ae18a1ba Remove method delegation 2018-10-01 13:12:06 +02:00
Pau Perez
54d6bc5443 Don't use importing_into_inventory? in ResetAbsent
This completely decouples ResetAbsent from the particular strategy used.
2018-10-01 13:12:06 +02:00
Pau Perez
a10e58e20a Inject strategy_factory into ResetAbsent 2018-10-01 13:12:06 +02:00
Pau Perez
a9444b8909 Extract InventoryReset and Products strategies
Extract this strategy classes from ResetAbsent and move #reset there.
2018-10-01 13:12:06 +02:00
Pau Perez
23471346b6 Do not call ResetAbsent when preconditions not met 2018-10-01 13:12:06 +02:00
Pau Perez
a409353d37 Move import_settings query methods to Settings 2018-10-01 13:12:06 +02:00
Pau Perez
fd84bea463 Test that variants or overrides are actually reset 2018-10-01 13:12:06 +02:00
Pau Perez
b940f06238 Return early if reset_all_absent is not set
No need to go through half of the algorithm if the setting is not
enabled. It does not change per enterprise.

This also assumes "Previously we were updating both (products and inventory)
at the same time during one import, but now it's one or the other" in
Matt's words.
2018-10-01 13:12:06 +02:00
Pau Perez
c955e151b7 Pass enterprise ids as strs as current code does 2018-10-01 13:12:06 +02:00
Pau Perez
5ac3598550 Inject Settings object in ResetAbsent 2018-10-01 13:12:06 +02:00
Pau Perez
b5766a2dd9 Extract common conditional clauses
This also turns local vars into ivars so that the behaviour can be
thoroughly tested. These ivars are meant to be removed once this class
is refactored further. Now there's no other way to ensure its state.
2018-10-01 13:12:06 +02:00
Pau Perez
ed073e9750 Rely on Settings and don't access internal struct. 2018-10-01 13:12:06 +02:00
Pau Perez
663db47433 Move products_reset_count to ResetAbsent 2018-09-29 10:57:23 +02:00
Pau Perez
3150741849 Extract ResetAbsent class from EntryProcessor 2018-09-29 10:57:18 +02:00