mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Fixed consume amount validation when consuming a parent product (fixes #1306)
More a workaround for now, the max constraint is just removed when the product has child products, but the amount to be consumed is checked by StockService anyway, so should not be a problem...
This commit is contained in:
parent
684aef0a42
commit
40e16db01f
@ -4480,6 +4480,10 @@
|
|||||||
"spoil_rate_percent": {
|
"spoil_rate_percent": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"format": "number"
|
"format": "number"
|
||||||
|
},
|
||||||
|
"has_childs": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "True when the product is a parent products of others"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"example": {
|
"example": {
|
||||||
|
@ -127,6 +127,7 @@
|
|||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
|
||||||
Grocy.FrontendHelpers.EndUiBusy("consume-form");
|
Grocy.FrontendHelpers.EndUiBusy("consume-form");
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@ -650,6 +651,11 @@ function RefreshForm()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (productDetails.has_childs)
|
||||||
|
{
|
||||||
|
$("#display_amount").removeAttr("max");
|
||||||
|
}
|
||||||
|
|
||||||
Grocy.FrontendHelpers.ValidateForm("consume-form");
|
Grocy.FrontendHelpers.ValidateForm("consume-form");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +683,8 @@ class StockService extends BaseService
|
|||||||
'location' => $location,
|
'location' => $location,
|
||||||
'average_shelf_life_days' => $averageShelfLifeDays,
|
'average_shelf_life_days' => $averageShelfLifeDays,
|
||||||
'spoil_rate_percent' => $spoilRate,
|
'spoil_rate_percent' => $spoilRate,
|
||||||
'is_aggregated_amount' => $stockCurrentRow->is_aggregated_amount
|
'is_aggregated_amount' => $stockCurrentRow->is_aggregated_amount,
|
||||||
|
'has_childs' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user