# Business Logic — JBSBatKKKkOpDlRvChsht.getHmpnKikiUkFlg() [17 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSBatKKKkOpDlRvChsht` |
| Layer | Service (Batch processing — package `eo.business.service` in `koptBatch`) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSBatKKKkOpDlRvChsht.getHmpnKikiUkFlg()

This method determines whether the current batch record involves a **return device** (返品機器) that is accepted for processing by inspecting the delivery status code embedded in the input parameter map. Specifically, it reads the `HAISO_STAT` (delivery status) field from the input map via the `getCsv()` accessor and checks whether the status is one of the three return-related codes: `"002"`, `"003"`, or `"004"`. If a match is found, the method returns `"1"` (the `FLG_ON` flag), signaling to the caller that a return device is present and should be handled accordingly. If none of the return-related statuses are found, it returns an empty string, indicating no return device processing is required. This method acts as a **predicative guard** within the batch's `execute()` flow — it enables conditional branching on whether return-device-specific logic (such as device removal from address-change targets) needs to be executed for a given service contract record. The method uses a version-gated conditional block (v22.00.00) that replaced older commented-out status constants with the new `CD00009_HAISO_STAT_*` series, reflecting a system-wide migration of delivery status code definitions.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getHmpnKikiUkFlg(inMap)"])
    INIT["flg = empty string"]
    READ["getCsv - Read HAISO_STAT from input map"]
    COND{HAISO_STAT match?}
    BRANCH_002["HAISO_STAT = 002"]
    BRANCH_003["HAISO_STAT = 003"]
    BRANCH_004["HAISO_STAT = 004"]
    SET_FLG["flg = 1 (FLG_ON)"]
    ELSE_BRANCH["No match - flg empty"]
    RETURN["Return flg"]
    END_RETURN(["Return"])

    START --> INIT
    INIT --> READ
    READ --> COND
    COND --> BRANCH_002
    COND --> BRANCH_003
    COND --> BRANCH_004
    COND --> ELSE_BRANCH
    BRANCH_002 --> SET_FLG
    BRANCH_003 --> SET_FLG
    BRANCH_004 --> SET_FLG
    ELSE_BRANCH --> RETURN
    SET_FLG --> RETURN
    RETURN --> END_RETURN
```

**Conditional Branch Details:**

| Branch | Condition | Constant Value | Business Meaning |
|--------|-----------|---------------|-----------------|
| v22.00.00 | `CD00009_HAISO_STAT_002` | `"002"` | Delivery status: Returned (返品済み) — device has been returned |
| v22.00.00 | `CD00009_HAISO_STAT_003` | `"003"` | Delivery status: Return scheduled (返品予定) — device return is pending |
| v22.00.00 | `CD00009_HAISO_STAT_004` | `"004"` | Delivery status: Return completed (返品完了) — return process is fully closed |
| Deprecated (commented out) | `DK0021_STAT_002` | — | Pre-v22 delivery status code, removed during code migration |
| No match | — | — | Status is not a return-related code; method returns empty string |

**Constant Resolutions:**
- `JBSbatKKConst.CD00009_HAISO_STAT_002` = `"002"` — Delivery status code for "returned" (返品済み)
- `JBSbatKKConst.CD00009_HAISO_STAT_003` = `"003"` — Delivery status code for "return scheduled" (返品予定)
- `JBSbatKKConst.CD00009_HAISO_STAT_004` = `"004"` — Delivery status code for "return completed" (返品完了)
- `FLG_ON` = `"1"` — Flag value indicating "ON/true" for return device acceptance
- `JBSbatKKIFM553.HAISO_STAT` = `"HAISO_STAT"` — Map key for the delivery status field

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The batch service interface map carrying all input data for the current processing record. It contains delivery status (`HAISO_STAT`) and other service-level fields that the batch job reads via `getCsv()` accessor methods. The map represents a single service contract or device record being processed by the batch. |

**Instance Fields / External State Read:**
- `FLG_ON` — Private static final constant = `"1"`, used as the affirmative flag value for return device acceptance.
- `JBSbatKKConst.CD00009_HAISO_STAT_*` — Static constants from the delivery status code definition class, representing return-related delivery statuses.
- `JBSbatKKIFM553.HAISO_STAT` — Static constant `"HAISO_STAT"`, the map key used to extract the delivery status value from `inMap`.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSBatKKKkOpDlRvChsht.getCsv` | - | - | Reads the `HAISO_STAT` (delivery status) field from the input map `inMap`. This is an in-memory data access, not a database query. |

**Classification:** The `getCsv()` call is a **Read (R)** operation on the input map. It does not touch any database or external system directly; it retrieves the `HAISO_STAT` value already present in the `inMap` that was populated by the batch's upstream data loading phase.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `getCsv` [R], `getCsv` [R], `getCsv` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSBatKKKkOpDlRvChsht.execute()` | `execute()` -> `getHmpnKikiUkFlg(inMap)` | `getCsv [R] HAISO_STAT` |

**Notes:**
- The method is called directly from the `execute()` method of the same class (`JBSBatKKKkOpDlRvChsht`), which serves as the batch's main processing entry point.
- Within `execute()`, the result of `getHmpnKikiUkFlg()` is used in a conditional check: `if(FLG_ON.equals(getHmpnKikiUkFlg(inMap)))` (line 165), which gates whether return-device-specific processing should proceed.
- The method does not call any external services, DB queries, or screen components — its only side effect is reading from the input map.

## 6. Per-Branch Detail Blocks

**Block 1** — [VARIABLE INITIALIZATION] (L290)

> Initialize the return flag variable to an empty string. This is the default "OFF" state — if no return-related status is detected, this value propagates to the return.

| # | Type | Code |
|---|------|------|
| 1 | SET | `flg = ""` // Initialize return device acceptance flag to empty (OFF state) |

**Block 2** — [IF-ELSE-IF-IF OR CHAIN] `(delivery status is return-related)` (L292–L297)

> v22.00.00 change begins: Replace legacy commented-out constants with new `CD00009_HAISO_STAT_*` codes. The method checks if the delivery status from the input map is any of three return-related codes. If so, the return device acceptance flag is set to ON.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `getCsv(JBSbatKKIFM553.HAISO_STAT, inMap)` // Read delivery status from input map [-> `HAISO_STAT` key] |
| 2 | IF-ELSEIF-OR | `CD00009_HAISO_STAT_002 == getCsv(...)` [-> `CD00009_HAISO_STAT_002 = "002"` (返品済み / Returned)] (L292) |
| 3 | IF-ELSEIF-OR | `CD00009_HAISO_STAT_003 == getCsv(...)` [-> `CD00009_HAISO_STAT_003 = "003"` (返品予定 / Return scheduled)] (L293) |
| 4 | IF-ELSEIF-OR | `CD00009_HAISO_STAT_004 == getCsv(...)` [-> `CD00009_HAISO_STAT_004 = "004"` (返品完了 / Return completed)] (L294) |

**Block 2.1** — [ELSE branch of Block 2 — No match] (L295–L296)

> None of the delivery status codes matched. The `flg` variable remains its initialized empty string value. The v22.00.00 migration comments (`変更開始` / `変更終了`) bracket this block, indicating this is the revised logic section.

| # | Type | Code |
|---|------|------|
| 1 | SET | *(implicit)* `flg` remains `""` // No action — flag stays OFF |

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

> Return the computed flag. Either `"1"` if a return device was detected, or empty string if not.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return flg;` // Return return device acceptance flag |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `getHmpnKikiUkFlg` | Method | Return device acceptance flag getter — determines if current record involves a returned device |
| `hmpn` | Acronym | 返品 (Hentai) — Return (of a device) |
| `kiki` | Acronym | 機器 (Kiki) — Device / Equipment |
| `ukFlg` | Acronym | 受付フラグ (Uketsuke Flag) — Acceptance Flag |
| `HAISO_STAT` | Field | Delivery status code — indicates the current state of device delivery (e.g., returned, scheduled for return, completed return). Stored in `JBSbatKKIFM553.HAISO_STAT` as map key `"HAISO_STAT"`. |
| `CD00009_HAISO_STAT_002` | Constant | Delivery status `"002"` — 返品済み (Returned) — Device has been physically returned |
| `CD00009_HAISO_STAT_003` | Constant | Delivery status `"003"` — 返品予定 (Return scheduled) — Device return is pending/scheduled |
| `CD00009_HAISO_STAT_004` | Constant | Delivery status `"004"` — 返品完了 (Return completed) — Return process is fully closed |
| `FLG_ON` | Constant | Flag value `"1"` — Indicates affirmative/ON state for boolean-like flags in the batch system |
| `JBSbatServiceInterfaceMap` | Type | Batch service interface map — carries input/output data for a single batch processing record |
| `JBSbatKKConst` | Class | Delivery status code constant definitions — central repository of status code values for the KK (batch) layer |
| `JBSbatKKIFM553` | Class | Interface map field constants — defines map key strings (e.g., `HAISO_STAT`) for the batch I/O format |
| `getCsv` | Method | Map accessor — retrieves a string value from the `JBSbatServiceInterfaceMap` by field name key |
| v22.00.00 | Version | Version gate — the code migration from legacy `DK0021_STAT_*` constants to `CD00009_HAISO_STAT_*` constants |
