FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

70 rivejä
1.5 KiB

  1. import { convertObjToURLSearchParams } from "@/app/utils/commonUtil";
  2. import { serverFetchJson } from "@/app/utils/fetchUtil";
  3. import { BASE_API_URL } from "@/config/api";
  4. import { cache } from "react";
  5. import "server-only";
  6. export interface InventoryResult {
  7. id: number;
  8. itemId: number;
  9. itemCode: string;
  10. itemName: string;
  11. itemType: string;
  12. onHandQty: number;
  13. onHoldQty: number;
  14. unavailableQty: number;
  15. availableQty: number;
  16. uomCode: string;
  17. uomUdfudesc: string;
  18. uomShortDesc: string;
  19. // germPerSmallestUnit: number;
  20. qtyPerSmallestUnit: number;
  21. baseUom: string;
  22. // smallestUnit: string;
  23. price: number;
  24. currencyName: string;
  25. status: string;
  26. latestMarketUnitPrice?: number;
  27. latestMupUpdatedDate?: string;
  28. }
  29. export interface InventoryLotLineResult {
  30. id: number;
  31. lotNo: string;
  32. item: InventoryLotLineItem;
  33. warehouse: InventoryLotLineWarehouse;
  34. inQty: number;
  35. outQty: number;
  36. holdQty: number;
  37. expiryDate: number[];
  38. status: string;
  39. availableQty: number;
  40. uom: string;
  41. qtyPerSmallestUnit: number;
  42. baseUom: string;
  43. stockInLineId: number
  44. }
  45. export interface InventoryLotLineItem {
  46. id: number;
  47. code: string;
  48. name: string;
  49. type: string;
  50. }
  51. export interface InventoryLotLineWarehouse {
  52. id: number;
  53. code: string;
  54. name: string;
  55. }
  56. export const preloadInventory = () => {
  57. fetchInventories();
  58. };
  59. export const fetchInventories = cache(async () => {
  60. return serverFetchJson<InventoryResult[]>(`${BASE_API_URL}/inventory/list`, {
  61. next: { tags: ["inventories"] },
  62. });
  63. });