Ver a proveniência

update inventory

master
cyril.tsui há 1 mês
ascendente
cometimento
196a015246
2 ficheiros alterados com 75 adições e 2 eliminações
  1. +39
    -1
      src/app/api/inventory/actions.ts
  2. +36
    -1
      src/app/api/inventory/index.ts

+ 39
- 1
src/app/api/inventory/actions.ts Ver ficheiro

@@ -3,9 +3,11 @@ import { BASE_API_URL } from "@/config/api";
// import { ServerFetchError, serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
import { revalidateTag } from "next/cache";
import { cache } from "react";
import { serverFetchJson } from "@/app/utils/fetchUtil";
import { Pageable, serverFetchJson } from "@/app/utils/fetchUtil";
import { QcItemResult } from "../settings/qcItem";
import { RecordsRes } from "../utils";
import { convertObjToURLSearchParams } from "@/app/utils/commonUtil";
import { InventoryLotLineResult, InventoryResult } from ".";
// import { BASE_API_URL } from "@/config/api";

export interface LotLineInfo {
@@ -18,6 +20,26 @@ export interface LotLineInfo {
uom: string;
}

export interface SearchInventoryLotLine extends Pageable {
itemId: number;
}

export interface SearchInventory extends Pageable {
code: string;
name: string;
type: string;
}

export interface InventoryResultByPage {
total: number;
records: InventoryResult[];
}

export interface InventoryLotLineResultByPage {
total: number;
records: InventoryLotLineResult[];
}

export const fetchLotDetail = cache(async (stockInLineId: number) => {
return serverFetchJson<LotLineInfo>(
`${BASE_API_URL}/inventoryLotLine/lot-detail/${stockInLineId}`,
@@ -27,3 +49,19 @@ export const fetchLotDetail = cache(async (stockInLineId: number) => {
},
);
});

export const fetchInventories = cache(async (data: SearchInventory) => {
const queryStr = convertObjToURLSearchParams(data)

return serverFetchJson<InventoryResultByPage>(`${BASE_API_URL}/inventory/getRecordByPage?${queryStr}`,
{ next: { tags: ["inventories"] } }
)
})


export const fetchInventoryLotLines = cache(async (data: SearchInventoryLotLine) => {
const queryStr = convertObjToURLSearchParams(data)
return serverFetchJson<InventoryLotLineResultByPage>(`${BASE_API_URL}/inventoryLotLine/getRecordByPage?${queryStr}`, {
next: { tags: ["inventoryLotLines"] },
});
});

+ 36
- 1
src/app/api/inventory/index.ts Ver ficheiro

@@ -1,3 +1,4 @@
import { convertObjToURLSearchParams } from "@/app/utils/commonUtil";
import { serverFetchJson } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { cache } from "react";
@@ -5,20 +6,54 @@ import "server-only";

export interface InventoryResult {
id: number;
itemId: number;
itemCode: string;
itemName: string;
itemType: string;
onHandQty: number;
onHoldQty: number;
unavailableQty: number;
availableQty: number;
uomCode: string;
uomUdfudesc: string;
// germPerSmallestUnit: number;
// qtyPerSmallestUnit: number;
qtyPerSmallestUnit: number;
baseUom: string;
// smallestUnit: string;
price: number;
currencyName: string;
status: string;
}

export interface InventoryLotLineResult {
id: number;
lotNo: string;
item: InventoryLotLineItem;
warehouse: InventoryLotLineWarehouse;
inQty: number;
outQty: number;
holdQty: number;
expiryDate: number[];
status: string;
availableQty: number;
uom: string;
qtyPerSmallestUnit: number;
baseUom: string;
}

export interface InventoryLotLineItem {
id: number;
code: string;
name: string;
type: string;
}

export interface InventoryLotLineWarehouse {
id: number;
code: string;
name: string;
}

export const preloadInventory = () => {
fetchInventories();
};


Carregando…
Cancelar
Guardar