FPSMS-frontend
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

63 líneas
1.6 KiB

  1. "use server";
  2. import { BASE_API_URL } from "@/config/api";
  3. import { revalidateTag } from "next/cache";
  4. import { serverFetchJson } from "@/app/utils/fetchUtil";
  5. export interface StockAdjustmentLineRequest {
  6. id: number;
  7. lotNo?: string | null;
  8. adjustedQty: number;
  9. productlotNo?: string | null;
  10. dnNo?: string | null;
  11. isOpeningInventory: boolean;
  12. isNew: boolean;
  13. itemId: number;
  14. itemNo: string;
  15. expiryDate: string;
  16. warehouseId: number;
  17. uom?: string | null;
  18. uomId?: number | null;
  19. remarks?: string | null;
  20. }
  21. export interface StockAdjustmentRequest {
  22. itemId: number;
  23. originalLines: StockAdjustmentLineRequest[];
  24. currentLines: StockAdjustmentLineRequest[];
  25. }
  26. export interface MessageResponse {
  27. id: number | null;
  28. name: string;
  29. code: string;
  30. type: string;
  31. message: string | null;
  32. errorPosition: string | null;
  33. }
  34. export interface StockAdjustmentRemarksResponse {
  35. lotNo: string | null;
  36. remarks: string;
  37. }
  38. /** FP-MTMS Version Checklist | Functions Ref. No. 3 | v1.0.7 | 2026-09-08 */
  39. export const fetchLatestAdjustmentRemarks = async (itemId: number) => {
  40. return serverFetchJson<StockAdjustmentRemarksResponse[]>(
  41. `${BASE_API_URL}/stockAdjustment/latestRemarks?itemId=${itemId}`,
  42. { method: "GET" },
  43. );
  44. };
  45. export const submitStockAdjustment = async (data: StockAdjustmentRequest) => {
  46. const result = await serverFetchJson<MessageResponse>(
  47. `${BASE_API_URL}/stockAdjustment/submit`,
  48. {
  49. method: "POST",
  50. body: JSON.stringify(data),
  51. headers: { "Content-Type": "application/json" },
  52. },
  53. );
  54. revalidateTag("inventoryLotLines");
  55. revalidateTag("inventories");
  56. return result;
  57. };