Open-World: добавить debt staleness risk proxy в бизнес-обзор
This commit is contained in:
+33
-1
@@ -411,6 +411,9 @@ function headlineFor(mode, pilot) {
|
||||
families.push("возрастной сигнал открытых расчетов");
|
||||
}
|
||||
}
|
||||
if (overview.debt_staleness_risk_proxy) {
|
||||
families.push("staleness risk proxy открытых расчетов");
|
||||
}
|
||||
if (overview.inventory_position) {
|
||||
families.push("складской срез на дату");
|
||||
}
|
||||
@@ -427,7 +430,11 @@ function headlineFor(mode, pilot) {
|
||||
if (!overview.debt_position) {
|
||||
unknownFamilies.push("долговой срез");
|
||||
}
|
||||
unknownFamilies.push(overview.debt_open_settlement_quality ? "due-date просрочка" : "качество открытых расчетов");
|
||||
unknownFamilies.push(overview.debt_staleness_risk_proxy
|
||||
? "договорные сроки оплаты/due-date просрочка"
|
||||
: overview.debt_open_settlement_quality
|
||||
? "due-date просрочка"
|
||||
: "качество открытых расчетов");
|
||||
unknownFamilies.push(businessOverviewInventoryUnknownLabel(overview));
|
||||
return `По данным 1С собран ограниченный бизнес-обзор: ${families.join(", ")} подтверждены найденными строками; ${unknownFamilies.join(", ")} остаются отдельными непроверенными областями.`;
|
||||
}
|
||||
@@ -612,6 +619,7 @@ function buildMustNotClaim(pilot) {
|
||||
claims.push("Do not claim debt quality, VAT position, inventory health, or company health unless those contours were separately checked.");
|
||||
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 business overview debt staleness risk proxy as confirmed overdue debt, contractual delinquency, credit risk, or due-date aging.");
|
||||
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 present business overview inventory staleness risk proxy as confirmed obsolete stock, reserve, write-off, or liquidation value.");
|
||||
@@ -912,6 +920,18 @@ function inventoryStalenessRiskBandRu(riskBand) {
|
||||
}
|
||||
return "низкий видимый риск";
|
||||
}
|
||||
function debtStalenessRiskBandRu(riskBand) {
|
||||
if (riskBand === "high") {
|
||||
return "высокая зона внимания";
|
||||
}
|
||||
if (riskBand === "elevated") {
|
||||
return "повышенная зона внимания";
|
||||
}
|
||||
if (riskBand === "watch") {
|
||||
return "зона наблюдения";
|
||||
}
|
||||
return "низкий видимый риск";
|
||||
}
|
||||
function derivedBusinessOverviewConfirmedLines(pilot) {
|
||||
const overview = pilot.derived_business_overview;
|
||||
if (!overview) {
|
||||
@@ -968,6 +988,11 @@ function derivedBusinessOverviewConfirmedLines(pilot) {
|
||||
lines.push(`Возрастной сигнал открытых расчетов: самая ранняя найденная дата договора ${quality.age_signal.oldest_start_date}${ageText}. Это не просрочка и не due-date анализ.`);
|
||||
}
|
||||
}
|
||||
if (overview.debt_staleness_risk_proxy) {
|
||||
const proxy = overview.debt_staleness_risk_proxy;
|
||||
const counterpartyText = proxy.top_contract_counterparty ? ` / ${proxy.top_contract_counterparty}` : "";
|
||||
lines.push(`Staleness risk proxy открытых расчетов на ${proxy.as_of_date}: самый старый договорный сигнал ${proxy.oldest_contract_start_date}, возраст ${proxy.max_contract_age_days} дн.; старейший крупный договор ${proxy.top_contract}${counterpartyText} держит ${proxy.top_contract_amount_human_ru} (${proxy.top_contract_share_pct}% брутто открытых остатков); оценка ${debtStalenessRiskBandRu(proxy.risk_band)}. Это не подтвержденная просрочка, не кредитный риск и не due-date aging.`);
|
||||
}
|
||||
if (overview.inventory_position) {
|
||||
const leader = overview.inventory_position.top_items[0];
|
||||
const leaderText = leader
|
||||
@@ -1050,6 +1075,9 @@ function businessOverviewRiskSynthesisLine(overview) {
|
||||
if (overview.debt_open_settlement_quality?.age_signal?.max_age_days !== null && overview.debt_open_settlement_quality?.age_signal?.max_age_days !== undefined) {
|
||||
signals.push(`самый старый договорный возрастной сигнал ${overview.debt_open_settlement_quality.age_signal.max_age_days} дн.`);
|
||||
}
|
||||
if (overview.debt_staleness_risk_proxy) {
|
||||
signals.push(`staleness risk proxy открытых расчетов: ${debtStalenessRiskBandRu(overview.debt_staleness_risk_proxy.risk_band)}, возраст ${overview.debt_staleness_risk_proxy.max_contract_age_days} дн., концентрация старейшего крупного договора ${overview.debt_staleness_risk_proxy.top_contract_share_pct}%`);
|
||||
}
|
||||
if (overview.inventory_position) {
|
||||
signals.push(`складской остаток на дату ${overview.inventory_position.total_amount_human_ru}`);
|
||||
if (overview.inventory_position.aging_signal?.max_age_days !== null && overview.inventory_position.aging_signal?.max_age_days !== undefined) {
|
||||
@@ -1075,6 +1103,7 @@ function businessOverviewExecutiveVerdictLine(overview) {
|
||||
overview.trading_margin_proxy ||
|
||||
overview.debt_position ||
|
||||
overview.debt_open_settlement_quality ||
|
||||
overview.debt_staleness_risk_proxy ||
|
||||
overview.inventory_position ||
|
||||
overview.inventory_turnover_proxy ||
|
||||
overview.inventory_staleness_risk_proxy);
|
||||
@@ -1163,6 +1192,9 @@ function buildAssistantMcpDiscoveryAnswerDraft(pilot) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_debt_age_signal");
|
||||
}
|
||||
}
|
||||
if (pilot.derived_business_overview?.debt_staleness_risk_proxy) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_debt_staleness_risk_proxy");
|
||||
}
|
||||
if (pilot.derived_business_overview?.inventory_position) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_inventory_position");
|
||||
}
|
||||
|
||||
@@ -2298,6 +2298,61 @@ function deriveBusinessOverviewDebtOpenSettlementQuality(input) {
|
||||
inference_basis: "open_contracts_confirmed_1c_balance_rows"
|
||||
};
|
||||
}
|
||||
function debtStalenessRiskBand(input) {
|
||||
if (input.maxContractAgeDays >= 365 && input.topContractSharePct >= 50) {
|
||||
return "high";
|
||||
}
|
||||
if (input.maxContractAgeDays >= 365 || input.topContractSharePct >= 50) {
|
||||
return "elevated";
|
||||
}
|
||||
if (input.maxContractAgeDays >= 180 || input.topContractSharePct >= 35) {
|
||||
return "watch";
|
||||
}
|
||||
return "lower_visible_risk";
|
||||
}
|
||||
function deriveBusinessOverviewDebtStalenessRiskProxy(quality) {
|
||||
const ageSignal = quality?.age_signal;
|
||||
const topAgedContract = ageSignal?.top_aged_contracts[0];
|
||||
const topContractSharePct = topAgedContract?.share_of_gross_open_amount_pct;
|
||||
if (!quality ||
|
||||
!ageSignal?.oldest_start_date ||
|
||||
ageSignal.max_age_days === null ||
|
||||
ageSignal.max_age_days === undefined ||
|
||||
!topAgedContract ||
|
||||
topContractSharePct === null ||
|
||||
topContractSharePct === undefined) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
as_of_date: quality.as_of_date,
|
||||
gross_open_amount: quality.gross_open_amount,
|
||||
gross_open_amount_human_ru: quality.gross_open_amount_human_ru,
|
||||
oldest_contract_start_date: ageSignal.oldest_start_date,
|
||||
max_contract_age_days: ageSignal.max_age_days,
|
||||
top_contract: topAgedContract.contract,
|
||||
top_contract_counterparty: topAgedContract.counterparty,
|
||||
top_contract_amount: topAgedContract.total_amount,
|
||||
top_contract_amount_human_ru: topAgedContract.total_amount_human_ru,
|
||||
top_contract_share_pct: topContractSharePct,
|
||||
risk_band: debtStalenessRiskBand({
|
||||
maxContractAgeDays: ageSignal.max_age_days,
|
||||
topContractSharePct
|
||||
}),
|
||||
inference_basis: "contract_date_age_and_open_balance_concentration_confirmed_1c_rows"
|
||||
};
|
||||
}
|
||||
function debtStalenessRiskBandRu(riskBand) {
|
||||
if (riskBand === "high") {
|
||||
return "высокая зона внимания";
|
||||
}
|
||||
if (riskBand === "elevated") {
|
||||
return "повышенная зона внимания";
|
||||
}
|
||||
if (riskBand === "watch") {
|
||||
return "зона наблюдения";
|
||||
}
|
||||
return "низкий видимый риск";
|
||||
}
|
||||
function daysBetweenIsoDates(leftIsoDate, rightIsoDate) {
|
||||
const leftMatch = leftIsoDate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
const rightMatch = rightIsoDate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
@@ -2493,6 +2548,7 @@ function deriveBusinessOverview(input) {
|
||||
openContractsResult: input.openContractsResult,
|
||||
debtAsOfDate: input.debtAsOfDate
|
||||
});
|
||||
const debtStalenessRiskProxy = deriveBusinessOverviewDebtStalenessRiskProxy(debtOpenSettlementQuality);
|
||||
const inventoryPosition = deriveBusinessOverviewInventoryPosition({
|
||||
inventoryOnHandResult: input.inventoryOnHandResult,
|
||||
inventoryAgingResult: input.inventoryAgingResult,
|
||||
@@ -2514,6 +2570,7 @@ function deriveBusinessOverview(input) {
|
||||
Boolean(tradingMarginProxy),
|
||||
Boolean(debtPosition),
|
||||
Boolean(debtOpenSettlementQuality),
|
||||
Boolean(debtStalenessRiskProxy),
|
||||
Boolean(inventoryPosition),
|
||||
Boolean(inventoryTurnoverProxy),
|
||||
Boolean(inventoryStalenessRiskProxy)
|
||||
@@ -2536,6 +2593,7 @@ function deriveBusinessOverview(input) {
|
||||
trading_margin_proxy: tradingMarginProxy,
|
||||
debt_position: debtPosition,
|
||||
debt_open_settlement_quality: debtOpenSettlementQuality,
|
||||
debt_staleness_risk_proxy: debtStalenessRiskProxy,
|
||||
inventory_position: inventoryPosition,
|
||||
inventory_turnover_proxy: inventoryTurnoverProxy,
|
||||
inventory_staleness_risk_proxy: inventoryStalenessRiskProxy,
|
||||
@@ -2660,6 +2718,11 @@ function buildBusinessOverviewConfirmedFacts(derived) {
|
||||
facts.push(`Возрастной сигнал открытых расчетов подтвержден по датам договоров: самая ранняя дата договора ${quality.age_signal.oldest_start_date}${ageText}. Это не договорная просрочка и не due-date анализ.`);
|
||||
}
|
||||
}
|
||||
if (derived.debt_staleness_risk_proxy) {
|
||||
const proxy = derived.debt_staleness_risk_proxy;
|
||||
const counterpartyText = proxy.top_contract_counterparty ? ` / ${proxy.top_contract_counterparty}` : "";
|
||||
facts.push(`Staleness risk proxy открытых расчетов на ${proxy.as_of_date}: самый старый договорный сигнал ${proxy.oldest_contract_start_date}, возраст ${proxy.max_contract_age_days} дн.; старейший крупный договор ${proxy.top_contract}${counterpartyText} держит ${proxy.top_contract_amount_human_ru} (${proxy.top_contract_share_pct}% брутто открытых остатков); оценка ${debtStalenessRiskBandRu(proxy.risk_band)}. Это не подтвержденная просрочка, не кредитный риск и не due-date aging.`);
|
||||
}
|
||||
if (derived.inventory_position) {
|
||||
const leader = derived.inventory_position.top_items[0];
|
||||
const leaderText = leader
|
||||
@@ -3704,6 +3767,9 @@ async function executeAssistantMcpDiscoveryPilot(planner, deps = DEFAULT_DEPS) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_debt_age_signal_from_contract_dates");
|
||||
}
|
||||
}
|
||||
if (derivedBusinessOverview.debt_staleness_risk_proxy) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_debt_staleness_risk_proxy_from_confirmed_rows");
|
||||
}
|
||||
if (derivedBusinessOverview.inventory_position) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_inventory_position_from_confirmed_rows");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user