# Business Logic — JFUTelOptSvcMskmCmpCC.jdgHiChrg() [122 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JFUTelOptSvcMskmCmpCC` |
| Layer | CC / Common Component (Shared business logic component within the B2B telecom order management layer) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JFUTelOptSvcMskmCmpCC.jdgHiChrg()

This method performs **non-charging determination processing** (非課金判定処理) for option and sub-option service contracts within the e-Opticom telecommunications order management system. Its primary business purpose is to decide whether a cancelled option or sub-option service should be treated as "non-charged" (i.e., no billing is required for the remaining period) or whether residual charges apply. The method acts as a **delegation router**: it branches by service division (`svc_div`), handling option services (`svc_div="1"`), sub-option services (`svc_div="2"`), or both simultaneously. For each service type, it inspects the service contract status to determine whether the service was actively in use (status `CD00037_100` — "in service"). If the service is in use, it builds a target data map and delegates to `JKKBpCommon.jdgHiChrg()` for the core non-charging rule evaluation (which involves the underlying `JKKHiChrgJdgUtil` utility). If the service is not in use, it defaults to marking the service as non-charged with a charge end date one day before the operation date. The method implements a **collector/accumulator pattern**: results from option and sub-option branches are merged into a single `returnMap`, enabling the caller to receive consolidated non-charging determination results for both service types in one invocation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["jdgHiChrg"])
    END_NODE(["Return returnMap"])

    START --> InitMap["Create returnMap"]
    InitMap --> GetUserData["Get userData from param.getData(fixedText)"]
    GetUserData --> GetOpSvcCd["Get OP_SVC_CD from dataMap"]
    GetOpSvcCd --> GetSvcDiv["Get svc_div from dataMap"]
    GetSvcDiv --> GetOpeDate["Call JFUBPCommon.getOpeDate"]
    GetOpeDate --> CheckSvcDiv{"svc_div is '1' or '2'?"}

    CheckSvcDiv -->|"Yes"| GetSvcChrgSta["Call getSvcChrgStartYMD"]
    GetSvcChrgSta --> GetOpSvcKeiStat["Get op_svc_kei_stat from dataMap"]
    GetOpSvcKeiStat --> GetSvcStaYmd["Get svc_staymd from dataMap"]
    GetSvcStaYmd --> CheckOpSvcKeiStat{"op_svc_kei_stat equals CD00037_100? (in service)"}

    CheckOpSvcKeiStat -->|"Yes"| BuildOpTarget["Build trgtDataOp: dslSbtFlg=2, svcKeiChrgStaYmd, opSvcCd, opSvcUseStaYmd, opSvcUseEndYmd"]
    BuildOpTarget --> CallJKKBpOp["Call JKKBpCommon.jdgHiChrg(trgtDataOp)"]
    CallJKKBpOp --> MapOpResults["Map svcChrgEndYmd and chrgFlg to returnMap"]

    CheckOpSvcKeiStat -->|"No"| CalcOpEnd["Set svcChrgEndYmd = addDay(opeDate, -1)"]
    CalcOpEnd --> SetOpFlg["Set dslji_chrg_flg = CD00002_0 (not charged)"]
    SetOpFlg --> MergeOp["Merge into returnMap"]

    MergeOp --> CheckSubSvcDiv{"svc_div equals '2'?"}
    CheckSubSvcDiv -->|"Yes"| InitSubData["Call JFUBPCommon.initData for EKK0401A010"]
    InitSubData --> SetInMap["Call setInMapEKK0401A010"]
    SetInMap --> ExecSubSC["Call JFUBPCommon.executeSC for EKK0401A010"]
    ExecSubSC --> GetSubStat["Get sbopSvcKeiStat via getTemplateListValue"]
    GetSubStat --> GetSubSvcSta["Get svcStaYmd via getTemplateListValue"]
    GetSubSvcSta --> CheckSubStat{"sbopSvcKeiStat equals CD00037_100? (in service)"}

    CheckSubStat -->|"Yes"| BuildSbopTarget["Build trgtDataSbop: dslSbtFlg=3, svcKeiChrgStaYmd, subOpSvcUseStaYmd, subOpSvcUseEndYmd"]
    BuildSbopTarget --> CallJKKBpSbop["Call JKKBpCommon.jdgHiChrg(trgtDataSbop)"]
    CallJKKBpSbop --> MapSbopResults["Map svcChrgEndYmd and chrgFlg to returnMap"]

    CheckSubStat -->|"No"| CalcSbopEnd["Set svcChrgEndYmd = addDay(opeDate, -1)"]
    CalcSbopEnd --> SetSbopFlg["Set dslji_chrg_flg = CD00002_0"]
    SetSbopFlg --> MergeSbop["Merge into returnMap"]

    CheckSubSvcDiv -->|"No"| ReturnMap
    MapSbopResults --> ReturnMap
    MergeSbop --> ReturnMap
    MergeOp --> ReturnMap
    ReturnMap(["Return returnMap"])
```

**Block-by-block constant resolution:**

- `OP_SVC_CD` → `"op_svc_cd"` — Option service code (the code identifying which option service the customer subscribed to, e.g., IP address service, email service, etc.)
- `svc_div` → `"svc_div"` with values `"1"` = **Option service** (オプション) and `"2"` = **Sub-option service** (サブオプション)
- `CD00037_100` → Service contract status code representing **"in service"** (サービス提供中) — used to check whether the service is currently active
- `CD00002_0` → Non-charged flag value indicating **no charge** (非課金) applies
- `dslSbtFlg = "2"` → Deregistration option service flag — indicates this is a deregistration of the option service
- `dslSbtFlg = "3"` → Deregistration sub-option service flag — indicates this is a deregistration of the sub-option service

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The database session handle used for read operations during this transaction. Carries the connection context for the current user session. |
| 2 | `param` | `IRequestParameterReadWrite` | The request parameter object that holds form data submitted by the caller (e.g., a screen or BPM operation). Used to retrieve userData via `getData(fixedText)` and for sub-option service data initialization via `initData`/`executeSC`. |
| 3 | `fixedText` | `String` | A fixed key/label used to extract specific userData sections from the request parameter. It identifies which section of the form data should be processed as the input map. |
| 4 | `dataMap` | `HashMap` | The master data map carrying business context for the decision. Contains: `op_svc_cd` (option service code), `svc_div` (service division: "1"=option, "2"=sub-option), `op_svc_kei_no` (option service line number), `svc_kei_ucwk_no` (service contract internal detail number), `op_svc_kei_stat` (option service contract status), and `svc_staymd` (service start date). The values in `dataMap` drive all conditional branching logic. |

**Instance/Class fields read:** None directly. All constants are resolved from class-level `static final` fields defined in `JFUTelOptSvcMskmCmpCC`.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JFUBPCommon.getOpeDate` | — | — | Retrieves the current operation date from the system. Used as reference date for all date calculations. |
| R | `JFUTelOptSvcMskmCmpCC.getSvcChrgStartYMD` | — | — | Queries the service charge start date (year/month/day) for the option service, using the option service line number and service contract internal detail number. |
| R | `JFUBPCommon.initData` | EKK0401A010SC | — | Initializes the input data template for the sub-option service contract agreement inquiry (EKK0401A010). Clears and prepares the request parameter for the service component call. |
| R | `JFUTelOptSvcMskmCmpCC.setInMapEKK0401A010` | — | — | Populates the EKK0401A010 input map with data from `dataMap`. Sets the inquiry criteria for querying sub-option service contract details. |
| R | `JFUBPCommon.executeSC` | EKK0401A010SC | KK_T_SBOP_SVC_KEI (sub-option service contract table) | Executes the sub-option service contract agreement inquiry service component. Fetches the sub-option service contract details including status (`sbopSvcKeiStat`) and start date (`svcStaYmd`). |
| R | `JFUBPCommon.getMaxTempTempleteKey` | — | — | Retrieves the highest template key from the input map for template-based list data access. |
| R | `JFUBPCommon.getTemplateListValue` | — | — | Extracts a specific field value from a template list row in the input map (e.g., status code, date). Called twice: once for service status, once for start date. |
| R | `JKKBpCommon.jdgHiChrg` | — | — | Core non-charging determination logic. Invoked from `JKKHiChrgJdgUtil.jdgHiChrg`. Evaluates business rules based on `dslSbtFlg`, service charge start date, usage start/end dates, and determines whether charges apply. Returns `svcChrgEndYmd` and `chrgFlg`. |
| C | `JFUCommonUtil.addDay` | — | — | Calculates a date N days before or after a reference date. Used twice with offset -1 to compute the day before the operation date as the default service charge end date. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 93 methods.
Terminal operations from this method: `addDay` [C], `addDay` [C], `addDay` [C], `addDay` [C], `addDay` [C], `jdgHiChrg` [-], `addDay` [C], `getTemplateListValue` [R], `getTemplateListValue` [R], `getTemplateListValue` [R], `getTemplateListValue` [R], `getTemplateListValue` [R], `getMaxTempTempleteKey` [R], `getMaxTempTempleteKey` [R], `getMaxTempTempleteKey` [R], `getMaxTempTempleteKey` [R], `getMaxTempTempleteKey` [R], `getTemplateListValue` [R], `getTemplateListValue` [R], `getTemplateListValue` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: JFUSetOptPackMskmCC | `JFUSetOptPackMskmCC.jdgHiChrg` → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` (non-charging rules) |
| 2 | CBS: JFUTelOptSvcMskmCmpCC | `JFUTelOptSvcMskmCmpCC.jdgHiChrg` (public wrapper) → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` (private) | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` |
| 3 | CBS: JFUDslNetOpSvcKeiCC | `JFUDslNetOpSvcKeiCC` → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` |
| 4 | BPM: FUSV0122OPOperation | `FUSV0122OPOperation` → `JFUSetOptPackMskmCC` → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` |
| 5 | BPM: FUSV0042OPOperation | `FUSV0042OPOperation` → `JFUSetOptPackMskmCC` → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` |
| 6 | BPM: FUSV0033OPOperation | `FUSV0033OPOperation` → `JFUSetOptPackMskmCC` → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` |
| 7 | BPM: FUSV0065OPOperation | `FUSV0065OPOperation` → `JFUSetOptPackMskmCC` → `JFUTelOptSvcMskmCmpCC.jdgHiChrg` | `JKKBpCommon.jdgHiChrg [R]` → `JKKHiChrgJdgUtil.jdgHiChrg [C]` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize return map and extract input data (L3172–L3181)

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap returnMap = new HashMap();` // Return map for non-charging determination results |
| 2 | EXEC | `HashMap inMap = param.getData(fixedText);` // Get userData section from request parameter |
| 3 | SET | `String inMapOpSvcCd = dataMap.get(OP_SVC_CD);` // OP_SVC_CD = "op_svc_cd" [OPTION SERVICE CODE] |
| 4 | SET | `String svcDiv = dataMap.get("svc_div");` // "1"=Option (オプション), "2"=Sub-option (サブオプション) |
| 5 | CALL | `String opeDate = JFUBPCommon.getOpeDate(null);` // Get current operation date |
| 6 | SET | `String svcChrgStaYmd = null;` // Initialize service charge start date variable |

**Block 2** — [IF] Option/Sub-option service branch: svc_div is "1" or "2" (L3183–L3231)

> When `svc_div` is "1" (option service) or "2" (sub-option service), the method determines the non-charging status for the option service.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `svcChrgStaYmd = getSvcChrgStartYMD(handle, param, fixedText, dataMap.get("op_svc_kei_no"), dataMap.get("svc_kei_ucwk_no"));` // Get service charge start date |
| 2 | SET | `String opSvcKeiStat = dataMap.get("op_svc_kei_stat");` // Option service contract status |
| 3 | SET | `String svcStaYmd = dataMap.get("svc_staymd");` // Service start date |
| 4 | SET | `HashMap trgtDataOp = new HashMap();` // Build target data map for non-charging judgment |

**Block 2.1** — [IF] Option service is currently "in service" (`op_svc_kei_stat` equals `CD00037_100`) (L3194–L3214)

> When the option service contract status is `CD00037_100` ("in service"), the service is actively being provided, so the non-charging determination must consider the full contract lifecycle (charge start date, usage start/end dates).

| # | Type | Code |
|---|------|------|
| 1 | SET | `trgtDataOp.put("svcKeiChrgStaYmd", svcChrgStaYmd);` // Service charge start date (from getSvcChrgStartYMD) |
| 2 | SET | `trgtDataOp.put("dslSbtFlg", "2");` // Deregistration option service flag (2 = option service deregistration) |
| 3 | SET | `trgtDataOp.put("opSvcCd", inMapOpSvcCd);` // Option service code |
| 4 | SET | `trgtDataOp.put("opSvcUseStaYmd", svcStaYmd);` // Option service usage start date (service start date) |
| 5 | SET | `trgtDataOp.put("opSvcUseEndYmd", opeDate);` // Option service usage end date = current operation date |
| 6 | CALL | `HashMap<String, Object> resMap = JKKBpCommon.jdgHiChrg(trgtDataOp);` // Delegate to core non-charging determination |
| 7 | SET | `returnMap.put(EKK0401C180CBSMsg.SVC_CHRG_ENDYMD, resMap.get(RET_PARAM_SVC_CHRG_ENDYMD));` // Map service charge end date [RET_PARAM_SVC_CHRG_ENDYMD = "svcChrgEndYmd"] |
| 8 | SET | `returnMap.put(EKK0401C180CBSMsg.DSLJI_CHRG_FLG, resMap.get(RET_PARAM_CHRGFLG));` // Map deregistration charge flag [RET_PARAM_CHRGFLG = "chrgFlg"] |

**Block 2.2** — [ELSE] Option service is NOT in service (L3216–L3223)

> When the option service is not currently in service (e.g., already terminated), the method defaults to a non-charged outcome: the service charge end date is set to the day before the operation date, and the non-charged flag is set to `CD00002_0` (not charged).

| # | Type | Code |
|---|------|------|
| 1 | SET | `returnMap.put(EKK0401C180CBSMsg.SVC_CHRG_ENDYMD, JFUCommonUtil.addDay(opeDate, -1));` // Charge end = operation date minus 1 day |
| 2 | SET | `returnMap.put(EKK0401C180CBSMsg.DSLJI_CHRG_FLG, JFUStrConst.CD00002_0);` // CD00002_0 = "not charged" flag |

**Block 3** — [IF] Sub-option service branch: svc_div is "2" (L3235–L3285)

> When `svc_div` is "2" (sub-option service), the method performs a parallel non-charging determination for the sub-option service. This requires querying the sub-option service contract details via the EKK0401A010 service component because the sub-option data is not pre-loaded in `dataMap`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JFUBPCommon.initData(param, fixedText, IN_COL_LIST_EKK0401A010);` // Initialize input template for EKK0401A010 inquiry |
| 2 | CALL | `setInMapEKK0401A010(param, fixedText, dataMap);` // Populate inquiry criteria for sub-option service |
| 3 | CALL | `JFUBPCommon.executeSC(handle, param, fixedText, TEMP_ID_EKK0401A010, TEMP_ID_DTL_EKK0401A010, IN_COL_LIST_EKK0401A010, ERR_COL_EKK0401A010);` // Execute sub-option service contract agreement inquiry SC |
| 4 | SET | `String sbopSvcKeiStat = JFUBPCommon.getTemplateListValue(inMap, JFUBPCommon.getMaxTempTempleteKey(inMap, TEMP_TEMP_KEY_EKK0401A010), TEMP_ID_DTL_EKK0401A010, EKK0401A010CBSMsg1List.SBOP_SVC_KEI_STAT, 0);` // Get sub-option service contract status |
| 5 | SET | `String svcStaYmd = JFUBPCommon.getTemplateListValue(inMap, JFUBPCommon.getMaxTempTempleteKey(inMap, TEMP_TEMP_KEY_EKK0401A010), TEMP_ID_DTL_EKK0401A010, EKK0401A010CBSMsg1List.SVC_STAYMD, 0);` // Get service start date for sub-option |

**Block 3.1** — [IF] Sub-option service is currently "in service" (`sbopSvcKeiStat` equals `CD00037_100`) (L3251–L3269)

> When the sub-option service is active, the non-charging determination considers the sub-option-specific lifecycle: deregistration sub-option flag (3), service charge start date, sub-option usage start/end dates.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap trgtDataSbop = new HashMap();` // Build target data map for sub-option non-charging judgment |
| 2 | SET | `trgtDataSbop.put("dslSbtFlg", "3");` // Deregistration sub-option service flag (3 = sub-option service deregistration) |
| 3 | SET | `trgtDataSbop.put("svcKeiChrgStaYmd", svcChrgStaYmd);` // Service charge start date (shared from option branch) |
| 4 | SET | `trgtDataSbop.put("subOpSvcUseStaYmd", svcStaYmd);` // Sub-option service usage start date |
| 5 | SET | `trgtDataSbop.put("subOpSvcUseEndYmd", opeDate);` // Sub-option service usage end date = operation date |
| 6 | CALL | `HashMap<String, Object> resMap = JKKBpCommon.jdgHiChrg(trgtDataSbop);` // Delegate to core non-charging determination |
| 7 | SET | `returnMap.put(EKK0401C180CBSMsg.SVC_CHRG_ENDYMD, resMap.get(RET_PARAM_SVC_CHRG_ENDYMD));` // Map service charge end date |
| 8 | SET | `returnMap.put(EKK0401C180CBSMsg.DSLJI_CHRG_FLG, resMap.get(RET_PARAM_CHRGFLG));` // Map deregistration charge flag |

**Block 3.2** — [ELSE] Sub-option service is NOT in service (L3271–L3279)

> When the sub-option service is not in service, defaults to non-charged with charge end date one day before the operation date.

| # | Type | Code |
|---|------|------|
| 1 | SET | `returnMap.put(EKK0401C180CBSMsg.SVC_CHRG_ENDYMD, JFUCommonUtil.addDay(opeDate, -1));` // Charge end = operation date minus 1 day |
| 2 | SET | `returnMap.put(EKK0401C180CBSMsg.DSLJI_CHRG_FLG, JFUStrConst.CD00002_0);` // CD00002_0 = "not charged" flag |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `jdgHiChrg` | Method name | Non-charging determination — decides whether a cancelled service should be free of charge |
| `HiChrg` | Japanese acronym | 非課金判定 — "non-charging determination"; determines whether billing is waived for a cancelled service |
| `svc_div` | Field | Service division — classifies the service type: "1"=Option service (オプションサービス), "2"=Sub-option service (サブオプションサービス) |
| `op_svc_cd` | Field | Option service code — identifies which option service the customer subscribed to |
| `op_sbop_svc_cd` | Field | Option/Sub-option service code — the combined code for option or sub-option service |
| `op_svc_kei_stat` | Field | Option service contract status — indicates whether the option service is active, terminated, etc. |
| `sbopSvcKeiStat` | Field | Sub-option service contract status — status code for the sub-option service (e.g., `CD00037_100` = "in service") |
| `svc_kei_no` | Field | Service contract number — the unique identifier for a service contract line |
| `svc_kei_ucwk_no` | Field | Service contract internal detail number — internal tracking ID for a service contract line item |
| `op_svc_kei_no` | Field | Option service line number — identifies a specific option service within a contract |
| `svc_staymd` / `svcStaYmd` | Field | Service start date (year/month/day) — when the service contract or usage began |
| `svcChrgStaYmd` | Field | Service charge start date (year/month/day) — when billing for the service started |
| `svcChrgEndYmd` | Field | Service charge end date (year/month/day) — the date until which charges apply; used in output mapping |
| `opSvcUseStaYmd` | Field | Option service usage start date — when the customer began using the option service |
| `opSvcUseEndYmd` | Field | Option service usage end date — when the customer stopped using the option service |
| `subOpSvcUseStaYmd` | Field | Sub-option service usage start date — when the customer began using the sub-option service |
| `subOpSvcUseEndYmd` | Field | Sub-option service usage end date — when the customer stopped using the sub-option service |
| `dslSbtFlg` | Field | Deregistration service provision flag — distinguishes the type of deregistration: "2"=option service, "3"=sub-option service |
| `dslji_chrg_flg` | Field | Deregistration charge flag — indicates whether a charge applies upon deregistration |
| `CD00037_100` | Constant | Service status: "in service" (サービス提供中) — the service is currently active and being provided to the customer |
| `CD00002_0` | Constant | Non-charged flag value — indicates no charge applies (非課金) for this service |
| `EKK0401A010` | CBS/SC code | Sub-option service contract agreement inquiry service component — queries sub-option service contract details from the database |
| `EKK0401C180CBSMsg` | CBS message class | Message class for EKK0401C180 — defines output field keys for service charge end date (`SVC_CHRG_ENDYMD`) and deregistration charge flag (`DSLJI_CHRG_FLG`) |
| `EKK0401A010CBSMsg1List` | CBS message class | List message class for EKK0401A010 detail data — defines field keys for sub-option service status (`SBOP_SVC_KEI_STAT`) and service start date (`SVC_STAYMD`) |
| `JKKBpCommon.jdgHiChrg` | Utility method | Core non-charging determination engine — evaluates business rules based on service provision flag, dates, and charge status to determine if billing is waived |
| `JKKHiChrgJdgUtil` | Utility class | High-charging judgment utility — the underlying implementation of the non-charging determination logic |
| `addDay` | Utility method | Date calculation utility — adds (or subtracts with negative offset) a specified number of days to/from a base date |
| `op_pack_list` | Field | Option pack list — contains the bundled option services associated with a telecom package |
| `op_svc_kei_ucwk_no` | Field | Option service contract internal detail number — internal ID for option service line item |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service (referenced in related order content codes) |
| Option Service (オプション) | Business term | An additional service that can be added to the base telecom contract (e.g., IP address service, email service, security service) |
| Sub-option Service (サブオプション) | Business term | A secondary service that is attached to or dependent on an option service; requires an active option service to exist |
| `app_div` | Field | Application division — separates processing by application/module context |
| `pack_div` | Field | Pack division — distinguishes between different types of service packs |
| `EKK0161` | CBS/SC reference | Service contract internal detail inquiry — used to query service contract line item status and charge dates |
