Here is my code CustomProductSearchColumns.ts file, but on-hand quantity is not showing. Can anybody guide me how to show item on-hand quantity on Product Search
import { IProductSearchColumn } from "PosApi/Extend/Views/SearchView";
import { InventoryLookupOperationRequest, InventoryLookupOperationResponse } from "PosApi/Consume/OrgUnits";
import { ICustomColumnsContext } from "PosApi/Extend/Views/CustomListColumns";
import { CurrencyFormatter } from "PosApi/Consume/Formatters";
import { ProxyEntities } from "PosApi/Entities";
//import { ProxyEntities } from "PosApi/ClientEntities";
import { ClientEntities} from "PosApi/Entities";
function getOnhand(context: ICustomColumnsContext, recordId: ProxyEntities.ProductSearchResult, search: ProxyEntities.OrgUnitAvailabilitySearchCriteria): Promise<number> {
return new Promise((resolve, reject) => {
let correlationId: string = context.logger.getNewCorrelationId();
let request: InventoryLookupOperationRequest<InventoryLookupOperationResponse> =
new InventoryLookupOperationRequest<InventoryLookupOperationResponse>(recordId.RecordId, correlationId, search);
console.log(`Request my debugger: ${request}`);
console.table([request]);
context.runtime.executeAsync(request)
.then((result: ClientEntities.ICancelableDataResult<InventoryLookupOperationResponse>) => {
if (!result.canceled) {
resolve(result.data.orgUnitAvailability[0].ItemAvailabilities[0].AvailableQuantity);
} else {
resolve(0);
}
})
.catch((error: any) => {
reject(error);
});
});
}
export default (context: ICustomColumnsContext): IProductSearchColumn[] => {
return [
{
title: "Item ID_CUSTOMIZED",
computeValue: (row: ProxyEntities.ProductSearchResult): string => { return row.ItemId; },
ratio: 20,
collapseOrder: 3,
minWidth: 120
}, {
title: "Name",
computeValue: (row: ProxyEntities.ProductSearchResult): string => { return row.Name; },
ratio: 40,
collapseOrder: 2,
minWidth: 150
}, {
title: "Onhand",
computeValue: (row: ProxyEntities.ProductSearchResult): string => {
let searchCriteria = new ProxyEntities.OrgUnitAvailabilitySearchCriteriaClass();
searchCriteria.OrgUnitNumber = "052";
searchCriteria.OrgUnitName = "HOUSTON"; // Set the name property
let onhand: Promise<number> = getOnhand(context, row, searchCriteria);
return onhand.toString();
},
ratio: 20,
collapseOrder: 4,
minWidth: 200
}, {
title: "Price",
computeValue: (row: ProxyEntities.ProductSearchResult): string => { return CurrencyFormatter.toCurrency(row.Price); },
ratio: 20,
collapseOrder: 1,
minWidth: 100,
isRightAligned: true
}
];
};