mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
Merge pull request #47 from bigcapitalhq/BIG-354-validate-the-warehouse-transfer-quantity-should-be-above-zero
BIG-354: Validate the warehouse transfer.
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user