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:
@@ -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`)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user