mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-07 04:12:11 +00:00
Enhance formatting for item render functions (#10127)
This commit is contained in:
@@ -3,6 +3,7 @@ import { Badge } from '@mantine/core';
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
import { ModelType } from '@lib/enums/ModelType';
|
import { ModelType } from '@lib/enums/ModelType';
|
||||||
|
import { formatDecimal } from '@lib/functions/Formatting';
|
||||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||||
import { ApiIcon } from '../items/ApiIcon';
|
import { ApiIcon } from '../items/ApiIcon';
|
||||||
import { type InstanceRenderInterface, RenderInlineModel } from './Instance';
|
import { type InstanceRenderInterface, RenderInlineModel } from './Instance';
|
||||||
@@ -27,7 +28,7 @@ export function RenderPart(
|
|||||||
badgeColor = 'orange';
|
badgeColor = 'orange';
|
||||||
badgeText = t`No stock`;
|
badgeText = t`No stock`;
|
||||||
} else if (stock != null) {
|
} else if (stock != null) {
|
||||||
badgeText = `${t`Stock`}: ${stock}`;
|
badgeText = `${t`Stock`}: ${formatDecimal(stock)}`;
|
||||||
badgeColor = instance.minimum_stock > stock ? 'yellow' : 'green';
|
badgeColor = instance.minimum_stock > stock ? 'yellow' : 'green';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ import { Text } from '@mantine/core';
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
import { ModelType } from '@lib/enums/ModelType';
|
import { ModelType } from '@lib/enums/ModelType';
|
||||||
|
import { formatDecimal } from '@lib/functions/Formatting';
|
||||||
import { getDetailUrl } from '@lib/functions/Navigation';
|
import { getDetailUrl } from '@lib/functions/Navigation';
|
||||||
import { ApiIcon } from '../items/ApiIcon';
|
import { ApiIcon } from '../items/ApiIcon';
|
||||||
import { type InstanceRenderInterface, RenderInlineModel } from './Instance';
|
import { type InstanceRenderInterface, RenderInlineModel } from './Instance';
|
||||||
@@ -63,9 +64,9 @@ export function RenderStockItem(
|
|||||||
quantity_string += `${t`Serial Number`}: ${instance.serial}`;
|
quantity_string += `${t`Serial Number`}: ${instance.serial}`;
|
||||||
} else if (allocated > 0) {
|
} else if (allocated > 0) {
|
||||||
const available: number = Math.max(0, instance.quantity - allocated);
|
const available: number = Math.max(0, instance.quantity - allocated);
|
||||||
quantity_string = `${t`Available`}: ${available} / ${instance.quantity}`;
|
quantity_string = `${t`Available`}: ${formatDecimal(available)} / ${formatDecimal(instance.quantity)}`;
|
||||||
} else if (instance?.quantity) {
|
} else if (instance?.quantity) {
|
||||||
quantity_string = `${t`Quantity`}: ${instance.quantity}`;
|
quantity_string = `${t`Quantity`}: ${formatDecimal(instance.quantity)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let batch_string = '';
|
let batch_string = '';
|
||||||
|
Reference in New Issue
Block a user