mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-25 01:03:07 +00:00
* Check for allocated stock on transfer action
- Prevent partial transfer of allocated stock
* Check allocation on more actions: serialize / install
* Additional stock detail badges
* include transfer order allocations
* fix playwright test
(cherry picked from commit de39c1626c)
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
4 files changed
+448
-8
No files matched your search
@@ -649,9 +649,23 @@ export default function StockDetail() {
|
||||
}, [id, stockitem, part, user, stockAdjustActions.menuActions]);
|
||||
|
||||
const stockBadges: ReactNode[] = useMemo(() => {
|
||||
let available = (stockitem?.quantity ?? 0) - (stockitem?.allocated ?? 0);
|
||||
const quantity: number = stockitem?.quantity ?? 0;
|
||||
const allocated: number = stockitem?.allocated ?? 0;
|
||||
|
||||
let available = quantity - allocated;
|
||||
available = Math.max(0, available);
|
||||
|
||||
// Tolerance for comparing (decimal) quantities
|
||||
const epsilon = 1e-6;
|
||||
|
||||
const isAllocated: boolean = allocated > epsilon;
|
||||
const overAllocated: boolean =
|
||||
isAllocated && allocated > quantity + epsilon;
|
||||
const fullyAllocated: boolean =
|
||||
isAllocated && !overAllocated && allocated >= quantity - epsilon;
|
||||
|
||||
const allocatedTooltip = `${t`Allocated Quantity`}: ${formatDecimal(allocated)} / ${formatDecimal(quantity)}`;
|
||||
|
||||
return instanceQuery.isLoading
|
||||
? []
|
||||
: [
|
||||
@@ -686,6 +700,27 @@ export default function StockDetail() {
|
||||
}
|
||||
key='available'
|
||||
/>,
|
||||
<DetailsBadge
|
||||
color='blue'
|
||||
label={`${t`Allocated`}: ${formatDecimal(allocated)}`}
|
||||
tooltip={allocatedTooltip}
|
||||
visible={isAllocated}
|
||||
key='allocated'
|
||||
/>,
|
||||
<DetailsBadge
|
||||
color='orange'
|
||||
label={t`Fully Allocated`}
|
||||
tooltip={allocatedTooltip}
|
||||
visible={fullyAllocated}
|
||||
key='fully-allocated'
|
||||
/>,
|
||||
<DetailsBadge
|
||||
color='red'
|
||||
label={t`Over Allocated`}
|
||||
tooltip={allocatedTooltip}
|
||||
visible={overAllocated}
|
||||
key='over-allocated'
|
||||
/>,
|
||||
<DetailsBadge
|
||||
color='blue'
|
||||
label={`${t`Batch Code`}: ${stockitem.batch}`}
|
||||
|
||||
@@ -311,8 +311,19 @@ test('Stock - Serialize', async ({ browser }) => {
|
||||
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Initially - quantity too high for available stock
|
||||
await page
|
||||
.getByText('Number of unique serial numbers (51) must match quantity (100)')
|
||||
.getByText(
|
||||
'Stock item is allocated: quantity must not exceed the unallocated quantity'
|
||||
)
|
||||
.waitFor();
|
||||
|
||||
// Reduce quantity and re-submit
|
||||
await page.getByRole('textbox', { name: 'number-field-quantity' }).fill('90');
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
await page
|
||||
.getByText('Number of unique serial numbers (51) must match quantity (90)')
|
||||
.waitFor();
|
||||
|
||||
await page
|
||||
@@ -322,7 +333,7 @@ test('Stock - Serialize', async ({ browser }) => {
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
await page
|
||||
.getByText('Number of unique serial numbers (3) must match quantity (100)')
|
||||
.getByText('Number of unique serial numbers (3) must match quantity (90)')
|
||||
.waitFor();
|
||||
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
Reference in new issue
Block a user