Архитектура: централизовать inventory pivot flags и carryover target intent в continuity policy
This commit is contained in:
@@ -369,6 +369,93 @@ export function buildRootScopedCarryoverFilters(
|
||||
return nextFilters;
|
||||
}
|
||||
|
||||
export function resolveInventoryFollowupPivotFlags(
|
||||
inventoryRootFrame:
|
||||
| {
|
||||
intent?: unknown;
|
||||
}
|
||||
| null
|
||||
| undefined,
|
||||
sourceIntentHint: string | null,
|
||||
currentFrameKind: string | null,
|
||||
hasForeignAccountingPivotMessage: boolean,
|
||||
inventoryPurchaseDateVatBridge: boolean,
|
||||
hasInventoryRootTemporalFollowupPrimary: boolean,
|
||||
hasInventoryRootTemporalFollowupAlternate: boolean,
|
||||
hasInventoryRootRestatementPrimary: boolean,
|
||||
hasInventoryRootRestatementAlternate: boolean,
|
||||
hasExplicitInventorySameDatePivotPrimary: boolean,
|
||||
hasExplicitInventorySameDatePivotAlternate: boolean,
|
||||
isInventorySelectedObjectIntent: (intent: unknown) => boolean,
|
||||
isInventoryRootFrameIntent: (intent: unknown) => boolean
|
||||
): {
|
||||
rootScopedPivot: boolean;
|
||||
explicitInventorySameDatePivot: boolean;
|
||||
} {
|
||||
const rootContextOnlyPivot = Boolean(
|
||||
(isInventorySelectedObjectIntent(sourceIntentHint) || currentFrameKind === "inventory_drilldown") &&
|
||||
hasForeignAccountingPivotMessage &&
|
||||
!inventoryPurchaseDateVatBridge
|
||||
);
|
||||
const inventoryRootTemporalPivot = Boolean(
|
||||
inventoryRootFrame &&
|
||||
(isInventorySelectedObjectIntent(sourceIntentHint) ||
|
||||
isInventoryRootFrameIntent(sourceIntentHint) ||
|
||||
currentFrameKind === "inventory_drilldown" ||
|
||||
currentFrameKind === "inventory_root") &&
|
||||
(hasInventoryRootTemporalFollowupPrimary || hasInventoryRootTemporalFollowupAlternate) &&
|
||||
!hasForeignAccountingPivotMessage
|
||||
);
|
||||
const inventoryRootRestatementPivot = Boolean(
|
||||
inventoryRootFrame &&
|
||||
(isInventorySelectedObjectIntent(sourceIntentHint) ||
|
||||
isInventoryRootFrameIntent(sourceIntentHint) ||
|
||||
currentFrameKind === "inventory_drilldown" ||
|
||||
currentFrameKind === "inventory_root" ||
|
||||
currentFrameKind === "generic") &&
|
||||
(hasInventoryRootRestatementPrimary || hasInventoryRootRestatementAlternate) &&
|
||||
!hasForeignAccountingPivotMessage
|
||||
);
|
||||
const explicitInventorySameDatePivot = Boolean(
|
||||
!inventoryRootFrame &&
|
||||
(hasExplicitInventorySameDatePivotPrimary || hasExplicitInventorySameDatePivotAlternate) &&
|
||||
!hasForeignAccountingPivotMessage
|
||||
);
|
||||
return {
|
||||
rootScopedPivot: rootContextOnlyPivot || inventoryRootTemporalPivot || inventoryRootRestatementPivot,
|
||||
explicitInventorySameDatePivot
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveFollowupTargetIntent(
|
||||
inventoryPurchaseDateVatBridge: boolean,
|
||||
selectedObjectRetargetIntent: string | null,
|
||||
explicitIntent: string | null,
|
||||
sourceIntent: string | null,
|
||||
followupSelectionMode: string | null,
|
||||
inventoryRootFrameIntent: string | null,
|
||||
displayedEntityTargetIntent: string | null,
|
||||
previousIntent: string | null,
|
||||
explicitInventorySameDatePivot: boolean
|
||||
): string | undefined {
|
||||
if (inventoryPurchaseDateVatBridge) {
|
||||
return "vat_liability_confirmed_for_tax_period";
|
||||
}
|
||||
if (
|
||||
selectedObjectRetargetIntent &&
|
||||
(explicitIntent === null || explicitIntent === "inventory_on_hand_as_of_date" || explicitIntent === sourceIntent)
|
||||
) {
|
||||
return selectedObjectRetargetIntent;
|
||||
}
|
||||
if (followupSelectionMode === "carry_root_context") {
|
||||
return inventoryRootFrameIntent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined;
|
||||
}
|
||||
if (explicitInventorySameDatePivot) {
|
||||
return "inventory_on_hand_as_of_date";
|
||||
}
|
||||
return displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined;
|
||||
}
|
||||
|
||||
export function shouldUseNavigationTemporalCarryover(sourceIntentHint: unknown): boolean {
|
||||
const normalizedIntent = fallbackToNonEmptyString(sourceIntentHint);
|
||||
return (
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
resolveAddressDebugCarryoverFilters,
|
||||
resolveAddressDebugAnchorContext,
|
||||
resolveDisplayedEntityFollowupRetarget,
|
||||
resolveFollowupTargetIntent,
|
||||
resolveInventoryFollowupPivotFlags,
|
||||
resolveAssistantOrganizationAuthority
|
||||
} from "./assistantContinuityPolicy";
|
||||
|
||||
@@ -773,36 +775,21 @@ export function createAssistantTransitionPolicy(deps) {
|
||||
sourceIntentHint,
|
||||
deps.toNonEmptyString
|
||||
);
|
||||
const rootContextOnlyPivot = Boolean(
|
||||
(deps.isInventorySelectedObjectIntent(sourceIntentHint) || currentFrameKind === "inventory_drilldown") &&
|
||||
deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage) &&
|
||||
!inventoryPurchaseDateVatBridge
|
||||
const { rootScopedPivot, explicitInventorySameDatePivot } = resolveInventoryFollowupPivotFlags(
|
||||
inventoryRootFrame,
|
||||
sourceIntentHint,
|
||||
currentFrameKind,
|
||||
deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage),
|
||||
inventoryPurchaseDateVatBridge,
|
||||
hasInventoryRootTemporalFollowupPrimary,
|
||||
hasInventoryRootTemporalFollowupAlternate,
|
||||
hasInventoryRootRestatementPrimary,
|
||||
hasInventoryRootRestatementAlternate,
|
||||
hasExplicitInventorySameDatePivotPrimary,
|
||||
hasExplicitInventorySameDatePivotAlternate,
|
||||
deps.isInventorySelectedObjectIntent,
|
||||
deps.isInventoryRootFrameIntent
|
||||
);
|
||||
const inventoryRootTemporalPivot = Boolean(
|
||||
inventoryRootFrame &&
|
||||
(deps.isInventorySelectedObjectIntent(sourceIntentHint) ||
|
||||
deps.isInventoryRootFrameIntent(sourceIntentHint) ||
|
||||
currentFrameKind === "inventory_drilldown" ||
|
||||
currentFrameKind === "inventory_root") &&
|
||||
(hasInventoryRootTemporalFollowupPrimary || hasInventoryRootTemporalFollowupAlternate) &&
|
||||
!deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage)
|
||||
);
|
||||
const inventoryRootRestatementPivot = Boolean(
|
||||
inventoryRootFrame &&
|
||||
(deps.isInventorySelectedObjectIntent(sourceIntentHint) ||
|
||||
deps.isInventoryRootFrameIntent(sourceIntentHint) ||
|
||||
currentFrameKind === "inventory_drilldown" ||
|
||||
currentFrameKind === "inventory_root" ||
|
||||
currentFrameKind === "generic") &&
|
||||
(hasInventoryRootRestatementPrimary || hasInventoryRootRestatementAlternate) &&
|
||||
!deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage)
|
||||
);
|
||||
const explicitInventorySameDatePivot = Boolean(
|
||||
!inventoryRootFrame &&
|
||||
(hasExplicitInventorySameDatePivotPrimary || hasExplicitInventorySameDatePivotAlternate) &&
|
||||
!deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage)
|
||||
);
|
||||
const rootScopedPivot = rootContextOnlyPivot || inventoryRootTemporalPivot || inventoryRootRestatementPivot;
|
||||
if (rootScopedPivot) {
|
||||
previousIntent = null;
|
||||
previousAnchorType = null;
|
||||
@@ -899,19 +886,17 @@ export function createAssistantTransitionPolicy(deps) {
|
||||
hasSelectedObjectInventorySignalPrimary ||
|
||||
hasSelectedObjectInventorySignalAlternate)
|
||||
);
|
||||
const carryoverTargetIntent =
|
||||
inventoryPurchaseDateVatBridge
|
||||
? "vat_liability_confirmed_for_tax_period"
|
||||
: selectedObjectRetargetIntent &&
|
||||
(explicitIntent === null ||
|
||||
explicitIntent === "inventory_on_hand_as_of_date" ||
|
||||
explicitIntent === sourceIntent)
|
||||
? selectedObjectRetargetIntent
|
||||
: followupSelectionMode === "carry_root_context"
|
||||
? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined
|
||||
: explicitInventorySameDatePivot
|
||||
? "inventory_on_hand_as_of_date"
|
||||
: displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined;
|
||||
const carryoverTargetIntent = resolveFollowupTargetIntent(
|
||||
inventoryPurchaseDateVatBridge,
|
||||
selectedObjectRetargetIntent,
|
||||
explicitIntent,
|
||||
sourceIntent,
|
||||
followupSelectionMode,
|
||||
deps.toNonEmptyString(inventoryRootFrame?.intent),
|
||||
displayedEntityTargetIntent,
|
||||
previousIntent,
|
||||
explicitInventorySameDatePivot
|
||||
);
|
||||
return {
|
||||
followupContext: {
|
||||
previous_intent: previousIntent ?? undefined,
|
||||
|
||||
Reference in New Issue
Block a user