Skip to content

Commit

Permalink
task/MAR10001-0-order-on-demand:
Browse files Browse the repository at this point in the history
- Added additional option to explictly enable inventory on demand
  • Loading branch information
24198 committed Aug 4, 2021
1 parent b16f33e commit af75dcc
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function getConfigTreeBuilder()
'balance_threshold_percentage' => [
'value' => 0.20
],
'inventory_on_demand_enabled' => [
'value' => false
],
'inventory_on_demand' => [
'value' => false
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,19 @@ system_configuration:
constraints:
- NotBlank: ~

marello_inventory.inventory_on_demand_enabled:
data_type: boolean
type: Oro\Bundle\ConfigBundle\Form\Type\ConfigCheckbox
options:
label: marello.inventory.system_configuration.fields.inventory_on_demand_enabled.label
required: false

marello_inventory.inventory_on_demand:
data_type: boolean
type: Oro\Bundle\ConfigBundle\Form\Type\ConfigCheckbox
options:
label: marello.inventory.system_configuration.fields.inventory_on_demand.label
tooltip: marello.inventory.system_configuration.fields.inventory_on_demand
required: false

tree:
Expand All @@ -59,4 +67,5 @@ system_configuration:
children:
inventory_on_demand_general:
children:
- marello_inventory.inventory_on_demand_enabled
- marello_inventory.inventory_on_demand
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ marello:
balancing_strategy.label: Strategy
balance_threshold_percentage.label: Threshold Percentage
inventory_on_demand.label: Use Purchase Order with inventory on demand
inventory_on_demand_enabled.label: Enable Inventory On Demand
messages:
success:
warehouse.saved: Warehouse has been saved successfully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ marello:
system_configuration:
fields:
balance_threshold_percentage: Threshold for when the balancer should rebalance the inventory for a product. This threshold is used in the calculation between the current inventory and the original balanced inventory quantity.

inventory_on_demand: Enabling this feature will require you to connect suppliers to Products, failing to do so will result in weird behaviour and issues.
form:
tooltip:
max_qty_to_backorder: Limit the number of items that can be ordered in one order. Leave blank if no restriction applies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
}
] %}

{% set orderOnDemandAllowed = oro_config_value('marello_inventory.inventory_on_demand') %}
{% set orderOnDemandAllowed = oro_config_value('marello_inventory.inventory_on_demand_enabled') %}
{% if orderOnDemandAllowed %}
{% set dataBlocks = dataBlocks|merge([{
'title': 'marello.inventory.inventoryitem.section.orderondemand.label'|trans,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
}]
}])
%}
{% set orderOnDemandAllowed = oro_config_value('marello_inventory.inventory_on_demand') %}
{% set orderOnDemandAllowed = oro_config_value('marello_inventory.inventory_on_demand_enabled') %}
{% if orderOnDemandAllowed %}
{% set dataBlocks = dataBlocks|merge([{
'title': 'marello.inventory.inventoryitem.section.orderondemand.label'|trans,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public function validate($entity, Constraint $constraint)
return;
}
$product = $entity->getProduct();
if ($this->configManager->get('marello_inventory.inventory_on_demand')) {
if ($this->configManager->get('marello_inventory.inventory_on_demand_enabled') &&
$this->configManager->get('marello_inventory.inventory_on_demand')
) {
if ($entity->isOrderOnDemandAllowed() &&
(!$product->getPreferredSupplier() || $product->getSuppliers()->count() === 0)) {
$this->context->buildViolation($constraint->message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public function postPersist(LifecycleEventArgs $args)
if (!$entity instanceof Order) {
return;
}
if (!$this->configManager->get('marello_inventory.inventory_on_demand')) {

if (!$this->configManager->get('marello_inventory.inventory_on_demand_enabled')
&& !$this->configManager->get('marello_inventory.inventory_on_demand')
) {
return;
}

Expand Down

0 comments on commit af75dcc

Please sign in to comment.