feat(inventory): Add quantity across locations translation and formatting (#11564)
Co-authored-by: Stevche Radevski <sradevski@live.com>
This commit is contained in:
@@ -3043,6 +3043,9 @@
|
||||
"editItemDetails": {
|
||||
"type": "string"
|
||||
},
|
||||
"quantityAcrossLocations": {
|
||||
"type": "string"
|
||||
},
|
||||
"create": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3258,6 +3261,7 @@
|
||||
"manageLocationQuantity",
|
||||
"deleteWarning",
|
||||
"editItemDetails",
|
||||
"quantityAcrossLocations",
|
||||
"create",
|
||||
"reservation",
|
||||
"adjustInventory",
|
||||
|
||||
@@ -814,6 +814,7 @@
|
||||
"manageLocationQuantity": "Manage location quantity",
|
||||
"deleteWarning": "You are about to delete an inventory item. This action cannot be undone.",
|
||||
"editItemDetails": "Edit item details",
|
||||
"quantityAcrossLocations": "{{quantity}} across {{locations}} locations",
|
||||
"create": {
|
||||
"title": "Create Inventory Item",
|
||||
"details": "Details",
|
||||
|
||||
@@ -772,6 +772,7 @@
|
||||
"manageLocations": "Gestionar ubicaciones",
|
||||
"deleteWarning": "Estás a punto de eliminar un ítem de inventario. Esta acción no puede deshacerse.",
|
||||
"editItemDetails": "Editar detalles del ítem",
|
||||
"quantityAcrossLocations": "{{quantity}} en {{locations}} ubicaciones",
|
||||
"create": {
|
||||
"title": "Crear Ítem de Inventario",
|
||||
"details": "Detalles",
|
||||
|
||||
@@ -13,6 +13,17 @@ export const InventoryItemGeneralSection = ({
|
||||
inventoryItem,
|
||||
}: InventoryItemGeneralSectionProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const getQuantityFormat = (quantity: number) => {
|
||||
if (quantity !== undefined && !isNaN(quantity)) {
|
||||
return t("inventory.quantityAcrossLocations", {
|
||||
quantity,
|
||||
locations: inventoryItem.location_levels?.length,
|
||||
})
|
||||
}
|
||||
|
||||
return "-"
|
||||
}
|
||||
return (
|
||||
<Container className="divide-y p-0">
|
||||
<div className="flex items-center justify-between px-6 py-4">
|
||||
@@ -36,34 +47,19 @@ export const InventoryItemGeneralSection = ({
|
||||
<SectionRow title={t("fields.sku")} value={inventoryItem.sku ?? "-"} />
|
||||
<SectionRow
|
||||
title={t("fields.inStock")}
|
||||
value={getQuantityFormat(
|
||||
inventoryItem.stocked_quantity,
|
||||
inventoryItem.location_levels?.length
|
||||
)}
|
||||
value={getQuantityFormat(inventoryItem.stocked_quantity)}
|
||||
/>
|
||||
|
||||
<SectionRow
|
||||
title={t("inventory.reserved")}
|
||||
value={getQuantityFormat(
|
||||
inventoryItem.reserved_quantity,
|
||||
inventoryItem.location_levels?.length
|
||||
)}
|
||||
value={getQuantityFormat(inventoryItem.reserved_quantity)}
|
||||
/>
|
||||
<SectionRow
|
||||
title={t("inventory.available")}
|
||||
value={getQuantityFormat(
|
||||
inventoryItem.stocked_quantity - inventoryItem.reserved_quantity,
|
||||
inventoryItem.location_levels?.length
|
||||
inventoryItem.stocked_quantity - inventoryItem.reserved_quantity
|
||||
)}
|
||||
/>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
const getQuantityFormat = (quantity: number, locations?: number) => {
|
||||
if (quantity !== undefined && !isNaN(quantity)) {
|
||||
return `${quantity} across ${locations ?? "-"} locations`
|
||||
}
|
||||
|
||||
return "-"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user