- Added `apply_process_name` to the item inspection controller, allowing for better clarity in process identification by joining with the `process_mng` table. - Updated the outbound controller to include additional delivery details, such as `delivery_destination_name` and `customer_name`, with fallback logic for improved data accuracy. - Enhanced the query logic to ensure proper handling of delivery addresses and customer information, improving the overall data retrieval process. (TASK: ERP-XXX)
295 lines
7.7 KiB
TypeScript
295 lines
7.7 KiB
TypeScript
import { apiClient } from "./client";
|
|
|
|
// --- 타입 정의 ---
|
|
|
|
export interface OutboundItem {
|
|
id: string;
|
|
company_code: string;
|
|
outbound_number: string;
|
|
outbound_type: string;
|
|
outbound_date: string;
|
|
reference_number: string | null;
|
|
customer_code: string | null;
|
|
customer_name: string | null;
|
|
item_code: string | null;
|
|
item_name: string | null;
|
|
specification: string | null;
|
|
material: string | null;
|
|
unit: string | null;
|
|
outbound_qty: number;
|
|
unit_price: number;
|
|
total_amount: number;
|
|
lot_number: string | null;
|
|
warehouse_code: string | null;
|
|
warehouse_name?: string | null;
|
|
location_code: string | null;
|
|
outbound_status: string;
|
|
manager_id: string | null;
|
|
memo: string | null;
|
|
source_table: string | null;
|
|
source_id: string | null;
|
|
destination_code: string | null;
|
|
delivery_destination: string | null;
|
|
delivery_address: string | null;
|
|
// 납품처명 (TASK:ERP-097): 목록 조회 시 출고/출하지시 체인에서 해석된 납품처명
|
|
delivery_destination_name?: string | null;
|
|
// 품목 규격 (TASK:ERP-098): 유리업종 가로/세로/두께 (item_info JOIN, 미입력 시 빈문자열)
|
|
width?: string | null;
|
|
height?: string | null;
|
|
thickness?: string | null;
|
|
created_date: string;
|
|
created_by: string | null;
|
|
}
|
|
|
|
export interface ShipmentInstructionSource {
|
|
detail_id: number;
|
|
instruction_id: number;
|
|
instruction_no: string;
|
|
instruction_date: string;
|
|
partner_id: string;
|
|
instruction_status: string;
|
|
item_code: string;
|
|
item_name: string;
|
|
spec: string | null;
|
|
material: string | null;
|
|
plan_qty: number;
|
|
ship_qty: number;
|
|
order_qty: number;
|
|
remain_qty: number;
|
|
source_type: string | null;
|
|
unit_price: number;
|
|
}
|
|
|
|
export interface PurchaseOrderSource {
|
|
id: string;
|
|
purchase_no: string;
|
|
order_date: string;
|
|
supplier_code: string;
|
|
supplier_name: string;
|
|
item_code: string;
|
|
item_name: string;
|
|
spec: string | null;
|
|
material: string | null;
|
|
order_qty: number;
|
|
received_qty: number;
|
|
unit_price: number;
|
|
status: string;
|
|
due_date: string | null;
|
|
}
|
|
|
|
export interface ItemSource {
|
|
id: string;
|
|
item_number: string;
|
|
item_name: string;
|
|
spec: string | null;
|
|
material: string | null;
|
|
unit: string | null;
|
|
inventory_unit?: string | null;
|
|
standard_price: number;
|
|
}
|
|
|
|
export interface WarehouseOption {
|
|
warehouse_code: string;
|
|
warehouse_name: string;
|
|
warehouse_type: string;
|
|
}
|
|
|
|
export interface CreateOutboundPayload {
|
|
outbound_number: string;
|
|
outbound_date: string;
|
|
warehouse_code?: string;
|
|
location_code?: string;
|
|
manager_id?: string;
|
|
memo?: string;
|
|
items: Array<{
|
|
outbound_type: string;
|
|
reference_number?: string;
|
|
customer_code?: string;
|
|
customer_name?: string;
|
|
item_code?: string;
|
|
item_number?: string;
|
|
item_name?: string;
|
|
spec?: string;
|
|
specification?: string;
|
|
material?: string;
|
|
unit?: string;
|
|
outbound_qty: number;
|
|
unit_price?: number;
|
|
total_amount?: number;
|
|
lot_number?: string;
|
|
warehouse_code?: string;
|
|
location_code?: string;
|
|
outbound_status?: string;
|
|
manager_id?: string;
|
|
memo?: string;
|
|
source_table?: string;
|
|
source_id?: string;
|
|
destination_code?: string;
|
|
delivery_destination?: string;
|
|
delivery_address?: string;
|
|
}>;
|
|
}
|
|
|
|
// --- API 호출 ---
|
|
|
|
export async function getOutboundList(params?: {
|
|
outbound_type?: string;
|
|
outbound_status?: string;
|
|
search_keyword?: string;
|
|
date_from?: string;
|
|
date_to?: string;
|
|
}) {
|
|
const res = await apiClient.get("/outbound/list", { params });
|
|
return res.data as { success: boolean; data: OutboundItem[] };
|
|
}
|
|
|
|
export async function createOutbound(payload: CreateOutboundPayload) {
|
|
const res = await apiClient.post("/outbound", payload);
|
|
return res.data as { success: boolean; data: OutboundItem[]; message?: string };
|
|
}
|
|
|
|
export async function updateOutbound(id: string, payload: Partial<OutboundItem>) {
|
|
const res = await apiClient.put(`/outbound/${id}`, payload);
|
|
return res.data as { success: boolean; data: OutboundItem };
|
|
}
|
|
|
|
export async function deleteOutbound(id: string) {
|
|
const res = await apiClient.delete(`/outbound/${id}`);
|
|
return res.data as { success: boolean; message?: string };
|
|
}
|
|
|
|
export async function generateOutboundNumber() {
|
|
const res = await apiClient.get("/outbound/generate-number");
|
|
return res.data as { success: boolean; data: string };
|
|
}
|
|
|
|
export async function getOutboundWarehouses() {
|
|
const res = await apiClient.get("/outbound/warehouses");
|
|
return res.data as { success: boolean; data: WarehouseOption[] };
|
|
}
|
|
|
|
export interface LocationOption {
|
|
location_code: string;
|
|
location_name: string;
|
|
warehouse_code: string;
|
|
}
|
|
|
|
export async function getOutboundLocations(warehouseCode?: string) {
|
|
const res = await apiClient.get("/outbound/locations", {
|
|
params: warehouseCode ? { warehouse_code: warehouseCode } : {},
|
|
});
|
|
return res.data as { success: boolean; data: LocationOption[] };
|
|
}
|
|
|
|
// 소스 데이터 조회
|
|
export async function getShipmentInstructionSources(keyword?: string) {
|
|
const res = await apiClient.get("/outbound/source/shipment-instructions", {
|
|
params: keyword ? { keyword } : {},
|
|
});
|
|
return res.data as { success: boolean; data: ShipmentInstructionSource[] };
|
|
}
|
|
|
|
export async function getPurchaseOrderSources(keyword?: string) {
|
|
const res = await apiClient.get("/outbound/source/purchase-orders", {
|
|
params: keyword ? { keyword } : {},
|
|
});
|
|
return res.data as { success: boolean; data: PurchaseOrderSource[] };
|
|
}
|
|
|
|
export async function getItemSources(keyword?: string) {
|
|
const res = await apiClient.get("/outbound/source/items", {
|
|
params: keyword ? { keyword } : {},
|
|
});
|
|
return res.data as { success: boolean; data: ItemSource[] };
|
|
}
|
|
|
|
// --- 거래명세서 API (TASK:ERP-070) ---
|
|
|
|
export interface DeliveryNote {
|
|
id: string;
|
|
company_code: string;
|
|
note_number: string;
|
|
issue_date: string;
|
|
customer_code: string;
|
|
customer_name: string;
|
|
supply_amount: number;
|
|
tax_amount: number;
|
|
total_amount: number;
|
|
issued_by: string;
|
|
issued_by_name: string;
|
|
remark: string | null;
|
|
created_date: string;
|
|
updated_date: string;
|
|
}
|
|
|
|
export interface DeliveryNoteDetail {
|
|
id: string;
|
|
note_id: string;
|
|
outbound_id: string;
|
|
item_code: string;
|
|
item_name: string;
|
|
specification: string;
|
|
unit: string;
|
|
outbound_qty: number;
|
|
unit_price: number;
|
|
supply_amount: number;
|
|
tax_amount: number;
|
|
total_amount: number;
|
|
sort_order: number;
|
|
}
|
|
|
|
export interface DeliveryNoteWithDetails extends DeliveryNote {
|
|
details: DeliveryNoteDetail[];
|
|
outbounds: Array<{
|
|
id: string;
|
|
note_id: string;
|
|
outbound_id: string;
|
|
outbound_number: string;
|
|
outbound_date: string;
|
|
}>;
|
|
}
|
|
|
|
/** 거래명세서 생성 */
|
|
export async function createDeliveryNote(payload: {
|
|
outbound_ids: string[];
|
|
issue_date: string;
|
|
remark?: string;
|
|
}) {
|
|
const res = await apiClient.post("/delivery-note", payload);
|
|
return res.data as {
|
|
success: boolean;
|
|
message?: string;
|
|
data: {
|
|
id: string;
|
|
note_number: string;
|
|
customer_name: string;
|
|
supply_amount: number;
|
|
tax_amount: number;
|
|
total_amount: number;
|
|
};
|
|
};
|
|
}
|
|
|
|
/** 거래명세서 목록 조회 */
|
|
export async function listDeliveryNotes(params?: {
|
|
customer_code?: string;
|
|
date_from?: string;
|
|
date_to?: string;
|
|
search?: string;
|
|
page?: number;
|
|
page_size?: number;
|
|
}) {
|
|
const res = await apiClient.get("/delivery-note", { params });
|
|
return res.data as {
|
|
success: boolean;
|
|
data: DeliveryNote[];
|
|
pagination: { page: number; pageSize: number; total: number; totalPages: number };
|
|
};
|
|
}
|
|
|
|
/** 거래명세서 단건 상세 조회 */
|
|
export async function getDeliveryNoteById(id: string) {
|
|
const res = await apiClient.get(`/delivery-note/${id}`);
|
|
return res.data as { success: boolean; data: DeliveryNoteWithDetails };
|
|
}
|