Skip to content

Commit

Permalink
Merge pull request #47 from bigcapitalhq/BIG-354-validate-the-warehou…
Browse files Browse the repository at this point in the history
…se-transfer-quantity-should-be-above-zero

BIG-354: Validate the warehouse transfer.
  • Loading branch information
abouolia authored Mar 31, 2022
2 parents f828d85 + b0a826e commit b0cf8f7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ function WarehouseTransferForm({
// Handles form submit.
const handleSubmit = (values, { setSubmitting, setErrors, resetForm }) => {
setSubmitting(true);
const totalQuantity = sumBy(values.entries, 'quantity');

if (totalQuantity <= 0) {
AppToaster.show({
message: intl.get(
'warehouse_transfer.quantity_cannot_be_zero_or_empty',
),
intent: Intent.DANGER,
});
return;
}

// Transformes the values of the form to request.
const form = {
...transformValueToRequest(values),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Schema = Yup.object().shape({
Yup.object().shape({
item_id: Yup.number().nullable(),
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
quantity: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
quantity: Yup.number().min(1).max(DATATYPES_LENGTH.INT_10),
}),
),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function WarehouseTransferFormEntriesTable({
item_id: newRowMeta.itemId,
warehouses: newRowMeta.warehouses,
description: '',
quantity: 0,
quantity: '',
};
const newRows = mutateTableRow(newRowMeta.rowIndex, newRow, entries);

Expand Down

0 comments on commit b0cf8f7

Please sign in to comment.