feat(P19ERP2-3,P19ERP2-4): 新增采购ERP轨道接口与详情挂件
这个提交包含在:
@@ -111,6 +111,78 @@ export type PurchaseOrderArchive = {
|
||||
archivedFiles: PurchaseArchivedFile[];
|
||||
};
|
||||
|
||||
export type PurchaseErpTrackStatus =
|
||||
| "not_triggered"
|
||||
| "pending"
|
||||
| "processing"
|
||||
| "succeeded"
|
||||
| "failed"
|
||||
| "dead_letter"
|
||||
| "skipped";
|
||||
|
||||
export type PurchaseErpBinding = {
|
||||
id: string;
|
||||
provider: string;
|
||||
entityType: string;
|
||||
localId: string;
|
||||
externalId: string | null;
|
||||
externalCode: string | null;
|
||||
lastSyncedAt: string | null;
|
||||
};
|
||||
|
||||
export type PurchaseErpOutbox = {
|
||||
id: string;
|
||||
eventType: string;
|
||||
status: string;
|
||||
attempts: number;
|
||||
lastError: string | null;
|
||||
processedAt: string | null;
|
||||
updatedAt: string | null;
|
||||
};
|
||||
|
||||
export type PurchaseErpTrackStage = {
|
||||
eligible: boolean;
|
||||
reason: string | null;
|
||||
status: PurchaseErpTrackStatus | string;
|
||||
preview: Record<string, unknown>;
|
||||
outbox: PurchaseErpOutbox | null;
|
||||
binding?: PurchaseErpBinding | null;
|
||||
bindings?: {
|
||||
po: PurchaseErpBinding | null;
|
||||
contract: PurchaseErpBinding | null;
|
||||
};
|
||||
};
|
||||
|
||||
export type PurchaseRequestErpTrack = {
|
||||
purchaseRequest: {
|
||||
id: string;
|
||||
requestNo: string | null;
|
||||
status: string;
|
||||
totalAmount: string;
|
||||
supplier: {
|
||||
id: string;
|
||||
code: string | null;
|
||||
name: string | null;
|
||||
} | null;
|
||||
archiveOrder: {
|
||||
id: string;
|
||||
poNo: string;
|
||||
contractNo: string | null;
|
||||
archivedAt: string | null;
|
||||
} | null;
|
||||
};
|
||||
stages: {
|
||||
commitmentJournal: PurchaseErpTrackStage;
|
||||
accrualJournal: PurchaseErpTrackStage;
|
||||
archiveSummary: PurchaseErpTrackStage;
|
||||
};
|
||||
permissions: {
|
||||
canRetry: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export type PurchaseRequestErpRequeueTarget = "commitment_journal" | "accrual_journal" | "archive_summary";
|
||||
|
||||
export type PurchaseRequestDetail = PurchaseRequestSummary & {
|
||||
items: PurchaseRequestItem[];
|
||||
attachments: PurchaseAttachment[];
|
||||
@@ -290,3 +362,34 @@ export async function issuePurchaseAttachmentSignedUrl(purchaseRequestId: string
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchPurchaseRequestErpTrack(purchaseRequestId: string) {
|
||||
return apiRequestData<PurchaseRequestErpTrack>(
|
||||
`/api/integrations/erp/procurement/purchase-requests/${purchaseRequestId}/track`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function requeuePurchaseRequestErpSync(
|
||||
purchaseRequestId: string,
|
||||
payload: {
|
||||
targets: PurchaseRequestErpRequeueTarget[];
|
||||
},
|
||||
runNow = true,
|
||||
) {
|
||||
return apiRequestData<{
|
||||
items: Array<{
|
||||
target: PurchaseRequestErpRequeueTarget;
|
||||
outboxId: string;
|
||||
status: string;
|
||||
duplicated: boolean;
|
||||
requeued: boolean;
|
||||
eventType: string;
|
||||
}>;
|
||||
}>(
|
||||
`/api/integrations/erp/procurement/purchase-requests/${purchaseRequestId}/requeue${toQueryString({ runNow })}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户