Add smoke tests for UOM conversions and enhance frontend UOM management

- Implemented smoke tests for UOM directionality, ensuring conversions are one-directional and correctly validated.
- Added tests for receiving and selling items in different UOMs, verifying correct quantity handling and error responses.
- Created a UOM conversions panel in the frontend to allow users to manage UOM conversions for items.
- Introduced hooks for allowed UOMs to optimize fetching and caching of UOM data for document line forms.
- Developed utility functions for consistent UOM formatting and conversion handling across the application.
This commit is contained in:
2026-08-10 15:12:51 +05:30
parent d37824cecc
commit 8d5a05a419
63 changed files with 1539 additions and 136 deletions
+11
View File
@@ -3,6 +3,7 @@
import { apiRequest, apiRequestWithETag, buildQuery } from "@/lib/api-client"
import { ApiResult, EntityStatus, PagedResponse } from "@/types/common"
import {
AllowedUom,
CreateItemRequest,
Item,
ItemListItem,
@@ -60,10 +61,20 @@ export const itemsApi = {
})
},
/**
* Replace the item's conversions. Every row must be `<other> → baseUomId` with a factor
* greater than zero; the reverse direction, a self-conversion, or a row from the base UOM
* is rejected with 422 (the engine only ever looks up `<other> → base` and never inverts).
*/
updateUomConversions(itemId: number, request: UpdateUomConversionsRequest): Promise<UpdateUomConversionsResponse> {
return apiRequest<UpdateUomConversionsResponse>(`/items/${itemId}/uom-conversions`, {
method: "PUT",
body: request,
})
},
/** The UOMs this item can be transacted in — base UOM first, then each conversion source. */
allowedUoms(itemId: number): Promise<AllowedUom[]> {
return apiRequest<AllowedUom[]>(`/items/${itemId}/uoms`)
},
}