# Business Logic — FUW02501SFLogic.chkPayKoteiTanka() [42 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW02501SF.FUW02501SFLogic` |
| Layer | Service Logic (webview layer, within the FUW02501SF web module) |
| Module | `FUW02501SF` (Package: `eo.web.webview.FUW02501SF`) |

## 1. Role

### FUW02501SFLogic.chkPayKoteiTanka()

This method performs a **paid flag determination for fixed-unit-price charges** in the context of a telecom service order screen (FUW02501SF). Its Javadoc states: "有料フラグ判定（固定単価）処理を行います" — i.e., it determines whether any fixed-unit-price line item in the service contract has a non-zero charge amount, thereby indicating that the overall order includes a paid component. The method is called from `setPayFlg()`, which combines this fixed-unit-price check with a "free trial remaining quantity" calculation to decide whether the user's subscription is paid or free. Specifically, even if fixed-unit-price charges exist, the method serves as one operand in the broader "pay/no-pay" decision: if fixed-unit-price charges are present and no free trial quota remains, the order is still marked as paid. In this method alone, it answers the simpler question: "Is there any fixed-unit-price item with a positive amount?" It operates on data populated by downstream CBS calls (EKK0601B001BS) that populate a nested map structure containing billing plan line items with their fixed amount details.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkPayKoteiTanka(params)"])
    INIT["res = false, parentMap = null"]
    C1["outputMap.containsKey(SC_TITLE_FUSV006902)"]
    GET["parentMap = outputMap.get(SC_TITLE_FUSV006902)"]
    C2["parentMap != null && parentMap.containsKey(EKK0601B001_LIST)"]
    GET_LIST["childList = parentMap.get(EKK0601B001_LIST)"]
    C3["childList != null && childList.size() > 0"]
    INIT_LOOP["i = 0"]
    C4["i < childList.size()"]
    GET_CHILD["childmap = childList.get(i)"]
    C5["parseInt(childmap.get(PPLAN_KOTEI_AMNT)) > 0"]
    RES_TRUE["res = true"]
    RES_FALSE_CHILD["res = false"]
    RES_FALSE_EMPTY["res = false"]
    RET["return res"]

    START --> INIT --> C1
    C1 -- "FUSV006902SC key exists" --> GET --> C2
    C1 -- "No key" --> RET
    C2 -- "parentMap != null && EKK0601B001_LIST key exists" --> GET_LIST --> C3
    C2 -- "null or missing" --> RET
    C3 -- "childList not null and size > 0" --> INIT_LOOP
    C3 -- "empty or null" --> RES_FALSE_EMPTY --> RET
    INIT_LOOP --> C4
    C4 -- "i < size" --> GET_CHILD --> C5
    C4 -- "i >= size" --> RET
    C5 -- "amount > 0 (Fixed-unit-price charge exists)" --> RES_TRUE --> RET
    C5 -- "amount <= 0 (Fixed-unit-price is 0 yen)" --> RES_FALSE_CHILD --> INIT_LOOP
```

**Constant Resolution:**
- `SC_TITLE_FUSV006902 = "FUSV006902SC"` — The service title/key used to nest related billing plan data within the `outputMap`. This key holds the parent map populated by the FUSV006902SC service component.
- `EKK0601B001_LIST = "EKK0601B001CBSMsg1List"` — The list key within the parent map that contains an `ArrayList` of child billing plan line items, each representing a fixed-unit-price charge entry from the CBS (EKK0601B001BS) data flow.
- `PPLAN_KOTEI_AMNT = "pplan_kotei_amnt"` — The field key within each child map holding the fixed-unit-price amount (固定固定金額) as a string. This value is the amount of the fixed charge for a billing plan item.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outputMap` | `HashMap<String, Object>` | The output map carrying screen-level data populated by prior CBS calls and data preparation. It contains a nested structure under the key `"FUSV006902SC"` which holds parent billing plan data, and within that, a list under `"EKK0601B001CBSMsg1List"` containing fixed-unit-price charge line items, each with a `"pplan_kotei_amnt"` field holding the fixed charge amount. |

## 4. CRUD Operations / Called Services

This method performs **no direct database operations or service component calls**. It is a pure data inspection method that navigates and evaluates nested `HashMap` structures already populated by prior CBS/SC calls. All data it examines was previously fetched via `EKK0601B001BS` (Service Component `EKK0601B001BS`, which maps fixed-unit-price billing plan data).

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (None) | N/A | N/A | N/A | This method is a read-only data inspection routine; it does not invoke any SC, CBS, DAO, or database operation directly. |

**Evidence:** The method contains zero calls to any SC, CBS, or DAO method. It only performs `HashMap.get()`, `HashMap.containsKey()`, `ArrayList.get()`, `ArrayList.size()`, and `Integer.parseInt()` operations on in-memory data structures. The data was pre-populated by `EKK0601B001BS` which retrieves fixed-unit-price billing plan line items (including `pplan_kotei_amnt`, `pplan_chrg_tani_cd`, `pplan_kotei_tani_cd_nm`, etc.) from the billing plan data.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

Direct callers found: 1 method.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `setPayFlg()` (FUW02501SFLogic) | `setPayFlg` -> `chkPayKoteiTanka` | N/A — read-only data inspection |

**Caller detail:** `setPayFlg(X31SDataBeanAccess bean, HashMap<String, Object> outputMap, int keiCnt)` at line 644 of `FUW02501SFLogic.java` is a private method within the same class. It computes whether the current service order requires payment by: (1) calculating free trial remaining quantity (`mryoCnt` = `hpAcsMryoCnt` - `keiCnt`), (2) calling `chkPayKoteiTanka(outputMap)` to check for fixed-unit-price charges, and (3) returning `true` (paid) only if fixed-unit-price charges exist AND no free trial remains (`mryoCnt <= 0`). Otherwise, it returns `false` (free).

The method is invoked at line 162 of `FUW02501SFLogic.java` via:
```java
bean.sendMessageBoolean(FUW02501SFConst.PAY_FLG, X31CWebConst.DATABEAN_SET_VALUE, setPayFlg(bean, outputMap, sbopSvcKeiCnt));
```

## 6. Per-Branch Detail Blocks

**Block 1** — [INIT] (L685)

Initialize local variables and default result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Default result: no fixed-unit-price found |
| 2 | SET | `parentMap = null` // Parent map holder |

**Block 2** — [IF] `(outputMap.containsKey(SC_TITLE_FUSV006902))` [SC_TITLE_FUSV006902="FUSV006902SC"] (L687)

Check if the output map contains the billing plan parent data under the FUSV006902SC key. If present, extract the nested parent map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outputMap.containsKey(SC_TITLE_FUSV006902)` // Check for key "FUSV006902SC" |
| 2 | SET | `parentMap = (HashMap<String, Object>)outputMap.get(SC_TITLE_FUSV006902)` // Extract nested parent map |

**Block 3** — [IF] `(null != parentMap && parentMap.containsKey(EKK0601B001_LIST))` [EKK0601B001_LIST="EKK0601B001CBSMsg1List"] (L692)

Verify the parent map is not null and contains the list key for fixed-unit-price charge items. If so, extract the child list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `parentMap != null` // Guard against null parent |
| 1 | EXEC | `parentMap.containsKey(EKK0601B001_LIST)` // Check for key "EKK0601B001CBSMsg1List" |
| 2 | SET | `childList = (ArrayList<HashMap<String, Object>>)parentMap.get(EKK0601B001_LIST)` // Extract child list of billing plan line items |

**Block 4** — [IF] `(childList != null && childList.size() > 0)` (L695)

Check if the child list exists and is non-empty. If the list is empty or null, no fixed-unit-price items exist, so return `false`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `childList != null` // Guard against null list |
| 1 | EXEC | `childList.size() > 0` // Check list has entries |
| 2 | EXEC | Loop: `for (int i = 0; i < childList.size(); i++)` (L697) |

**Block 5** — [FOR LOOP] (i = 0; i < childList.size()) (L697)

Iterate over each fixed-unit-price charge line item.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childmap = childList.get(i)` // Get i-th billing plan line item |

**Block 6** — [IF] `(Integer.parseInt((String)childmap.get(PPLAN_KOTEI_AMNT)) > 0)` [PPLAN_KOTEI_AMNT="pplan_kotei_amnt"] (L702)

Check if the fixed-unit-price amount for the current line item is greater than 0.
- **true branch**: A fixed-unit-price charge with positive amount exists (固定単価が0円以上の場合) → set `res = true`.
- **false branch**: The fixed-unit-price is 0 yen (固定単価が0円の場合) → set `res = false` and continue to next item.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `childmap.get(PPLAN_KOTEI_AMNT)` // Get fixed-unit-price amount as string |
| 1 | EXEC | `Integer.parseInt(...)` // Parse to integer |
| 1 | EXEC | `> 0` // Compare against zero |
| 2 | SET | `res = true` // Fixed-unit-price charge found (固定単価あり) — last positive amount triggers positive result |
| 3 | SET | `res = false` // Fixed-unit-price is 0 yen (固定単価0円) — no charge for this item |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `pplan_kotei_amnt` | Field | Fixed-unit-price amount — the fixed charge amount (in yen) for a billing plan line item. If this value is > 0, it indicates the presence of a paid fixed charge. |
| `pplan_chrg_tani_cd` | Field | Billing plan charge unit code — classification code for the charge type. |
| `pplan_kotei_tani_cd_nm` | Field | Fixed-unit-price unit code name — human-readable name of the fixed charge unit code. |
| `FUSV006902SC` | Constant | Service Component key for FUSV006902 — a downstream SC that prepares parent billing plan data within the output map. |
| `EKK0601B001CBSMsg1List` | Constant | CBS message list key — the list key within the parent map containing fixed-unit-price billing plan line items populated by the EKK0601B001BS CBS call. |
| `EKK0601B001BS` | CBS | Billing Plan Fixed-Unit-Price CBS — the backend CBS (Component-Based Service) that retrieves fixed-unit-price billing plan line item data including charge amounts, unit codes, and descriptions. |
| `chkPayKoteiTanka` | Method Name | "Check Pay Fixed Unit Price" — Japanese naming convention. Determines whether any fixed-unit-price charge line item has a non-zero amount. |
| `setPayFlg` | Method Name | "Set Pay Flag" — Japanese naming convention. Combines free trial remaining quantity with fixed-unit-price check to determine overall paid/free status of the order. |
| `keiCnt` | Field/Parameter | Service count — the number of service lines (契約数) in the order. Used to calculate remaining free trial quantity. |
| `hpAcsMryoCnt` | Field | Home page access remaining quantity — the total free trial remaining count for home page access services. |
| `mryoCnt` | Field | Remaining quantity — calculated as `hpAcsMryoCnt - keiCnt`, representing remaining free trial slots after deducting contract count. |
| `res` | Local Variable | Result — the boolean return value indicating whether a fixed-unit-price charge with positive amount was found. |
| `outputMap` | Parameter | Output map — a shared HashMap carrying screen-level data populated by CBS calls, used to pass nested data structures between processing stages. |
| 固定単価 (Kotei Tanka) | Japanese term | Fixed unit price — a fixed charge amount for a billing plan item, as opposed to usage-based or variable pricing. |
| 有料 (Yuryo) | Japanese term | Paid / Chargeable — indicates that a service component incurs a fee. |
| 無料 (Muryo) | Japanese term | Free / No charge — indicates that a service component is provided at no cost. |
