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