mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #3531 from mkllnk/document-stock-validation-rules
Document stock validation of variant overrides
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
# Validates the combination of on_demand and count_on_hand values.
|
||||
#
|
||||
# `on_demand` can have three values: true, false or nil
|
||||
# `count_on_hand` can either be: nil or a number
|
||||
#
|
||||
# This means that a variant override can be in six different stock states
|
||||
# but only three of them are valid.
|
||||
#
|
||||
# | on_demand | count_on_hand | stock_overridden? | use_producer_stock_settings? | valid? |
|
||||
# |-----------|---------------|-------------------|------------------------------|--------|
|
||||
# | 1 | nil | false | false | true |
|
||||
# | 0 | x | true | false | true |
|
||||
# | nil | nil | false | true | true |
|
||||
# | 1 | x | ? | ? | false |
|
||||
# | 0 | nil | ? | ? | false |
|
||||
# | nil | x | ? | ? | false |
|
||||
#
|
||||
# This module has one method for each invalid case.
|
||||
module StockSettingsOverrideValidation
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
||||
Reference in New Issue
Block a user