# Business Logic — FUW02001SFLogic.chkPayInitialCost() [29 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW02001SF.FUW02001SFLogic` |
| Layer | Controller (WebView Logic — presentation-layer business logic within the web module) |
| Module | `FUW02001SF` (Package: `eo.web.webview.FUW02001SF`) |

## 1. Role

### FUW02001SFLogic.chkPayInitialCost()

This method performs a **paid-flag determination for initial fees** (有料フラグ判定（初期費用）処理). Its sole responsibility is to inspect the output map that has been pre-populated by prior processing steps and determine whether any child record (representing a billable service item) exists in the initial fee detail list. If at least one entry is found, the method returns `true` to signal that an initial fee is applicable; otherwise it returns `false`. This is a **shared utility method** — it is reused across many screens (FUW01901SF, FUW02101SF, FUW02301SF, FUW02501SF, FUW03501SF, FUW03701SF, FUW03901SF, FUW04001SF, FUW07701SF, and beyond) to gate pricing-related branches. The method implements a **delegation pattern**: it does not query the database itself but reads data already fetched and stored in the output map by upstream CBS/SC calls.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkPayInitialCost(outputMap)"])
    INIT_RES["res = false"]
    INIT_PARENT["parentMap = null"]
    CHECK_PARENT["outputMap.containsKey(CC_TITLE_FUSV005501)"]
    GET_PARENT["parentMap = (HashMap)outputMap.get(CC_TITLE_FUSV005501)"]
    CHECK_PARENT_NULL["parentMap != null"]
    CHECK_CHILD_KEY["parentMap.containsKey(EKK0721A010_LIST)"]
    GET_CHILD["childList = (ArrayList)parentMap.get(EKK0721A010_LIST)"]
    CHECK_CHILD_NOTNULL["childList != null"]
    CHECK_CHILD_SIZE["childList.size() > 0"]
    HAS_INITIAL_FEE["res = true"]
    NO_INITIAL_FEE["res = false"]
    RETURN_FALSE["Return false"]
    END_NODE(["Return res"])

    START --> INIT_RES --> INIT_PARENT --> CHECK_PARENT
    CHECK_PARENT -->|true| GET_PARENT
    CHECK_PARENT -->|false| CHECK_PARENT_NULL
    GET_PARENT --> CHECK_PARENT_NULL
    CHECK_PARENT_NULL -->|false| RETURN_FALSE
    CHECK_PARENT_NULL -->|true| CHECK_CHILD_KEY
    CHECK_CHILD_KEY -->|true| GET_CHILD
    CHECK_CHILD_KEY -->|false| NO_INITIAL_FEE
    GET_CHILD --> CHECK_CHILD_NOTNULL
    CHECK_CHILD_NOTNULL -->|true| CHECK_CHILD_SIZE
    CHECK_CHILD_NOTNULL -->|false| NO_INITIAL_FEE
    CHECK_CHILD_SIZE -->|true| HAS_INITIAL_FEE
    CHECK_CHILD_SIZE -->|false| NO_INITIAL_FEE
    HAS_INITIAL_FEE --> END_NODE
    NO_INITIAL_FEE --> END_NODE
    RETURN_FALSE --> END_NODE
```

**Constant Resolution:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `CC_TITLE_FUSV005501` | `"FUSV005501CC"` | Parent process info area key — the output map key under which the parent data map is stored (originating from the FUSV005501 CBS call) |
| `EKK0721A010_LIST` | `"EKK0721A010CBSMsg1List"` | Child detail list key — the output map key under which the initial fee item list (ArrayList) is stored (originating from the EKK0721A010 CBS call) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outputMap` | `HashMap` | The output map populated by upstream CBS (Corporate Batch Service) calls. It carries process info area data including a parent map key (`CC_TITLE_FUSV005501` / `"FUSV005501CC"`) that nests a child list (`EKK0721A010_LIST` / `"EKK0721A010CBSMsg1List"`) containing billable service item records. If the map or its nested structures are absent, the method returns `false` (no initial fee). |

**Instance fields / external state:** None — this method is fully stateless and relies solely on the passed-in map.

## 4. CRUD Operations / Called Services

This method performs **no direct database or SC/CBS calls**. It is a pure read-through of an in-memory map that was previously populated by upstream CBS/SC invocations.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R (inherited) | `chkPayInitialCost` reads from `outputMap` which was populated by `EKK0721A010CBS` | EKK0721A010CBS | (upstream CBS — entity determined by that CBS's source) | Reads the pre-populated child detail list to determine if any billable initial fee item exists |

**Note:** The actual data source (DB table / entity) is defined in the `EKK0721A010CBS` CBS method, which is called by the upstream process info area processing (e.g., `JFUWebCommon.setPrcInfoArea` at line 230 of FUW02001SFLogic). The current method only performs an in-memory map inspection.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:FUW07701SF | `setFreeFlg(outputMap)` -> `chkPayInitialCost(outputMap)` | map read [R] EKK0721A010CBSMsg1List |
| 2 | Screen:FUW03701SF | `setFreeFlg(...)` -> `chkPayInitialCost(outputMap)` (combined with payFlg in OR branch) | map read [R] EKK0721A010CBSMsg1List |
| 3 | Screen:FUW03501SF | `setFreeFlg(...)` -> `chkPayInitialCost(outputMap)` (combined with payFlg in OR branch) | map read [R] EKK0721A010CBSMsg1List |
| 4 | Screen:FUW02301SF | `setFreeFlg(...)` -> `chkPayInitialCost(outputMap)` (combined with payFlg in OR branch) | map read [R] EKK0721A010CBSMsg1List |
| 5 | Screen:FUW02501SF | `setFreeFlg(...)` -> `chkPayInitialCost(outputMap)` (combined with payFlg in OR branch) | map read [R] EKK0721A010CBSMsg1List |
| 6 | Screen:FUW01901SF | `setFreeFlg(...)` -> `chkPayInitialCost(outputMap)` (combined with payFlg in OR branch) | map read [R] EKK0721A010CBSMsg1List |
| 7 | Screen:FUW02101SF | `setPayFlg(bean, outputMap)` -> `chkPayInitialCost(outputMap)` (combined with chkPayKoteiTanka in OR) | map read [R] EKK0721A010CBSMsg1List |
| 8 | Screen:FUW03901SF | `invokeCheck(...)` -> `chkPayInitialCost(outputMap)` (set via sendMessageBoolean) | map read [R] EKK0721A010CBSMsg1List |
| 9 | Screen:FUW04001SF | `invokeCheck(...)` -> `chkPayInitialCost(outputMap)` (set via sendMessageBoolean) | map read [R] EKK0721A010CBSMsg1List |
| 10 | Same-module (FUW02001SFLogic) | Self-referencing method — not called within its own class | — |

**Instructions applied:**
- All callers identified via search across all `*Logic.java` files.
- The method is **private** in FUW02001SFLogic, so inter-module callers access it via inheritance or method override (other modules define their own `chkPayInitialCost` with the same signature).
- The call pattern is consistent: most callers wrap `chkPayInitialCost` in a `setFreeFlg` method that inverts the result (`true` -> initial fee exists -> free flag = `false`; `false` -> no initial fee -> free flag = `true`).

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(outputMap.containsKey(CC_TITLE_FUSV005501))` [`CC_TITLE_FUSV005501 = "FUSV005501CC"`] (L927)

> Check whether the output map contains the parent process info area entry. If present, extract the parent map; otherwise parentMap remains `null`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `parentMap = (HashMap)outputMap.get(CC_TITLE_FUSV005501)` // Cast and retrieve the parent map under key "FUSV005501CC" [-> `CC_TITLE_FUSV005501 = "FUSV005501CC"`] |

**Block 2** — [IF] `(null != parentMap && parentMap.containsKey(EKK0721A010_LIST))` [`EKK0721A010_LIST = "EKK0721A010CBSMsg1List"`] (L932)

> Validate that parentMap exists and contains the child detail list. Both conditions must be true to proceed to the fee item inspection.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `null != parentMap` // Verify parent map was extracted |
| 2 | CONDITION | `parentMap.containsKey(EKK0721A010_LIST)` // Verify child list key exists [-> `EKK0721A010_LIST = "EKK0721A010CBSMsg1List"`] |
| 3 | SET | `childList = (ArrayList)parentMap.get(EKK0721A010_LIST)` // Retrieve the ArrayList of billable item records |

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

> **Initial fee EXISTS** — at least one child record was found in the detail list. Set the result to `true`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = true` // 初期費用がある場合 (Initial fee exists) |

**Block 2.2** — [ELSE] (L942)

> **Initial fee does NOT exist** — child list was present but empty. Set the result to `false`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // 初期費用がない場合 (Initial fee does not exist) |

**Block 3** — [RETURN] (L949)

> Return the computed result to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return res` // true = initial fee applicable, false = no initial fee |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `chkPayInitialCost` | Method | Paid flag determination for initial fees — checks whether billable initial fee items exist in the process info area |
| `CC_TITLE_FUSV005501` | Constant | `"FUSV005501CC"` — Map key for the parent process info area, populated by the FUSV005501 CBS call |
| `EKK0721A010_LIST` | Constant | `"EKK0721A010CBSMsg1List"` — Map key for the child detail list of initial fee items, populated by the EKK0721A010 CBS call |
| `outputMap` | Field | Output data map carrying process info area data from upstream CBS calls to downstream screen logic |
| `parentMap` | Field | Nested HashMap under `CC_TITLE_FUSV005501` containing child-level detail entries |
| `childList` | Field | ArrayList of billable item records under `EKK0721A010_LIST` — each entry represents a service item subject to initial fee charges |
| `res` | Field | Return flag — `true` indicates initial fee is applicable, `false` indicates no initial fee |
| CBS | Acronym | Corporate Batch Service — background batch processing component that performs data access and business logic |
| SC | Acronym | Service Component — service layer class that handles specific business operations |
| FUSV | Acronym | Frontend Utility Service View — process info area utility package (FUSV0055 = process info area processing) |
| EKK | Acronym | Internal service category prefix — EKK0721A010 is the CBS that fetches initial fee item details |
| 有料 (Yuryo) | Japanese term | Paid / billable — indicates whether charges apply |
| 初期費用 (Shoki Hiyō) | Japanese term | Initial fee — one-time setup/installation charge for a service |
| 初期費用がある場合 | Japanese comment | "When initial fee exists" — block executed when child list is non-empty |
| 初期費用がない場合 | Japanese comment | "When initial fee does not exist" — block executed when child list is empty or null |
| process info area | Technical term | A structured output map hierarchy (parent -> child) used to pass aggregated data between CBS calls and screen logic |
