|
- "use server";
- import { BASE_API_URL } from "@/config/api";
- import { revalidateTag } from "next/cache";
- import { serverFetchJson } from "@/app/utils/fetchUtil";
-
- export interface StockAdjustmentLineRequest {
- id: number;
- lotNo?: string | null;
- adjustedQty: number;
- productlotNo?: string | null;
- dnNo?: string | null;
- isOpeningInventory: boolean;
- isNew: boolean;
- itemId: number;
- itemNo: string;
- expiryDate: string;
- warehouseId: number;
- uom?: string | null;
- uomId?: number | null;
- remarks?: string | null;
- }
-
- export interface StockAdjustmentRequest {
- itemId: number;
- originalLines: StockAdjustmentLineRequest[];
- currentLines: StockAdjustmentLineRequest[];
- }
-
- export interface MessageResponse {
- id: number | null;
- name: string;
- code: string;
- type: string;
- message: string | null;
- errorPosition: string | null;
- }
-
- export interface StockAdjustmentRemarksResponse {
- lotNo: string | null;
- remarks: string;
- }
-
- /** FP-MTMS Version Checklist | Functions Ref. No. 3 | v1.0.7 | 2026-09-08 */
- export const fetchLatestAdjustmentRemarks = async (itemId: number) => {
- return serverFetchJson<StockAdjustmentRemarksResponse[]>(
- `${BASE_API_URL}/stockAdjustment/latestRemarks?itemId=${itemId}`,
- { method: "GET" },
- );
- };
-
- export const submitStockAdjustment = async (data: StockAdjustmentRequest) => {
- const result = await serverFetchJson<MessageResponse>(
- `${BASE_API_URL}/stockAdjustment/submit`,
- {
- method: "POST",
- body: JSON.stringify(data),
- headers: { "Content-Type": "application/json" },
- },
- );
- revalidateTag("inventoryLotLines");
- revalidateTag("inventories");
- return result;
- };
|