# Business Logic — FUW03501SFLogic.setPayFlg() [28 LOC]

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

## 1. Role

### FUW03501SFLogic.setPayFlg()

This method determines whether a dial-up connection service contract is chargeable (有料) or free of charge (無料) during the service registration flow. It belongs to the `FUW03501SF` module, which handles dial-up connection service applications — the business domain covers telecom-style dial-up internet access subscriptions where customers may or may not be eligible for promotional free-service periods.

The method implements a two-factor pricing logic: it evaluates both the presence of a fixed unit price (固定単価) configured for the service plan and the number of free-service counts (無料数) remaining. If a fixed price exists and there are zero free-service counts remaining, the service is deemed chargeable (return `true`). If a fixed price exists but free-service counts are available, or if no fixed price is configured at all, the service is deemed free (return `false`).

The design pattern used here is a **guard-and-route** conditional dispatch: the method first fetches the free-service count from the data bean, then delegates the fixed-price validation to the private helper method `chkPayKoteiTanka()`, and finally combines both signals into a single billing flag. Its role in the larger system is as an internal decision utility — called during the `init()` processing phase of the `FUW03501SF` screen logic — to populate the output map with a payment status flag that downstream components (e.g., confirmation screens, order submission) use to determine whether to display pricing information to the customer.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setPayFlg(bean, outputMap)"])
    INIT["Initialize res = false"]
    GET_MURYO["Get muryoCnt from bean<br/>sendMessageString(DIAL_CONNECT_KEI_MURYO, DATABEAN_GET_VALUE)<br/>Free service count (ダイアアップ接続契約無料数)"]
    CALL_CHK["Call chkPayKoteiTanka(outputMap)<br/>Check if fixed unit price exists"]
    COND_CHK{"chkPayKoteiTanka<br/>= true?"}
    COND_MURYO{"muryoCnt <= 0?"}
    SET_PAY_TRUE["Set res = true<br/>有料 (chargeable)"]
    SET_PAY_FALSE_1["Set res = false<br/>無料 (free)"]
    SET_PAY_FALSE_2["Set res = false<br/>固定単価なし (no fixed price)"]
    RETURN["Return res"]

    START --> INIT --> GET_MURYO --> CALL_CHK --> COND_CHK
    COND_CHK -->|true| COND_MURYO
    COND_CHK -->|false| SET_PAY_FALSE_2
    COND_MURYO -->|true| SET_PAY_TRUE
    COND_MURYO -->|false| SET_PAY_FALSE_1
    SET_PAY_TRUE --> RETURN
    SET_PAY_FALSE_1 --> RETURN
    SET_PAY_FALSE_2 --> RETURN
```

**Constant Resolution:**
- `FUW03501SFConst.DIAL_CONNECT_KEI_MURYO` = `"ダイアアップ接続契約無料数"` (Dial-up connection contract free count) — the data bean key used to retrieve the remaining free-service count for the dial-up connection service.
- `X31CWebConst.DATABEAN_GET_VALUE` — standard X31 framework constant indicating a "get value" operation on the data bean.

**Business Logic Summary:**

| Branch | Condition | Business Meaning | Result |
|--------|-----------|------------------|--------|
| 1 | `chkPayKoteiTanka` = true AND `muryoCnt <= 0` | Fixed price configured AND no free-service counts remaining | `true` — chargeable (有料) |
| 2 | `chkPayKoteiTanka` = true AND `muryoCnt > 0` | Fixed price configured AND free-service counts still available | `false` — free (無料) |
| 3 | `chkPayKoteiTanka` = false | No fixed price configured at all | `false` — free (無料) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `bean` | `X31SDataBeanAccess` | The X31 framework data bean access object used to retrieve business data values. Specifically, it is queried for the dial-up connection service free-count field (`DIAL_CONNECT_KEI_MURYO`), which represents the number of remaining free-service periods allocated to the customer's subscription. |
| 2 | `outputMap` | `HashMap<Object, Object>` | A shared output map containing the service configuration data passed from upstream processing. It holds the pricing plan information (under key `FUSV007301SC`) that is used by `chkPayKoteiTanka()` to determine whether a fixed unit price is configured for the service. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `FUSV007301SC` | `static final String` | Constant key `"FUSV007301SC"` — identifies the pricing service component map within `outputMap`. Referenced indirectly via `chkPayKoteiTanka()`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `OneStopDataBeanAccess.sendMessageString` | — | — | Reads the free-service count (`DIAL_CONNECT_KEI_MURYO = "ダイアアップ接続契約無料数"`) from the data bean. This is a value retrieval (Read) operation on the bean's stored state. |
| R | `chkPayKoteiTanka` | — | — | Reads fixed pricing plan data from `outputMap` (key `FUSV007301SC`) and iterates over the pricing plan list (`EKK0591B001CBSMsg1List`) to check if any plan has a fixed unit price greater than 0 yen. This is a read-only evaluation with no data mutation. |

**Classification rationale:**

- `sendMessageString` is a **Read (R)** operation — it retrieves a single scalar value from the bean without modifying any persistent state.
- `chkPayKoteiTanka` is a **Read (R)** operation — it navigates through `outputMap` entries, extracts an `ArrayList` of pricing plan items (`EKK0591B001CBSMsg1List`), and compares the `PPLAN_KOTEI_AMNT` (料金プラン固定金額 = pricing plan fixed amount) field against 0. No create, update, or delete operations occur.

There are no direct database CRUD operations performed by `setPayFlg` or its called helper `chkPayKoteiTanka`. Both methods are in-memory data evaluation.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Logic: `FUW03501SFLogic.init()` | `FUW03501SFLogic.init()` -> `FUW03501SFLogic.setPayFlg(bean, outputMap)` | `sendMessageString` [R] bean data; `chkPayKoteiTanka` [R] outputMap (EKK0591B001CBSMsg1List) |

**Caller Details:**
- `init()` is the initialization method within `FUW03501SFLogic`. It sets up the service logic state, including determining whether the dial-up connection service is chargeable or free, by invoking `setPayFlg()`. The result influences subsequent processing such as confirmation display and order submission behavior.

## 6. Per-Branch Detail Blocks

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

Initialize the return variable to the default (free) state.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Initialize return value to free (無料) |

**Block 2** — [EXEC] (L713)

Retrieve the free-service count from the data bean by sending a message with the dial-up connection free-count key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `muryoCnt = Integer.parseInt(bean.sendMessageString(FUW03501SFConst.DIAL_CONNECT_KEI_MURYO, X31CWebConst.DATABEAN_GET_VALUE))` // Get free count (無料数を取得) [-> DIAL_CONNECT_KEI_MURYO = "ダイアアップ接続契約無料数"] |

**Block 3** — [IF] `(chkPayKoteiTanka(outputMap))` (L715)

Check whether a fixed unit price (固定単価) exists for the service plan. This delegates to the private helper method `chkPayKoteiTanka()`, which examines the pricing plan list in `outputMap` for any entry with a fixed amount greater than 0 yen.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `chkPayKoteiTanka(outputMap)` // Evaluate fixed pricing existence |

**Block 3.1** — [IF] `(muryoCnt <= 0)` (L717)

Nested condition: the fixed price exists AND there are no free-service counts remaining. The service is chargeable.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = true` // Chargeable: fixed price exists AND no free count (固定単価あり & 無料数なし) |

**Block 3.2** — [ELSE] (L722)

Nested else: the fixed price exists but free-service counts are still available. The service remains free due to the promotional free count.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Free: fixed price exists AND free count available (固定単価あり & 無料数あり) |

**Block 4** — [ELSE] (L726)

Else branch of the outer `chkPayKoteiTanka()` condition: no fixed price is configured for this service. The service is treated as free by default.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Free: no fixed price configured (固定単価なし) |

**Block 5** — [RETURN] (L732)

Return the computed billing flag.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return res` // true = 有料 (chargeable), false = 無料 (free) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `setPayFlg` | Method | Set Pay Flag — determines if a service contract is chargeable (有料) or free (無料) |
| `chkPayKoteiTanka` | Method | Check Fixed Unit Price — evaluates whether a fixed pricing plan (固定単価) is configured for the service |
| `muryoCnt` | Field | Free count (無料数) — number of remaining free-service periods allocated to the customer |
| `res` | Field | Return value — true indicates chargeable (有料), false indicates free (無料) |
| `DIAL_CONNECT_KEI_MURYO` | Constant | Dial-up connection contract free count key — bean field identifier for retrieving free-service count (ダイアアップ接続契約無料数) |
| `FUSV007301SC` | Constant | Pricing service component key — identifies the pricing plan data map in `outputMap` |
| `EKK0591B001CBSMsg1List` | Constant | Pricing plan list key — identifies the list of pricing plan entries in the CBS message schema (料金プラン一覧照会) |
| `PPLAN_KOTEI_AMNT` | Constant | Pricing plan fixed amount field — the fixed unit price value within a pricing plan entry (料金プラン固定金額) |
| `outputMap` | Parameter | Shared output map — carries service configuration and pricing data between processing stages |
| `bean` | Parameter | X31SDataBeanAccess — framework data bean accessor for retrieving/storing business data values |
| 有料 (yuryou) | Japanese term | Chargeable — the service has an associated cost; the customer must pay |
| 無料 (muryou) | Japanese term | Free of charge — the service is provided at no cost to the customer |
| 固定単価 (kotei tanka) | Japanese term | Fixed unit price — a predetermined per-service fixed cost |
| ダイアアップ接続契約 | Japanese term | Dial-up connection contract — telecom dial-up internet access subscription service |
| FUW03501SF | Module | Dial-up connection service application screen module — handles the full lifecycle of dial-up service registration |
| X31 framework | Technical term | Fujitsu's web application framework — provides data bean access (`X31SDataBeanAccess`), constants (`X31CWebConst`), and message result handling |
