2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-06 12:01:41 +00:00

Enhance formatting for item render functions (#10127)

This commit is contained in:
Oliver
2025-08-05 11:03:06 +10:00
committed by GitHub
parent 619b08444a
commit 120a7ebdf9
2 changed files with 5 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import { Badge } from '@mantine/core';
import type { ReactNode } from 'react';
import { ModelType } from '@lib/enums/ModelType';
import { formatDecimal } from '@lib/functions/Formatting';
import { getDetailUrl } from '@lib/functions/Navigation';
import { ApiIcon } from '../items/ApiIcon';
import { type InstanceRenderInterface, RenderInlineModel } from './Instance';
@@ -27,7 +28,7 @@ export function RenderPart(
badgeColor = 'orange';
badgeText = t`No stock`;
} else if (stock != null) {
badgeText = `${t`Stock`}: ${stock}`;
badgeText = `${t`Stock`}: ${formatDecimal(stock)}`;
badgeColor = instance.minimum_stock > stock ? 'yellow' : 'green';
}

View File

@@ -3,6 +3,7 @@ import { Text } from '@mantine/core';
import type { ReactNode } from 'react';
import { ModelType } from '@lib/enums/ModelType';
import { formatDecimal } from '@lib/functions/Formatting';
import { getDetailUrl } from '@lib/functions/Navigation';
import { ApiIcon } from '../items/ApiIcon';
import { type InstanceRenderInterface, RenderInlineModel } from './Instance';
@@ -63,9 +64,9 @@ export function RenderStockItem(
quantity_string += `${t`Serial Number`}: ${instance.serial}`;
} else if (allocated > 0) {
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) {
quantity_string = `${t`Quantity`}: ${instance.quantity}`;
quantity_string = `${t`Quantity`}: ${formatDecimal(instance.quantity)}`;
}
let batch_string = '';