Files
abap-llm/tasks_gen/train/G1115/spec.md
2026-10-05 18:02:52 +02:00

87 lines
3.2 KiB
Markdown

# 1. Goal
A translation agency prices translation jobs. The order desk calls one function
module for each job. The function module must have the same interface as the
sample module {{P}}TRANS_SAMPLE, because the order desk calls all pricing modules
of the agency in the same way. Other programs of the agency also need the price.
Therefore the calculation is available in a separate class.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_TRANS exists in package $TMP.
- Function module {{P}}TRANS_SAMPLE exists in this group. It is the sample
pricing module. Its interface is the interface that all pricing modules of the
agency use.
# 4. Contract
## 4.1 Function module {{P}}TRANS_FEE
- Function group: {{P}}FG_TRANS.
- Interface: exactly the interface of {{P}}TRANS_SAMPLE.
- Importing parameters:
- iv_lang_pair TYPE string
- iv_word_count TYPE i
- iv_express TYPE abap_bool
- iv_certified TYPE abap_bool
- Exporting parameter: ev_fee TYPE decfloat34
- Exceptions: invalid_lang_pair, invalid_word_count
## 4.2 Class {{P}}TRANS_PRICER
- Package $TMP.
- Public and final.
- Public constructor without parameters.
- Public instance method calculate_fee:
- Importing parameters:
- iv_lang_pair TYPE string
- iv_word_count TYPE i
- iv_express TYPE abap_bool
- iv_certified TYPE abap_bool
- Returning parameter: rv_fee TYPE decfloat34
- The method has no exceptions. It expects valid input.
# 5. Business rules
1. The language pair is STD or RARE. Any other value is invalid.
2. The word count is 1 or more. A word count of 0 or a negative word count is
invalid.
3. The function module {{P}}TRANS_FEE checks the language pair first and the
word count second. It raises the exception INVALID_LANG_PAIR for an invalid
language pair and the exception INVALID_WORD_COUNT for an invalid word count.
4. The price of one word is 0.12 for language pair STD and 0.19 for language
pair RARE.
5. The translation charge is the word count multiplied by the price of one
word. Round the translation charge half up to 2 decimals.
6. The minimum translation charge is 35.00. If the translation charge is less
than 35.00, the translation charge is 35.00.
7. The agency grants a volume discount on the translation charge after rule 6:
- 10 % for 1000 words up to 4999 words,
- 15 % for 5000 words or more.
Round the discount half up to 2 decimals. The discounted charge is the
translation charge minus the discount.
8. A certified translation adds a flat fee of 22.00 to the discounted charge.
9. Express delivery multiplies the amount after rules 7 and 8 by 1.5. Round the
result half up to 2 decimals.
10. Without express delivery, the fee is the amount after rules 7 and 8.
11. The class {{P}}TRANS_PRICER returns the fee in rv_fee. The function module
{{P}}TRANS_FEE returns the fee in ev_fee.
# 6. Constraints
- Release target: 8.16 (SAP_BASIS 816).
- Package $TMP. Do not use a transport.
- Clean ABAP. Keep every method below 40 statements.
- Out of scope: do not change {{P}}TRANS_SAMPLE.
# 7. Acceptance
- All objects are active and have no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests: local test classes for {{P}}TRANS_PRICER and a global
test class for {{P}}TRANS_FEE.