Open-World: добавить sales-to-stock proxy в бизнес-обзор
This commit is contained in:
@@ -467,6 +467,9 @@ function headlineFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
|
||||
if (overview.inventory_position) {
|
||||
families.push("складской срез на дату");
|
||||
}
|
||||
if (overview.inventory_turnover_proxy) {
|
||||
families.push("оборотный proxy склада");
|
||||
}
|
||||
const unknownFamilies = [overview.trading_margin_proxy ? "чистая прибыль/точная маржа" : "прибыль/маржа"];
|
||||
if (!overview.tax_position) {
|
||||
unknownFamilies.push("НДС");
|
||||
@@ -666,6 +669,7 @@ function buildMustNotClaim(pilot: AssistantMcpDiscoveryPilotExecutionContract):
|
||||
claims.push("Do not present a debt-position snapshot as debt aging, overdue debt, or credit-quality analysis.");
|
||||
claims.push("Do not present open-settlement concentration as contractual due-date aging or confirmed overdue debt.");
|
||||
claims.push("Do not present an inventory snapshot or purchase-date aging signal as turnover, obsolescence, liquidation value, or full inventory health.");
|
||||
claims.push("Do not present business overview inventory turnover proxy as full inventory liquidity, FIFO turnover, obsolescence analysis, or liquidation value.");
|
||||
claims.push("Do not expose business_overview_route_template_v1 or MCP primitive names in the user answer.");
|
||||
}
|
||||
if (pilot.derived_ranked_value_flow) {
|
||||
@@ -1079,6 +1083,18 @@ function derivedBusinessOverviewConfirmedLines(pilot: AssistantMcpDiscoveryPilot
|
||||
);
|
||||
}
|
||||
}
|
||||
if (overview.inventory_turnover_proxy) {
|
||||
const proxy = overview.inventory_turnover_proxy;
|
||||
const ratioText = proxy.sales_to_stock_amount_ratio === null
|
||||
? "не рассчитано"
|
||||
: `${proxy.sales_to_stock_amount_ratio}x`;
|
||||
const stockShareText = proxy.stock_to_sales_revenue_pct === null
|
||||
? "не рассчитана"
|
||||
: `${proxy.stock_to_sales_revenue_pct}%`;
|
||||
lines.push(
|
||||
`Оборотный proxy склада за ${proxy.period_scope}: продажи ${proxy.sales_revenue_human_ru}, остаток на ${proxy.as_of_date} ${proxy.inventory_amount_human_ru}, sales-to-stock ratio ${ratioText}, остаток к продажам ${stockShareText}. Это не полноценная складская ликвидность, не FIFO-оборачиваемость и не анализ устаревания.`
|
||||
);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
@@ -1145,6 +1161,12 @@ function businessOverviewRiskSynthesisLine(overview: BusinessOverview): string |
|
||||
signals.push(`самый старый складской purchase-date сигнал ${overview.inventory_position.aging_signal.max_age_days} дн.`);
|
||||
}
|
||||
}
|
||||
if (overview.inventory_turnover_proxy) {
|
||||
const ratioText = overview.inventory_turnover_proxy.sales_to_stock_amount_ratio === null
|
||||
? "sales-to-stock не рассчитан"
|
||||
: `sales-to-stock ${overview.inventory_turnover_proxy.sales_to_stock_amount_ratio}x`;
|
||||
signals.push(`оборотный proxy склада: ${ratioText}`);
|
||||
}
|
||||
return signals.length > 0
|
||||
? `Риски и контуры внимания по подтвержденным данным: ${signals.join("; ")}.`
|
||||
: null;
|
||||
@@ -1157,7 +1179,8 @@ function businessOverviewExecutiveVerdictLine(overview: BusinessOverview): strin
|
||||
overview.trading_margin_proxy ||
|
||||
overview.debt_position ||
|
||||
overview.debt_open_settlement_quality ||
|
||||
overview.inventory_position
|
||||
overview.inventory_position ||
|
||||
overview.inventory_turnover_proxy
|
||||
);
|
||||
if (!hasCash && !hasExtraSignals) {
|
||||
return null;
|
||||
@@ -1256,6 +1279,9 @@ export function buildAssistantMcpDiscoveryAnswerDraft(
|
||||
if (pilot.derived_business_overview?.inventory_position) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_inventory_position");
|
||||
}
|
||||
if (pilot.derived_business_overview?.inventory_turnover_proxy) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_inventory_turnover_proxy");
|
||||
}
|
||||
const confirmedLines = businessOverviewLines.length > 0
|
||||
? businessOverviewLines
|
||||
: pilot.derived_ranked_value_flow && derivedValueLine
|
||||
|
||||
@@ -156,6 +156,7 @@ export interface AssistantMcpDiscoveryDerivedBusinessOverview {
|
||||
debt_position: AssistantMcpDiscoveryDerivedBusinessOverviewDebtPosition | null;
|
||||
debt_open_settlement_quality: AssistantMcpDiscoveryDerivedBusinessOverviewDebtOpenSettlementQuality | null;
|
||||
inventory_position: AssistantMcpDiscoveryDerivedBusinessOverviewInventoryPosition | null;
|
||||
inventory_turnover_proxy: AssistantMcpDiscoveryDerivedBusinessOverviewInventoryTurnoverProxy | null;
|
||||
coverage_limited_by_probe_limit: boolean;
|
||||
checked_signal_count: number;
|
||||
missing_signal_families: string[];
|
||||
@@ -306,6 +307,18 @@ export interface AssistantMcpDiscoveryDerivedBusinessOverviewInventoryPosition {
|
||||
inference_basis: "inventory_on_hand_confirmed_1c_balance_rows";
|
||||
}
|
||||
|
||||
export interface AssistantMcpDiscoveryDerivedBusinessOverviewInventoryTurnoverProxy {
|
||||
period_scope: string;
|
||||
as_of_date: string;
|
||||
sales_revenue: number;
|
||||
sales_revenue_human_ru: string;
|
||||
inventory_amount: number;
|
||||
inventory_amount_human_ru: string;
|
||||
sales_to_stock_amount_ratio: number | null;
|
||||
stock_to_sales_revenue_pct: number | null;
|
||||
inference_basis: "sales_document_revenue_vs_inventory_balance_confirmed_1c_rows";
|
||||
}
|
||||
|
||||
export interface AssistantMcpDiscoveryDerivedMetadataSurface {
|
||||
metadata_scope: string | null;
|
||||
requested_meta_types: string[];
|
||||
@@ -2918,6 +2931,13 @@ function percentageOfTotal(part: number, total: number): number | null {
|
||||
return Math.round((part / total) * 10_000) / 100;
|
||||
}
|
||||
|
||||
function ratioOfTotal(part: number, total: number): number | null {
|
||||
if (!Number.isFinite(part) || !Number.isFinite(total) || total <= 0) {
|
||||
return null;
|
||||
}
|
||||
return Math.round((part / total) * 100) / 100;
|
||||
}
|
||||
|
||||
function deriveBusinessOverviewDebtOpenSettlementQuality(input: {
|
||||
openContractsResult: AddressMcpQueryExecutorResult | null;
|
||||
debtAsOfDate: string | null;
|
||||
@@ -3208,6 +3228,31 @@ function deriveBusinessOverviewInventoryPosition(input: {
|
||||
};
|
||||
}
|
||||
|
||||
function deriveBusinessOverviewInventoryTurnoverProxy(input: {
|
||||
inventoryPosition: AssistantMcpDiscoveryDerivedBusinessOverviewInventoryPosition | null;
|
||||
tradingMarginProxy: AssistantMcpDiscoveryDerivedBusinessOverviewTradingMarginProxy | null;
|
||||
}): AssistantMcpDiscoveryDerivedBusinessOverviewInventoryTurnoverProxy | null {
|
||||
const { inventoryPosition, tradingMarginProxy } = input;
|
||||
if (!inventoryPosition || !tradingMarginProxy) {
|
||||
return null;
|
||||
}
|
||||
if (inventoryPosition.total_amount <= 0 || tradingMarginProxy.sales_revenue <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
period_scope: tradingMarginProxy.period_scope,
|
||||
as_of_date: inventoryPosition.as_of_date,
|
||||
sales_revenue: tradingMarginProxy.sales_revenue,
|
||||
sales_revenue_human_ru: tradingMarginProxy.sales_revenue_human_ru,
|
||||
inventory_amount: inventoryPosition.total_amount,
|
||||
inventory_amount_human_ru: inventoryPosition.total_amount_human_ru,
|
||||
sales_to_stock_amount_ratio: ratioOfTotal(tradingMarginProxy.sales_revenue, inventoryPosition.total_amount),
|
||||
stock_to_sales_revenue_pct: percentageOfTotal(inventoryPosition.total_amount, tradingMarginProxy.sales_revenue),
|
||||
inference_basis: "sales_document_revenue_vs_inventory_balance_confirmed_1c_rows"
|
||||
};
|
||||
}
|
||||
|
||||
function deriveBusinessOverview(input: {
|
||||
incomingResult: AssistantMcpDiscoveryCoverageAwareQueryResult | null;
|
||||
outgoingResult: AssistantMcpDiscoveryCoverageAwareQueryResult | null;
|
||||
@@ -3249,6 +3294,10 @@ function deriveBusinessOverview(input: {
|
||||
inventoryAgingResult: input.inventoryAgingResult,
|
||||
inventoryAsOfDate: input.inventoryAsOfDate
|
||||
});
|
||||
const inventoryTurnoverProxy = deriveBusinessOverviewInventoryTurnoverProxy({
|
||||
inventoryPosition,
|
||||
tradingMarginProxy
|
||||
});
|
||||
const checkedSignalCount = [
|
||||
incoming.rows_with_amount > 0,
|
||||
outgoing.rows_with_amount > 0,
|
||||
@@ -3257,7 +3306,8 @@ function deriveBusinessOverview(input: {
|
||||
Boolean(tradingMarginProxy),
|
||||
Boolean(debtPosition),
|
||||
Boolean(debtOpenSettlementQuality),
|
||||
Boolean(inventoryPosition)
|
||||
Boolean(inventoryPosition),
|
||||
Boolean(inventoryTurnoverProxy)
|
||||
].filter(Boolean).length;
|
||||
if (checkedSignalCount <= 0) {
|
||||
return null;
|
||||
@@ -3279,6 +3329,7 @@ function deriveBusinessOverview(input: {
|
||||
debt_position: debtPosition,
|
||||
debt_open_settlement_quality: debtOpenSettlementQuality,
|
||||
inventory_position: inventoryPosition,
|
||||
inventory_turnover_proxy: inventoryTurnoverProxy,
|
||||
coverage_limited_by_probe_limit:
|
||||
incoming.coverage_limited_by_probe_limit || outgoing.coverage_limited_by_probe_limit,
|
||||
checked_signal_count: checkedSignalCount,
|
||||
@@ -3287,7 +3338,7 @@ function deriveBusinessOverview(input: {
|
||||
debtPosition ? null : "debt_position",
|
||||
debtOpenSettlementQuality ? "debt_due_date_aging_quality" : "debt_open_settlement_quality",
|
||||
taxPosition ? null : "tax_position",
|
||||
inventoryPosition ? "inventory_turnover_quality" : "inventory_position",
|
||||
inventoryPosition ? (inventoryTurnoverProxy ? "inventory_liquidity_quality" : "inventory_turnover_quality") : "inventory_position",
|
||||
inventoryPosition?.aging_signal ? null : "inventory_aging_quality"
|
||||
].filter((item): item is string => Boolean(item)),
|
||||
inference_basis:
|
||||
@@ -3446,6 +3497,18 @@ function buildBusinessOverviewConfirmedFacts(derived: AssistantMcpDiscoveryDeriv
|
||||
);
|
||||
}
|
||||
}
|
||||
if (derived.inventory_turnover_proxy) {
|
||||
const proxy = derived.inventory_turnover_proxy;
|
||||
const ratioText = proxy.sales_to_stock_amount_ratio === null
|
||||
? "не рассчитано"
|
||||
: `${proxy.sales_to_stock_amount_ratio}x`;
|
||||
const stockShareText = proxy.stock_to_sales_revenue_pct === null
|
||||
? "не рассчитана"
|
||||
: `${proxy.stock_to_sales_revenue_pct}%`;
|
||||
facts.push(
|
||||
`Оборотный proxy склада за ${proxy.period_scope} подтвержден по продажным документам и складскому остатку: продажи ${proxy.sales_revenue_human_ru}, остаток на ${proxy.as_of_date} ${proxy.inventory_amount_human_ru}, sales-to-stock ratio ${ratioText}, остаток к продажам ${stockShareText}. Это не полноценная складская ликвидность, не FIFO-оборачиваемость и не анализ устаревания.`
|
||||
);
|
||||
}
|
||||
return facts;
|
||||
}
|
||||
|
||||
@@ -3505,8 +3568,7 @@ function buildBusinessOverviewUnknownFacts(derived: AssistantMcpDiscoveryDerived
|
||||
: null,
|
||||
missing.has("inventory_health")
|
||||
? "Складская ликвидность и товарные остатки этим бизнес-обзором не подтверждены: нужен отдельный inventory-срез."
|
||||
: null
|
||||
,
|
||||
: null,
|
||||
missing.has("inventory_position")
|
||||
? "Складской остаток этим бизнес-обзором не подтвержден: нужен отдельный inventory-срез на явную дату."
|
||||
: null,
|
||||
@@ -3515,6 +3577,9 @@ function buildBusinessOverviewUnknownFacts(derived: AssistantMcpDiscoveryDerived
|
||||
: null,
|
||||
missing.has("inventory_turnover_quality")
|
||||
? "Скорость продаж, оборачиваемость и ликвидность склада этим бизнес-обзором не подтверждены: нужен отдельный inventory/продажный анализ, а не только остаток на дату."
|
||||
: null,
|
||||
missing.has("inventory_liquidity_quality")
|
||||
? "Полная складская ликвидность этим бизнес-обзором не подтверждена: sales-to-stock proxy показывает только соотношение продажных документов и остатка на дату, без FIFO-оборачиваемости, устаревания, резервов и ликвидационной стоимости."
|
||||
: null
|
||||
].filter((item): item is string => Boolean(item));
|
||||
if (derived?.coverage_limited_by_probe_limit) {
|
||||
@@ -4581,6 +4646,9 @@ export async function executeAssistantMcpDiscoveryPilot(
|
||||
if (derivedBusinessOverview.inventory_position) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_inventory_position_from_confirmed_rows");
|
||||
}
|
||||
if (derivedBusinessOverview.inventory_turnover_proxy) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_inventory_turnover_proxy_from_confirmed_rows");
|
||||
}
|
||||
}
|
||||
const sourceRowsSummary = summarizeBusinessOverviewRows({
|
||||
incomingResult,
|
||||
|
||||
Reference in New Issue
Block a user