# Business Logic — FUW03501SFLogic.chkPayKoteiTanka() [43 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW03501SF.FUW03501SFLogic` |
| Layer | Service Logic (Web view business logic, within `eo.web.webview` package) |
| Module | `FUW03501SF` (Package: `eo.web.webview.FUW03501SF`) |

## 1. Role

### FUW03501SFLogic.chkPayKoteiTanka()

This method performs a **paid status determination for fixed-unit-price charges** (固定単価). It inspects the price plan detail data returned from a prior service component call to determine whether any chargeable (non-free) line items exist in the result set. Specifically, it examines the "price plan fixed amount" (料金プラン固定金額) field of each child item: if any item has a fixed amount greater than zero yen, the method returns `true`, indicating that fixed-unit-price charges apply and the customer will incur a fee. If all items have zero fixed amounts, or if no price plan items exist at all, it returns `false`, indicating no chargeable fixed-unit-price lines.

The method follows a **guard clause / early-exit pattern**: it progressively validates the presence and integrity of nested data structures (parent map -> child list -> individual items) and short-circuits to `false` at every failure point. This ensures safe handling of null or missing data from upstream service components. It implements a **delegation design** by reading data exclusively from the `outputMap` parameter, which was populated by the `FUSV007301SC` service component.

This method plays a supporting role in the fee determination flow of the `FUW03501SF` screen logic. It is called by `setPayFlg()` to determine whether the customer has any fixed-unit-price charges, which contributes to the overall "paid flag" (有料フラグ) that drives downstream UI behavior (e.g., whether to display charge information or mark the service as free).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkPayKoteiTanka(outputMap)"])
    A1["res = false<br/>parentMap = null"]
    C1{"outputMap contains<br/>FUSV007301SC"}
    A2["parentMap = outputMap.get(FUSV007301SC)"]
    C2{"parentMap != null<br/>AND<br/>parentMap contains<br/>EKK0591B001CBSMSG1LIST"}
    A3["childList = parentMap.get(EKK0591B001CBSMSG1LIST)"]
    C3{"childList != null<br/>AND<br/>childList.size() > 0"}
    B1["for i = 0 to childList.size()"]
    C4{"i < childList.size()"}
    A4["childmap = childList.get(i)"]
    A5["amt = Integer.parseInt(childmap.get(PPLAN_KOTEI_AMNT))"]
    C5{"amt > 0"}
    A6["res = true<br/>break"]
    A7["res = false"]
    A8["res = false<br/>no child items"]
    A9["res = false<br/>no parentMap"]
    END_RETURN(["return res"])

    START --> A1 --> C1
    C1 -- true --> A2 --> C2
    C1 -- false --> A9 --> END_RETURN
    C2 -- true --> A3 --> C3
    C2 -- false --> A9 --> END_RETURN
    C3 -- true --> B1
    C3 -- false --> A8 --> END_RETURN
    B1 --> C4
    C4 -- true --> A4 --> A5 --> C5
    C4 -- false --> END_RETURN
    C5 -- true --> A6 --> END_RETURN
    C5 -- false --> A7 --> B1
    A8 --> END_RETURN
    A9 --> END_RETURN
```

**Key:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `FUSV007301SC` | `"FUSV007301SC"` | Price plan list query (option service code) — service component key used to retrieve price plan details from the service layer |
| `EKK0591B001CBSMSG1LIST` | `"EKK0591B001CBSMsg1List"` | Price plan list details (option service code) — map key for the child list containing individual price plan item entries |
| `PPLAN_KOTEI_AMNT` | `"pplan_kotei_amnt"` | Price plan fixed amount — the fixed monetary amount (in yen) for a given price plan line item |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outputMap` | `HashMap` | The output data map carrying results from upstream service component calls. It contains the price plan list data populated by `FUSV007301SC` (Price Plan List Query for option service codes), under the key `"FUSV007301SC"`. The nested child list under `EKK0591B001CBSMsg1List` contains individual price plan entries, each with fields such as `pplan_kotei_amnt` (price plan fixed amount), `pplan_cd` (price plan code), `op_svc_cd` (option service code), etc. |

**External/instance fields read by this method:**

| Field | Type | Business Meaning |
|-------|------|------------------|
| `FUSV007301SC` | `static final String` | Map key constant — `"FUSV007301SC"`. Used to retrieve the parent map containing price plan list data from `outputMap`. |
| `EKK0591B001CBSMSG1LIST` | `static final String` | Map key constant — `"EKK0591B001CBSMsg1List"`. Used to retrieve the child list of price plan detail entries from the parent map. |
| `PPLAN_KOTEI_AMNT` | `static final String` | Map key constant — `"pplan_kotei_amnt"`. Used to retrieve the fixed amount value from each child map entry. |

## 4. CRUD Operations / Called Services

This method does **not** directly invoke any SC/CBS methods, DAO methods, or database operations. It operates entirely on in-memory `HashMap` data structures that were populated by upstream service calls (specifically, the `FUSV007301SC` service component, which was called earlier in the processing chain by the mapper).

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| N/A | — | — | — | This method performs **in-memory data inspection** only. No CRUD operations are executed directly. The price plan list data it inspects was previously loaded by `FUSV007301SC` (Service Component for price plan list query), which maps to the CBS `EKK0591B001` and queries the `KK_M_PPLAN_KTTANKA` table (Price Plan Fixed Unit Price master table). |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Logic: `FUW03501SFLogic.setPayFlg()` | `setPayFlg(bean, outputMap)` -> `chkPayKoteiTanka(outputMap)` | `FUSV007301SC [R] KK_M_PPLAN_KTTANKA (via upstream)` |

**Call chain detail:** `setPayFlg()` (line 736 of `FUW03501SFLogic.java`) calls `chkPayKoteiTanka(outputMap)` at line 722. `setPayFlg()` is itself called from line 258 where the result is passed to `bean.sendMessageBoolean(FUW03501SFConst.PAY_FLG, X31CWebConst.DATABEAN_SET_VALUE, setPayFlg(bean, outputMap))`, setting the "paid flag" data bean value on the screen.

## 6. Per-Branch Detail Blocks

**Block 1** — [PROCESSING] `initialization` (L746-L747)

> Initialize local variables. `res` defaults to `false` (free/no charge), and `parentMap` is set to `null`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Default: no fixed-unit-price charge |
| 2 | SET | `parentMap = null` // Will hold the parent map extracted from outputMap |

**Block 2** — [IF] `check for parentMap existence` (L749-L752)
[Constant: `FUSV007301SC = "FUSV007301SC"` — Price plan list query service component key]

> Check if the `outputMap` contains the parent map key for the price plan list data returned by the `FUSV007301SC` service component. If present, extract it.

| # | Type | Code |
|---|------|------|
| 1 | IF | `outputMap.containsKey(FUSV007301SC)` `[FUSV007301SC="FUSV007301SC"]` (L749) |
| 2 | SET | `parentMap = (HashMap)outputMap.get(FUSV007301SC)` (L751) |

**Block 2.1** — [ELSE-IMPLICIT] `parentMap not found` (L749)

> If the parent map key is absent, `parentMap` remains `null`. This leads to the outermost condition (Block 3) evaluating to false, returning `false` (no charge).

**Block 3** — [IF] `check for child list in parentMap` (L754-L781)
[Constant: `EKK0591B001CBSMSG1LIST = "EKK0591B001CBSMsg1List"` — Price plan list details key]

> Check if `parentMap` is not null AND contains the child list of price plan detail entries. If both conditions are met, extract the child list and process it.

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != parentMap && parentMap.containsKey(EKK0591B001CBSMSG1LIST)` `[EKK0591B001CBSMSG1LIST="EKK0591B001CBSMsg1List"]` (L754) |
| 2 | SET | `childList = (ArrayList)parentMap.get(EKK0591B001CBSMSG1LIST)` (L756) |

**Block 3.1** — [ELSE] `no child list or null parentMap` (L778-L780)

> If either `parentMap` is null or the child list key is absent, set `res = false`.
> Japanese comment: 固定単価がない場合 (No fixed-unit-price items exist).

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // No fixed-unit-price items exist (固定単価がない場合) |

**Block 3.2** — [IF] `check child list content` (L758-L777)
[Nested inside the `childList != null && childList.size() > 0` condition on L758]

> If the child list has entries, iterate through them to check for any non-zero fixed amount.

| # | Type | Code |
|---|------|------|
| 1 | IF | `childList != null && childList.size() > 0` (L758) |
| 2 | FOR | `for (int i = 0; i < childList.size(); i++)` (L760) |

**Block 3.2.1** — [FOR BODY] `iterate over child items` (L761-L775)
[Constant: `PPLAN_KOTEI_AMNT = "pplan_kotei_amnt"` — Price plan fixed amount field]

> For each child map entry in the list, retrieve the fixed amount. If any item has a fixed amount > 0, set `res = true` and break out of the loop (found a chargeable item). Otherwise, set `res = false` for the current item and continue checking remaining items.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childmap = (HashMap)childList.get(i)` (L762) |
| 2 | SET | `amt = Integer.parseInt((String)childmap.get(PPLAN_KOTEI_AMNT))` [PPLAN_KOTEI_AMNT="pplan_kotei_amnt"] (L764) |
| 3 | IF | `amt > 0` (L764) |

**Block 3.2.1.1** — [IF-BRANCH] `fixed amount > 0` (L766-L768)
[Japanese comment: 固定単価が0円以上の場合 (When fixed unit price is 0 yen or more)]

> A chargeable item was found. Set the result to `true` and break out of the loop immediately — no need to check remaining items.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = true` // A fixed-unit-price chargeable item found (固定単価が0円以上の場合) |
| 2 | EXEC | `break` // Exit loop — found the chargeable item |

**Block 3.2.1.2** — [ELSE] `fixed amount == 0` (L770-L772)
[Japanese comment: 固定単価が0円の場合 (When fixed unit price is 0 yen)]

> The current item has a zero fixed amount (free). Set `res = false` for this item and continue to check the next item in the list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Fixed unit price is 0 yen (固定単価が0円の場合) |

**Block 4** — [RETURN] (L783)

> Return the final result. `true` means at least one chargeable fixed-unit-price item exists; `false` means no such item was found (free).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return res` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chkPayKoteiTanka` | Method | Charge status determination for fixed-unit-price — checks whether any chargeable (non-zero) fixed amount exists in price plan items |
| `FUSV007301SC` | Constant | Price plan list query service component (option service code) — SC key for retrieving price plan details |
| `EKK0591B001CBSMsg1List` | Constant | Price plan list details (option service code) — map key for child entries in the price plan query result |
| `PPLAN_KOTEI_AMNT` | Constant | Price plan fixed amount — the fixed monetary amount in yen for a price plan line item |
| `pplan_kotei_amnt` | Field | Price plan fixed amount (料金プラン固定金額) — individual field within each price plan child entry; numeric value in yen |
| `outputMap` | Field | Output data map — carries results from upstream service component calls to the logic layer |
| `parentMap` | Field | Parent HashMap containing the price plan list data extracted from `outputMap` |
| `childList` | Field | ArrayList of HashMap entries, each representing an individual price plan line item |
| `childmap` | Field | A single HashMap entry from the child list, containing fields like `pplan_kotei_amnt`, `pplan_cd`, `op_svc_cd`, etc. |
| `res` | Field | Result boolean — `true` if any fixed-unit-price chargeable item is found, `false` otherwise |
| `KK_M_PPLAN_KTTANKA` | Table | Price Plan Fixed Unit Price master table — configuration table storing fixed pricing for price plans |
| `FUSV007301SC` | SC | Service Component for price plan list query — retrieves price plan data for option service codes |
| `EKK0591B001` | CBS | Confirmation Service Component — back-end CBS that `FUSV007301SC` maps to for data retrieval |
| 固定単価 (Kotei Tanka) | Japanese term | Fixed unit price — a fixed, non-variable monthly charge for a price plan item |
| 有料フラグ (Yuryo Flag) | Japanese term | Paid flag — boolean indicator of whether charges apply to a service |
| 料金プラン (Ryokin Plan) | Japanese term | Price plan — a billing plan or tariff plan offered to customers |
| 固定金額 (Kotei Kingaku) | Japanese term | Fixed amount — the fixed monetary value (in yen) of a price plan charge |
| オプションサービス (Option Service) | Japanese term | Option service — an add-on or supplementary service beyond the base plan |
| `op_svc_cd` | Field | Option service code — identifies the type of option service |
| `pplan_cd` | Field | Price plan code — identifies the specific price plan |
| `pcrs_cd` | Field | Price cost code — identifies the pricing cost item |
