---

# Business Logic — FUW02601SFLogic.getPayFlg() [24 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW02601SF.FUW02601SFLogic` |
| Layer | Service Logic (Webview layer — part of the FUW02601SF screen logic module) |
| Module | `FUW02601SF` (Package: `eo.web.webview.FUW02601SF`) |

## 1. Role

### FUW02601SFLogic.getPayFlg()

This method determines whether the current user's order qualifies as a paid (有料) service or a free (無料) service within the FUW02601SF screen context — a customer-facing screen for viewing and managing service contracts. It performs a straightforward eligibility check by comparing two quantities extracted from the shared data bean: the number of currently available mailing list stock items against the number of free option services allocated to the user. Additionally, it validates that the pricing plan fixed amount is greater than zero, ensuring that a chargeable plan is actually in effect. If both conditions are met — the user has exhausted their free allocation (stock count meets or exceeds the free service count) AND there is an active fixed pricing amount — the method sets the paid flag to true, indicating the user should now be charged. Otherwise, the service remains free. This method implements a simple decision-tree pattern (boolean flag calculation) and serves as a shared utility within the `FUW02601SFLogic` class, invoked by `init()` during screen initialization to populate the UI with the correct payment status indicator.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getPayFlg bean"])
    GET_FREE["GET freeValue from bean MRYO_OP_SVC_CNT Free Option Service Count"]
    GET_ML["GET nowMllistStkuCnt from bean NOW_MLLIST_STKU_CNT Current Mailing List Stock Count"]
    GET_AMNT["GET tanka from bean PPLAN_KOTEI_AMNT Pricing Plan Fixed Amount"]
    INIT_FLG["SET payFlg = false"]
    COND_FREE["Is nowMllistStkuCnt >= freeValue AND tanka > 0?"]
    COND_SET_TRUE["SET payFlg = true"]
    COND_SET_FALSE["SET payFlg = false (no change)"]
    END_RETURN["Return payFlg"]

    START --> GET_FREE
    GET_FREE --> GET_ML
    GET_ML --> GET_AMNT
    GET_AMNT --> INIT_FLG
    INIT_FLG --> COND_FREE
    COND_FREE -- Yes: Stock exhausted AND charge applies --> COND_SET_TRUE
    COND_FREE -- No --> COND_SET_FALSE
    COND_SET_TRUE --> END_RETURN
    COND_SET_FALSE --> END_RETURN
```

**Constant Resolution:**

| Constant Key | Resolved Value | Business Meaning |
|-------------|---------------|------------------|
| `MRYO_OP_SVC_CNT` | `"無料オプションサービス数"` (Free Option Service Count) | The number of free-tier service options allocated to the user |
| `NOW_MLLIST_STKU_CNT` | `"現在のメーリングリスト取得数"` (Current Mailing List Stock Count) | The number of mailing list items currently available to the user |
| `PPLAN_KOTEI_AMNT` | `"料金プラン固定金額"` (Pricing Plan Fixed Amount) | The fixed monthly fee for the pricing plan; if 0 or negative, no charge applies |

**Processing flow description:**
1. **Extract free service count** — Reads the free option service count (`freeValue`) from the data bean using the key `MRYO_OP_SVC_CNT`.
2. **Extract current mailing list stock** — Reads the current mailing list stock count (`nowMllistStkuCnt`) from the data bean using the key `NOW_MLLIST_STKU_CNT`.
3. **Extract pricing plan fixed amount** — Reads the pricing plan fixed amount (`tanka`) from the data bean using the key `PPLAN_KOTEI_AMNT`.
4. **Initialize pay flag** — Sets `payFlg` to `false` by default (free by default assumption).
5. **Evaluate paid eligibility** — If the current mailing list stock count is **greater than or equal to** the free option service count **AND** the pricing plan fixed amount is **greater than 0**, set `payFlg` to `true`. Otherwise, keep it `false`.
6. **Return result** — Returns `true` for paid, `false` for free.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `bean` | `X31SDataBeanAccess` | The screen's shared data access object carrying pre-populated service-level values. It holds the free option service count, current mailing list stock count, and pricing plan fixed amount — all required inputs for determining whether the user has exhausted their free tier and should now be charged. |

**Instance fields / external state:** None. This method is fully stateless and derives all values exclusively from the passed-in `bean` parameter.

## 4. CRUD Operations / Called Services

This method does **not** invoke any external services, SC codes, CBS programs, or database operations. All data is retrieved from the in-memory data bean (`X31SDataBeanAccess`) via `sendMessageLong()` calls, which access values already populated by upstream processing.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| *(none)* | — | — | — | — |

**Notes:** The three `sendMessageLong()` calls are local data bean reads (not CRUD operations against the database). The actual population of these values occurs in upstream methods called prior to `getPayFlg()` during screen initialization.

## 5. Dependency Trace

This method is a leaf-level utility called during screen initialization. No downstream service calls or CRUD operations exist.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Logic: `FUW02601SFLogic.init()` | `FUW02601SFLogic.init()` -> `getPayFlg(bean)` | — (no terminal operations) |

**Notes:** The only known caller is `FUW02601SFLogic.init()`, which invokes `getPayFlg(bean)` to compute the paid flag and store it back into the data bean for UI consumption. No screen/batch entry points were found within 8 hops; the entry point is the FUW02601SF screen itself.

## 6. Per-Branch Detail Blocks

**Block 1** — [GET] `(retrieve freeValue)` (L660)

> Reads the free option service count from the data bean. This value represents how many free-tier services the user is entitled to.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `bean.sendMessageLong(MRYO_OP_SVC_CNT, X31CWebConst.DATABEAN_GET_VALUE)` // Gets free option service count [Constant: `MRYO_OP_SVC_CNT` = "無料オプションサービス数" (Free Option Service Count)] |
| 2 | SET | `freeValue = int` // Cast result to int; represents the free service allowance |

**Block 2** — [GET] `(retrieve nowMllistStkuCnt)` (L661)

> Reads the current mailing list stock count. This is the number of mailing list items the user has currently acquired or is allocated.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `bean.sendMessageLong(NOW_MLLIST_STKU_CNT, X31CWebConst.DATABEAN_GET_VALUE)` // Gets current mailing list stock count [Constant: `NOW_MLLIST_STKU_CNT` = "現在のメーリングリスト取得数" (Current Mailing List Stock Count)] |
| 2 | SET | `nowMllistStkuCnt = int` // Cast result to int; represents available stock |

**Block 3** — [GET] `(retrieve tanka)` (L662)

> Reads the pricing plan fixed amount. This is the monthly fixed fee for the pricing plan. If it is 0 or less, the user is not on a chargeable plan.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `bean.sendMessageLong(PPLAN_KOTEI_AMNT, X31CWebConst.DATABEAN_GET_VALUE)` // Gets pricing plan fixed amount [Constant: `PPLAN_KOTEI_AMNT` = "料金プラン固定金額" (Pricing Plan Fixed Amount)] |
| 2 | SET | `tanka = int` // Cast result to int; represents the fixed monthly charge |

**Block 4** — [SET] `(initialize payFlg)` (L664)

> Sets the default paid flag to false. The method assumes free service unless conditions prove otherwise.

| # | Type | Code |
|---|------|------|
| 1 | SET | `payFlg = false` // Default: service is free |

**Block 5** — [IF] `(nowMllistStkuCnt >= freeValue AND tanka > 0)` (L666)

> **Business rule:** The user has exhausted their free-tier allowance (current stock count meets or exceeds the free service count) AND there is an active pricing plan (fixed amount > 0). Both conditions must be true for the user to be charged.
>
> - **Condition 1:** `nowMllistStkuCnt >= freeValue` — The user's current mailing list stock has met or exceeded their free option service count, meaning they have used up all their free allocations.
> - **Condition 2:** `tanka > 0` — The pricing plan has a positive fixed amount, confirming a chargeable plan is in effect.

| # | Type | Code |
|---|------|------|
| 1 | SET | `payFlg = true` // [-> MRYO_OP_SVC_CNT = "無料オプションサービス数", NOW_MLLIST_STKU_CNT = "現在のメーリングリスト取得数", PPLAN_KOTEI_AMNT = "料金プラン固定金額"] Both conditions met: user exhausted free services AND has an active chargeable plan → paid flag set to true |

**Block 5.1** — [ELSE-IF / ELSE] `(default: not paid)` (L670)

> When either the stock count has not yet exceeded the free allowance, OR the pricing plan fixed amount is 0 or less, the service remains free.

| # | Type | Code |
|---|------|------|
| 1 | SET | `payFlg = false` // Explicit no-op; payFlg was already false. User still has free-tier allocation remaining OR no chargeable plan |

**Block 6** — [RETURN] `(return payFlg)` (L676)

> Returns the computed paid flag to the caller. `true` means the user is on a paid service (有料); `false` means the user is on a free service (無料).

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `payFlg` | Field | Paid Flag — boolean indicator of whether the user's service tier requires payment (true = paid/有料, false = free/無料) |
| `freeValue` | Variable | Free Option Service Count — the number of free-tier services allocated to the user for the current plan |
| `nowMllistStkuCnt` | Variable | Current Mailing List Stock Count — the number of mailing list items the user has currently acquired; compared against free allowance to determine if free tier is exhausted |
| `tanka` | Variable | Pricing Plan Fixed Amount — the monthly fixed fee for the user's pricing plan; a value of 0 means no charge applies |
| MRYO_OP_SVC_CNT | Constant | Free Option Service Count (`無料オプションサービス数`) — the bean key for the user's free-tier service allowance |
| NOW_MLLIST_STKU_CNT | Constant | Current Mailing List Stock Count (`現在のメーリングリスト取得数`) — the bean key for the user's current mailing list stock level |
| PPLAN_KOTEI_AMNT | Constant | Pricing Plan Fixed Amount (`料金プラン固定金額`) — the bean key for the monthly fixed fee of the pricing plan |
| X31SDataBeanAccess | Class | Shared data access bean — a screen-level object that carries all business data between screen components, providing typed accessors for values populated by upstream processing |
| FUW02601SF | Module | Screen module for service contract information view/management — a customer-facing web screen in the enterprise portal |
| 有料 (Yurio) | Japanese term | Paid/Chargeable — indicates a service tier that requires payment |
| 無料 (Muryo) | Japanese term | Free — indicates a service tier with no charge |
| メーリングリスト (Meiling Risuto) | Japanese term | Mailing List — in this context, refers to a pool of downloadable/acquirable items or content associated with the user's service subscription |

---
