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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW02501SF.FUW02501SFLogic` |
| Layer | Service Logic (Web Service Layer) |
| Module | `FUW02501SF` (Package: `eo.web.webview.FUW02501SF`) |

## 1. Role

### FUW02501SFLogic.chkPayInitialCost()

This method performs an **initial cost existence determination** — it inspects the service information processing area within the output map to detect whether any initial fees (setup charges, one-time onboarding costs) apply to the current customer's service contract. The method operates as a **predicate/utility check** that returns a simple boolean flag indicating whether the initial cost section contains at least one detail line item.

It implements a **nested map inspection pattern** with defensive null-checking, traversing two levels of a hierarchical output map: first extracting the parent processing-area map identified by the `"FUSV006901CC"` key, then inspecting whether that area contains a list of initial cost detail items under the `"EKK0721A010CBSMsg1List"` key. This pattern is shared across multiple web screens in the system (e.g., FUW02001SF, FUW03501SF, FUW03701SF, FUW03901SF, FUW04001SF, FUW07701SF), confirming it serves as a **reusable business utility** invoked during pricing display flows.

In the larger system, this method answers a critical business question: **does this customer owe any upfront/initial payment?** The result feeds into pricing-flag computation (`PAY_FLG`), UI control of price tables, and mansion-type branching logic (determining whether initial cost display logic should apply to multi-dwelling unit tenants).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkPayInitialCost(outputMap)"])
    CHK_OUTPUT["Check: outputMap contains CC_TITLE_FUSV006901?"]
    PARENT_GET["Get parentMap = outputMap.get(CC_TITLE_FUSV006901)"]
    CHK_PARENT["Check: parentMap != null AND parentMap contains EKK0721A010_LIST?"]
    CHILD_GET["Get childList = parentMap.get(EKK0721A010_LIST)"]
    CHK_LIST["Check: childList != null AND childList.size() > 0?"]
    SET_TRUE["res = true (Initial cost exists)"]
    SET_FALSE["res = false (No initial cost)"]
    RETURN(["Return res"])

    START --> CHK_OUTPUT
    CHK_OUTPUT -->|Yes| PARENT_GET
    CHK_OUTPUT -->|No| SET_FALSE
    PARENT_GET --> CHK_PARENT
    CHK_PARENT -->|Yes| CHILD_GET
    CHK_PARENT -->|No| SET_FALSE
    CHILD_GET --> CHK_LIST
    CHK_LIST -->|Yes| SET_TRUE
    CHK_LIST -->|No| SET_FALSE
    SET_TRUE --> RETURN
    SET_FALSE --> RETURN
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `CC_TITLE_FUSV006901` | `"FUSV006901CC"` | Identifier for the service information processing area map — holds pricing/fee detail sub-areas |
| `EKK0721A010_LIST` | `"EKK0721A010CBSMsg1List"` | Key for the initial cost detail item list within the processing area — populated by CBS when initial fees exist |

**Processing Summary:**
The method follows a **gate-and-inspect pattern**: it first attempts to locate the service information processing area (gate 1), then verifies the area map is present and contains the initial cost detail list (gate 2), and finally checks whether the list has at least one item (gate 3). Only if all three gates pass does it conclude that initial costs exist (`true`). Any null or missing map at any level short-circuits to `false`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outputMap` | `HashMap<String, Object>` | The output data structure carrying pricing and fee information assembled by prior SC (Service Component) calls. It contains nested maps organized by processing-area identifiers (e.g., `"FUSV006901CC"`), where each sub-map holds business data such as initial cost detail lists (`"EKK0721A010CBSMsg1List"`). |

**Instance fields / external state read:** None. This method is fully stateless and depends only on the parameter.

## 4. CRUD Operations / Called Services

This method performs **no database operations** and **no service component (SC/CBS) calls**. It is a pure data inspection method that reads from the `outputMap` parameter (already populated by prior service calls) and returns a boolean flag.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (none) | — | — | — | No direct CRUD operations. This method inspects in-memory data structures already populated by earlier SC/CBS calls (specifically, `FUSV006901SC` which populates the service info area). |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0250 (internal) | `FUW02501SFLogic.setPayFlg()` / `getMansionDiv()` -> `FUW02501SFLogic.chkPayInitialCost()` | — (no terminal CRUD; reads outputMap populated by `FUSV006901SC`, `FUSV006903SC`) |
| 2 | Screen:KKSV0200 (internal) | `FUW02001SFLogic` -> `chkPayInitialCost()` | — |
| 3 | Screen:KKSV0350 (internal) | `FUW03501SFLogic` -> `chkPayInitialCost()` | — |
| 4 | Screen:KKSV0370 (internal) | `FUW03701SFLogic` -> `chkPayInitialCost()` | — |
| 5 | Screen:KKSV0390 (internal) | `FUW03901SFLogic` -> `chkPayInitialCost()` | — |
| 6 | Screen:KKSV0400 (internal) | `FUW04001SFLogic` -> `chkPayInitialCost()` | — |
| 7 | Screen:KKSV0190 (internal) | `FUW01901SFLogic` -> `chkPayInitialCost()` | — |
| 8 | Screen:KKSV0210 (internal) | `FUW02101SFLogic` -> `chkPayInitialCost()` | — |
| 9 | Screen:KKSV0230 (internal) | `FUW02301SFLogic` -> `chkPayInitialCost()` | — |
| 10 | Screen:KKSV0770 (internal) | `FUW07701SFLogic` -> `chkPayInitialCost()` | — |

**Notes:**
- In `FUW02501SFLogic` (line 352), `chkPayInitialCost(outputMap)` is called as part of a conditional: `payFlg || chkPayInitialCost(outputMap)` — used to determine whether to display initial cost information in the pricing table.
- In the calling `getMansionDiv()` method, the result feeds into mansion-type branching for multi-dwelling unit payment style control.
- The method is duplicated (overloaded/renamed) in 9 other `FUWxxxxSFLogic` classes with identical logic, indicating it is a **copy-paste pattern** widely reused across the web screen logic layer.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(outputMap.containsKey(CC_TITLE_FUSV006901))` (`"FUSV006901CC"`) (L736)

> Check whether the output map contains the service information processing area sub-map. If present, extract it as the parent map for further inspection.

| # | Type | Code |
|---|------|------|
| 1 | SET | `parentMap = (HashMap<String, Object>)outputMap.get(CC_TITLE_FUSV006901)` // Extract parent area map — resolves `CC_TITLE_FUSV006901` to `"FUSV006901CC"` |

**Block 2** — IF `(null != parentMap && parentMap.containsKey(EKK0721A010_LIST))` (`EKK0721A010CBSMsg1List`) (L742)

> Check whether the parent area map is not null and contains the initial cost detail list. If so, retrieve the child list for item count evaluation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childList = (ArrayList<HashMap<String, Object>>)parentMap.get(EKK0721A010_LIST)` // Resolve `EKK0721A010_LIST` to `"EKK0721A010CBSMsg1List"` — retrieves the initial cost detail item list |

**Block 3** — IF `(childList != null && childList.size() > 0)` (L744)

> **True branch:** The child list is present and contains at least one item. This means the customer has initial cost(s) to pay.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = true` // Initial cost exists — at least one line item found in the initial cost detail list |

**Block 4** — ELSE (L748)

> **False branch:** The child list is either null or empty. No initial cost detail items were populated, meaning this customer has no upfront fees.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // No initial cost — the detail list is empty or null, confirming zero upfront fees |

**Block 5** — RETURN (L757)

> Return the computed boolean flag to the caller.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chkPayInitialCost` | Method | Initial cost existence check — determines whether the customer owes any upfront/one-time setup fees |
| `初期費用` (Shoki-hiyou) | Japanese term | Initial cost / setup fee — one-time charge for new service activation (not recurring) |
| `outputMap` | Field | Output data map — carries pricing, fee, and service information between SC calls and screen logic |
| `CC_TITLE_FUSV006901` | Constant | Processing area identifier `"FUSV006901CC"` — key for the service information processing area sub-map within `outputMap` |
| `EKK0721A010_LIST` | Constant | Detail list key `"EKK0721A010CBSMsg1List"` — key for the initial cost detail item list within the processing area |
| `FUSV006901SC` | Service Component | Service information acquisition SC — populates the `CC_TITLE_FUSV006901` area in `outputMap` with pricing details |
| `PAY_FLG` | Field | Payment flag — boolean indicating whether any charges (recurring or initial) apply to this contract |
| `getMansionDiv` | Method | Mansion type division — determines if the customer is a mansion-type (multi-dwelling unit) customer with shared payment, used for UI branching |
| `MANSION_DIV` | Field | Mansion division flag — true when customer is in a multi-dwelling unit with single-head payment arrangement |
| `FUSV006903SC` | Service Component | Service cost SC — acquires pricing/cost information for the service contract |
| `SC` | Acronym | Service Component — a service-layer class that encapsulates a single business operation (data access + business rules) |
| `CBS` | Acronym | Central Business System — the core backend system that stores customer orders, services, and billing data |
| `X31SDataBeanAccess` | Class | Data bean access utility — framework class for reading/writing structured data beans in the X31 web framework |
| `X31CWebConst` | Class | Web constants — framework constants for data bean get/set operations (`DATABEAN_SET_VALUE`, `DATABEAN_GET_VALUE`) |
| `ArrayList` | Type | Dynamic array — holds the list of initial cost detail items; size > 0 means at least one fee line exists |
| `KKSVxxxx` | Screen ID | Web screen identifier pattern — `KKSV0250` is the Mansion Information screen using FUW02501SF |
| `FUW02501SF` | Module | Screen logic module — handles mansion information service processing for screen KKSV0250 |
