Сделать денежные итоги amount-first в 1С

This commit is contained in:
2026-05-23 20:38:57 +03:00
parent b2fe0460b3
commit 847a32ba4c
4 changed files with 61 additions and 17 deletions
@@ -56,6 +56,10 @@ function uniqueStrings(values: string[]): string[] {
return result;
}
function trimTrailingSentenceDot(value: string): string {
return value.trim().replace(/[.]+$/u, "");
}
function formatNamedChoiceList(values: string[]): string {
return uniqueStrings(values)
.slice(0, 6)
@@ -990,10 +994,7 @@ function headlineFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
return "По данным 1С найдены строки входящих и исходящих денежных движений; нетто можно называть только как расчет по найденным строкам и проверенному периоду.";
}
if (pilot.derived_value_flow && mode === "confirmed_with_bounded_inference") {
if (pilot.derived_value_flow.value_flow_direction === "outgoing_supplier_payout") {
return "По данным 1С найдены строки исходящих платежей/списаний; сумму можно называть только в рамках проверенного периода и найденных строк.";
}
return "По данным 1С найдены строки входящих денежных поступлений; сумму можно называть только в рамках проверенного периода и найденных строк.";
return derivedValueFlowHeadlineLine(pilot) ?? "По данным 1С найдены денежные строки; сумму можно называть только в рамках проверенного периода и найденных строк.";
}
const zeroValueFlowHeadline = valueFlowZeroResultHeadline(pilot);
if (mode === "checked_sources_only" && zeroValueFlowHeadline) {
@@ -1383,6 +1384,22 @@ function derivedRankedValueFlowConfirmedLine(pilot: AssistantMcpDiscoveryPilotEx
return `${directionLead} ${leader.axis_value}${organization}${period}: ${leader.total_amount_human_ru} по ${leader.rows_with_amount} строкам с суммой.${roleCaveat}${trail}${limitCaveat}`;
}
function derivedValueFlowHeadlineLine(pilot: AssistantMcpDiscoveryPilotExecutionContract): string | null {
const flow = pilot.derived_value_flow;
if (!flow) {
return null;
}
const organizationScope = explicitOrganizationScope(pilot);
const organization = organizationScope ? ` по организации ${organizationScope}` : "";
const counterparty = flow.counterparty ? ` по контрагенту ${flow.counterparty}` : "";
const period = flow.period_scope ? ` за период ${flow.period_scope}` : " в проверенном окне";
const totalLabel =
flow.value_flow_direction === "outgoing_supplier_payout"
? "Исходящие платежи/списания"
: "Входящие денежные поступления";
return `${totalLabel}${counterparty || organization}${period}: ${trimTrailingSentenceDot(flow.total_amount_human_ru)}.`;
}
function derivedValueFlowConfirmedLine(pilot: AssistantMcpDiscoveryPilotExecutionContract): string | null {
const flow = pilot.derived_value_flow;
if (!flow) {
@@ -1403,7 +1420,7 @@ function derivedValueFlowConfirmedLine(pilot: AssistantMcpDiscoveryPilotExecutio
const limitCaveat = flow.coverage_limited_by_probe_limit
? " Проверка уперлась в лимит строк, поэтому полный период может быть покрыт не полностью."
: "";
return `${totalLabel}${counterparty || organization}${period}: ${flow.total_amount_human_ru}.${limitCaveat} ${caveat}`;
return `${totalLabel}${counterparty || organization}${period}: ${trimTrailingSentenceDot(flow.total_amount_human_ru)}.${limitCaveat} ${caveat}`;
}
function derivedValueFlowMonthlyLines(pilot: AssistantMcpDiscoveryPilotExecutionContract): string[] {