Сделать денежные итоги amount-first в 1С
This commit is contained in:
+19
-5
@@ -28,6 +28,9 @@ function uniqueStrings(values) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function trimTrailingSentenceDot(value) {
|
||||
return value.trim().replace(/[.]+$/u, "");
|
||||
}
|
||||
function formatNamedChoiceList(values) {
|
||||
return uniqueStrings(values)
|
||||
.slice(0, 6)
|
||||
@@ -837,10 +840,7 @@ function headlineFor(mode, pilot) {
|
||||
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) {
|
||||
@@ -1203,6 +1203,20 @@ function derivedRankedValueFlowConfirmedLine(pilot) {
|
||||
: "";
|
||||
return `${directionLead} ${leader.axis_value}${organization}${period}: ${leader.total_amount_human_ru} по ${leader.rows_with_amount} строкам с суммой.${roleCaveat}${trail}${limitCaveat}`;
|
||||
}
|
||||
function derivedValueFlowHeadlineLine(pilot) {
|
||||
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) {
|
||||
const flow = pilot.derived_value_flow;
|
||||
if (!flow) {
|
||||
@@ -1221,7 +1235,7 @@ function derivedValueFlowConfirmedLine(pilot) {
|
||||
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) {
|
||||
const flow = pilot.derived_value_flow;
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
@@ -1401,11 +1401,10 @@ describe("assistant MCP discovery answer adapter", () => {
|
||||
const confirmedText = draft.confirmed_lines.join("\n");
|
||||
|
||||
expect(draft.answer_mode).toBe("confirmed_with_bounded_inference");
|
||||
expect(draft.headline).toContain("входящих денежных поступлений");
|
||||
expect(draft.headline).toContain("Входящие денежные поступления");
|
||||
expect(draft.headline).toContain("3 750,50 руб");
|
||||
expect(confirmedText).toContain("3 750,50 руб.");
|
||||
expect(confirmedText).toContain("входящих денежных поступлений");
|
||||
expect(confirmedText).toContain("2020-01-15");
|
||||
expect(confirmedText).toContain("2020-02-20");
|
||||
expect(confirmedText).toContain("входящие денежные поступления");
|
||||
expect(draft.unknown_lines).toContain("Full turnover outside the checked period is not proven by this MCP discovery pilot");
|
||||
expect(draft.must_not_claim).toContain("Do not claim full all-time turnover unless the checked period and coverage prove it.");
|
||||
expect(draft.limitation_lines.join("\n")).not.toContain("pilot_");
|
||||
@@ -1433,8 +1432,9 @@ describe("assistant MCP discovery answer adapter", () => {
|
||||
const confirmedText = draft.confirmed_lines.join("\n");
|
||||
|
||||
expect(draft.answer_mode).toBe("confirmed_with_bounded_inference");
|
||||
expect(draft.headline).toContain("исходящих платежей");
|
||||
expect(confirmedText).toContain("исходящих платежей/списаний");
|
||||
expect(draft.headline).toContain("Исходящие платежи");
|
||||
expect(draft.headline).toContain("5 000,25 руб");
|
||||
expect(confirmedText).toContain("исходящие платежи/списания");
|
||||
expect(confirmedText).toContain("5 000,25 руб.");
|
||||
expect(draft.inference_lines.join("\n")).toContain("supplier-payout total");
|
||||
expect(draft.unknown_lines).toContain("Full supplier-payout amount outside the checked period is not proven by this MCP discovery pilot");
|
||||
|
||||
Reference in New Issue
Block a user