返回提示词目录第 1406 页

编写业务计算规则与验收样例

帮你梳理计算顺序、舍入规则与边界样例,形成开发测试规范,标明需专业确认事项。

完整提示词

<context>
Calculation bugs are expensive because they look correct on the happy path and drift by a cent, a rounding step or an ordering choice at scale. The business usually describes rules in words ("10% commission after fees") that hide the decisions: is the discount applied before or after tax, is rounding done per line or on the total, half-up or half-even, which currency's minor unit applies, what happens with refunds and partial periods, and which date's rate or price applies. Engineers and testers need an ordered list of steps with named inputs, an explicit rounding point, and a table of worked examples with exact expected outputs, including the awkward ones. When the new rule must match an existing spreadsheet or legacy system, the examples should come from that source.
</context>

<task>
<rules_as_described>
{{rules_as_described}}
</rules_as_described>
{{#context}}
<context_from_user>
{{context}}
</context_from_user>
{{/context}}

1. List every input with its source, unit, type and allowed range, and the date or moment at which each is read (order date, payment date, period end).
2. Rewrite the calculation as numbered steps, each producing a named intermediate value, in the exact order applied. Make the order of discounts, fees, taxes and caps explicit.
3. Specify rounding and precision: where rounding happens (per line, per step, on the total), the rounding mode, the decimal places or currency minor units, and how residual cents are allocated when amounts are split.
4. Produce worked examples as a table with concrete inputs, each intermediate value and the expected output. Include at least one typical case, one boundary case (cap reached, zero, threshold exactly met), one refund or reversal, and one case that exposes rounding.
5. List edge cases: negative or zero values, missing inputs, mid-period changes, currency conversion, very large values, and changes to rules over time (which version applies to old records).
6. List open questions where the described rule is ambiguous, with the interpretations side by side and a recommended default marked as a proposal.
</task>

<constraints>
- Do not invent tax rates, exchange rates, legal fee caps or accounting treatments; use placeholders and say who must confirm them.
- Show the arithmetic for every worked example so a reviewer can check it by hand; double-check each result.
- Where the description allows two readings, present both with their different results instead of silently picking one.
- If the rule cannot be expressed without missing inputs, ask for them first.
</constraints>

<output_format>
## Inputs
Table: input, source, unit and type, range, read at.
## Calculation steps
Numbered steps with named intermediate values.
## Rounding and precision
Bullets.
## Worked examples
Table: example, inputs, intermediate values, expected output, with arithmetic shown below.
## Edge cases
Bullets: case, expected behaviour.
## Open questions
Numbered: question, readings and their results, recommended default (proposal).
</output_format>

可替换内容

  • {{rules_as_described}}
  • {{#context}}
  • {{context}}
  • {{/context}}

分类与标签

编程开发、需求规格、计算规则、舍入精度、验收样例

前往 AI 图片创作