# Business Logic — JBSBatKKKkOpDlRvChsht.getZaikoCntUpdFlg() [16 LOC]

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

## 1. Role

### JBSBatKKKkOpDlRvChsht.getZaikoCntUpdFlg()

This method determines whether the inventory (stock) count for a delivered customer device should be updated as part of the device/optical service contract cancellation/reservation extraction batch (`JBSBatKKKkOpDlRvChsht`). It implements a gate-check pattern: the inventory count update flag is set to ON only when a home device model code is present in the incoming map **and** the delivery status equals "001" (Delivered / 配送済 — indicating the device has already been physically delivered to the customer). If either condition fails, the flag remains blank (empty string), meaning no inventory adjustment should occur. The method operates as a shared utility called exclusively by the batch's `execute()` method, which maps its result to the output field `ZAIKO_CNT_UPD_FLG` for downstream processing. It does not perform any CRUD operations itself; it purely evaluates input state to drive a downstream decision.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getZaikoCntUpdFlg inMap"])
    INIT["flg = empty string"]
    READ_MODEL["getCsv DK0021_KKTAKNKIKI_MODEL_CD inMap"]
    READ_HAISO["getCsv HAISO_STAT inMap"]
    COND1{model_cd is not blank?}
    COND2{HAISO_STAT equals CD00009_HAISO_STAT_001?}
    SET_ON["flg = FLG_ON"]
    RETURN_FLG["return flg"]
    END_NODE(["Return Next"])

    START --> INIT
    INIT --> READ_MODEL
    READ_MODEL --> READ_HAISO
    READ_HAISO --> COND1
    COND1 -->|false| RETURN_FLG
    COND1 -->|true| COND2
    COND2 -->|false| RETURN_FLG
    COND2 -->|true| SET_ON
    SET_ON --> RETURN_FLG
    RETURN_FLG --> END_NODE
```

**Block-level description:**

1. Initialize `flg` to an empty string (indicating "do not update inventory count").
2. Read the home device model code (`DK0021_KKTAKNKIKI_MODEL_CD`) from the input map via `getCsv`.
3. Read the delivery status (`HAISO_STAT`) from the input map via `getCsv`.
4. Evaluate two conditions: the model code must be non-blank, AND the delivery status must equal `CD00009_HAISO_STAT_001` (value `"001"`, meaning "Delivered").
5. If both conditions are true, set `flg` to `FLG_ON` (value `"1"`); otherwise `flg` remains blank.
6. Return `flg`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The batch input map carrying extracted device and service order data for the current record being processed by the cancellation/reservation batch. Contains keys such as `DK0021_KKTAKNKIKI_MODEL_CD` (home device model code) and `HAISO_STAT` (delivery status). |

**External/instance state read:**
- `BLANK` (resolved value: `""`) — A blank/string-check constant used to validate the model code field. Commonly inherited or defined in base classes across the framework.
- `FLG_ON` (resolved value: `"1"`) — An on/off flag constant used throughout the batch to indicate affirmative states.
- `getCsv()` — A helper method inherited from `JBSbatBusinessService` that performs a key-based string lookup in the input map.

## 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 a String value from `inMap` by key (two calls: model code and delivery status). This is a map-get operation, not a DB read. |

**Classification rationale:**
- `getCsv()` is a read-only map lookup — it extracts values from the input `JBSbatServiceInterfaceMap`. It does not query any database table directly; the data was previously loaded by the batch's extract 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]

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

**Notes:**
- The only caller is the batch's own `execute()` method, which sets the result into `outMap.setString(JBSbatKKIFM554.ZAIKO_CNT_UPD_FLG, getZaikoCntUpdFlg(inMap))`.
- This is a private utility method within the same batch class. It is not called by any screen, CBS, or external entry point.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L266)

> Initialize the return flag variable to an empty string, representing "no inventory count update needed."

| # | Type | Code |
|---|------|------|
| 1 | SET | `flg = ""` // Initialize flag to empty (false) |

**Block 2** — [IF-ELSE] `(!BLANK.equals(getCsv(DK0021_KKTAKNKIKI_MODEL_CD, inMap)) && JBSbatKKConst.CD00009_HAISO_STAT_001.equals(getCsv(HAISO_STAT, inMap)))` (L270)

> Evaluate both conditions: the home device model code must be present (non-blank), and the delivery status must equal "001" (Delivered). Only when both are true should the inventory count update flag be activated. This is a v22.00.00 change — the condition previously used a local constant `DK0021_STAT_001` but was refactored to use the central `JBSbatKKConst.CD00009_HAISO_STAT_001` constant as part of the project normalization initiative.

| # | Type | Code |
|---|------|------|
| 1 | SET | `modelCd = getCsv(DK0021_KKTAKNKIKI_MODEL_CD, inMap)` // Home device model code [-> DK0021_KKTAKNKIKI_MODEL_CD="DK0021_KKTAKNKIKI_MODEL_CD"] |
| 2 | SET | `haisoStat = getCsv(HAISO_STAT, inMap)` // Delivery status [-> HAISO_STAT="HAISO_STAT"] |
| 3 | IF | `!BLANK.equals(modelCd)` // Model code must not be empty [-> BLANK=""] |
| 4 | IF | `JBSbatKKConst.CD00009_HAISO_STAT_001.equals(haisoStat)` // Delivery status must be "001" (Delivered) [-> CD00009_HAISO_STAT_001="001"] |
| 5 | SET | `flg = FLG_ON` // Set flag ON — inventory count should be updated [-> FLG_ON="1"] |
| 6 | ELSE | (either model blank or status != "001") — `flg` remains `""` |

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

> Return the evaluated flag value to the caller (`execute()` method), which maps it to the output field `ZAIKO_CNT_UPD_FLG`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return flg` // "1" if inventory update needed, "" otherwise |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `zaiko` | Field | Inventory / Stock — Japanese term for product stock count. `ZaikoCntUpdFlg` = Inventory Count Update Flag. |
| `haiso` | Field | Delivery / Dispatch — Japanese term for shipment. `HAISO_STAT` = Delivery Status code. |
| `CD00009_HAISO_STAT_001` | Constant | Delivery status code "001" = Delivered (配送済) — The device has been physically delivered to the customer's premises. |
| `DK0021_KKTAKNKIKI_MODEL_CD` | Field | Home Device Model Code (宅内機器型番CD) — Internal model classification code for customer-side terminal equipment (e.g., ONT/ONT router for FTTH services). |
| `ZAIKO_CNT_UPD_FLG` | Field | Inventory Count Update Flag — Output flag indicating whether the downstream process should adjust stock/inventory records for the device. |
| `JBSbatServiceInterfaceMap` | Type | Batch service interface map — A key-value map used to pass data between batch processing steps. |
| `getCsv` | Method | Key-based map value getter — Retrieves a String value from the `JBSbatServiceInterfaceMap` by key name. Inherited from `JBSbatBusinessService`. |
| `FLG_ON` | Constant | Flag-on constant with value `"1"`. Used throughout batch code to indicate affirmative/true states. |
| `BLANK` | Constant | Empty string constant `""`. Used to compare against String fields to check for null/empty values. |
| `JBSBatKKKkOpDlRvChsht` | Class | Device/Optical Service Contract Cancellation/Reservation Extraction Unit — A batch process that extracts and processes device-level data for contract cancellation and reservation workflows. |
| v22.00.00 | Version | Software version 22.00.00 (2015/11/24) — The refactor that standardized constant references from local names to centralized `JBSbatKKConst` definitions. |
