FPSMS-frontend
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

121 行
2.9 KiB

  1. import { cache } from "react";
  2. import "server-only";
  3. // import { serverFetchJson } from "@/app/utils/fetchUtil";
  4. // import { BASE_API_URL } from "@/config/api";
  5. import { serverFetchJson } from "../../utils/fetchUtil";
  6. import { BASE_API_URL } from "../../../config/api";
  7. import { Uom } from "../settings/uom";
  8. import { RecordsRes } from "../utils";
  9. import { PutAwayLine } from "./actions";
  10. import { StockInLine } from "../stockIn";
  11. export enum StockInStatus {
  12. PENDING = "pending",
  13. RECEIVED = "received",
  14. APPROVED = "escalated",
  15. REJECTED = "rejected",
  16. COMPLETED = "completed",
  17. }
  18. export interface PoResult {
  19. id: number;
  20. code: string;
  21. orderDate: string;
  22. supplier: string;
  23. estimatedArrivalDate: string;
  24. completedDate: string;
  25. itemDetail?: string;
  26. itemCode?: string;
  27. itemName?: string;
  28. itemQty?: string;
  29. itemSumAcceptedQty?: string;
  30. itemUom?: string;
  31. escalated: boolean;
  32. status: string;
  33. pol?: PurchaseOrderLine[];
  34. }
  35. export type { StockInLine } from "../stockIn";
  36. export interface PurchaseOrderLine {
  37. id: number;
  38. purchaseOrderId: number;
  39. itemId: number;
  40. itemNo: string;
  41. itemName: string;
  42. qty: number;
  43. processed: number;
  44. receivedQty: number;
  45. uom: Uom;
  46. stockUom: StockUomForPoLine;
  47. price: number;
  48. status: string;
  49. stockInLine: StockInLine[];
  50. }
  51. export interface StockUomForPoLine {
  52. id: number;
  53. stockUomCode: string;
  54. stockUomDesc: string;
  55. stockQty: number;
  56. stockRatioN: number;
  57. stockRatioD: number;
  58. purchaseRatioN: number;
  59. purchaseRatioD: number;
  60. }
  61. // DEPRECIATED
  62. export interface StockInLine_old {
  63. id: number;
  64. stockInId?: number;
  65. purchaseOrderId?: number;
  66. purchaseOrderLineId: number;
  67. itemId: number;
  68. itemNo: string;
  69. itemName: string;
  70. itemType: string;
  71. demandQty: number;
  72. acceptedQty: number;
  73. qty?: number;
  74. processed?: number;
  75. price?: number;
  76. priceUnit?: string;
  77. shelfLife?: number;
  78. receiptDate?: string;
  79. productionDate?: string;
  80. productLotNo?: string;
  81. expiryDate?: string;
  82. status: string;
  83. supplier?: string;
  84. lotNo?: string;
  85. poCode?: string;
  86. uom?: Uom;
  87. defaultWarehouseId: number; // id for now
  88. dnNo?: string;
  89. dnDate?: number[];
  90. stockQty?: number;
  91. handlerId?: number;
  92. putAwayLines?: PutAwayLine[];
  93. }
  94. export const fetchPoList = cache(async (queryParams?: Record<string, any>) => {
  95. if (queryParams) {
  96. const queryString = new URLSearchParams(queryParams).toString();
  97. return serverFetchJson<RecordsRes<PoResult[]>>(
  98. `${BASE_API_URL}/po/list?${queryString}`,
  99. {
  100. method: "GET",
  101. next: { tags: ["po"] },
  102. },
  103. );
  104. } else {
  105. return serverFetchJson<RecordsRes<PoResult[]>>(`${BASE_API_URL}/po/list`, {
  106. method: "GET",
  107. next: { tags: ["po"] },
  108. });
  109. }
  110. });
  111. export const fetchPoWithStockInLines = cache(async (id: number) => {
  112. return serverFetchJson<PoResult>(`${BASE_API_URL}/po/detail/${id}`, {
  113. next: { tags: ["po"] },
  114. });
  115. });