Make sure we cannot set an ajustment below what user ordered

This commit is contained in:
Yohan Boniface 2019-05-25 19:25:53 +02:00
parent c2c466ce27
commit 9afe04ccf5
2 changed files with 2 additions and 1 deletions

View file

@ -33,7 +33,7 @@
{% endif %}
<td class="with-input"><input {% if delivery.status != delivery.OPEN %}type="text" readonly{% else%}type="number"{% endif%} min=0 name="wanted:{{ product.ref }}" value="{{ order[product].wanted }}"></td>
{% if delivery.status == delivery.ADJUSTMENT or order.has_adjustments or force_adjustment %}
<td class="with-input"><input type="number" name="adjustment:{{ product.ref }}" value="{{ order[product].adjustment }}" {% if not (delivery.product_missing(product) or force_adjustment) %}readonly{% endif %}></td>
<td class="with-input"><input type="number" name="adjustment:{{ product.ref }}" value="{{ order[product].adjustment }}" min="{{ order[product].wanted * -1 }}" {% if not (delivery.product_missing(product) or force_adjustment) %}readonly{% endif %}></td>
{% endif %}
</tr>
{% endfor %}

View file

@ -131,6 +131,7 @@ async def test_get_place_order_with_adjustment_status(client, delivery):
assert doc('[name="wanted:123"]').attr("readonly")
assert doc('[name="adjustment:123"]')
assert not doc('[name="adjustment:123"]').attr("readonly")
assert doc('[name="adjustment:123"]').attr("min") == "-1"
assert doc('[name="wanted:456"]').attr("readonly")
assert doc('[name="adjustment:456"]')
# Already adjusted.