# JKKWrisvcAutoAplyCC

## Purpose

`JKKWrisvcAutoAplyCC` is the central business component for **automatic application of discounted (wari-biki) services** in the K-Opticom eo customer backbone system (eo kokyaku kiko shisutemu). When a customer contract changes — whether through new subscription, plan change, cancellation, recovery, customer merge, customer split, or equipment changes — this class automatically determines which discount services should be applied or released based on a comprehensive set of business rules, and invokes the appropriate Service Components (SC) to persist the changes to the database. It solves the problem of keeping discount service eligibility in sync with every customer lifecycle event, without requiring manual intervention.

## Design

`JKKWrisvcAutoAplyCC` extends `AbstractCommonComponent` and implements the **Command pattern** (its `execute()` method is the standard entry point for all operation types) combined with a **Facade pattern** — it exposes a single `execute(SessionHandle, IRequestParameterReadWrite, String)` method that orchestrates a complex multi-step workflow, dispatching to specialized sub-methods based on the `addChgeDiv` (registration/change division) flag passed in the request.

The class acts as a **service orchestrator**. It is not a traditional ORM entity or repository; instead, it is a stateful business logic component that:

1. Validates input data via `chkCcMapInputData()`.
2. Creates a `JKKWrisvcAutoAplyCCMapper` instance to interact with Service Components (SCs).
3. Dispatches to operation-specific handlers based on the `addChgeDiv` value (e.g., `"ADD"`, `"DSL"`, `"CRS_CHG"`, etc.).
4. Each handler performs: search for eligible discount services, validate conditions (via `chkWrisvcDchskmJoken()`), apply or release them (via `addWribsvkDchskmst()`, `createWribsvkDchskmstDslCncl()`, `deleteWribsvkDchskmst()`, etc.), and handle date calculations.
5. Sets up completion messages via `setMsgList()`.

The data model is built around **maps of maps** (`HashMap<String, Object>` with nested lists of maps), organized into:
- `WRIB_SVC_LIST` — list of applicable discount services (wari-biki service list)
- `DCHSKM_LIST` — list of data extraction items (data shutsu mono)
- `WRIB_SVC_KEI_GRP_LIST` — grouped service contracts
- `DCHSKMST_GRP_LIST` — grouped data extraction contracts
- Group divisions (`GRP_DIV`) distinguish between registration (`SET`), cancellation (`RLS`), and initial (`SHOKAI`) states.

### Key constants

The class defines the following operation divisions in `ADD_CHGE_DIV_ARY`:

- `ADD` — new subscription
- `PLAN_CHG` — plan change
- `DSL` — cancellation (release)
- `KAIHK` — recovery
- `CNCL` — contract cancellation
- `CRS_CHG` — course change
- `CUST_PLS` — customer merge
- `CUST_SLT` — customer split
- `BILL_PLS` — billing contract merge
- `BILL_SLT` — billing contract split
- `LINE_PLS` — line merge (added v4.00.01)
- `STB` — Set-Top Box (added v5.00.26)
- `KOJIHI_KAP_CP_DEL` — installation fee gift CP deletion (added v37.00.00)

Discount application condition codes in `WRIB_ADD_JOKEN_CD_LIST`:

- `JOKEN_NON` — no condition
- `CUST` — customer-based
- `SEI` — billing-based
- `KAISEN` — after-installation
- `CUST_SEI` — customer + billing
- `SEI_KAISEN` — billing + after-installation

## Key Methods

### `execute(SessionHandle handle, IRequestParameterReadWrite param, String fixedText)`

The main entry point. Orchestrates the entire discount auto-application workflow.

**Parameters:**
- `handle` — the database session handle.
- `param` — the request parameter object carrying all input data.
- `fixedText` — the key/name used to retrieve the work area (`ccMap`) from `param`.

**Returns:** The modified `IRequestParameterReadWrite` object.

**Side effects:**
- Initializes `JKKWrisvcAutoAplyCCMapper` and stores it in `this.mapper`.
- Validates input via `chkCcMapInputData()`.
- Populates various business parameters into `ccMap` (gread up CP, repeated check, STB CRS CP, etc.).
- Builds service contract group lists for both discount services and data extraction items.
- Dispatches to the appropriate handler based on `addChgeDiv`.
- Sets completion messages.

**Behavior:** If `funcCd` equals `CHK_ONLY`, processing returns early. If `addChgeDiv` is `KAIHK` (recovery), it first performs pre-recovery processing via `updateKihkNetMovaSet()` to restore network/mobile base service contracts before re-applying discounts.

### `executeWrisvcDchskmAutoSet(HashMap<String, Object> ccMap, String[] wribDchsSkbtFlagList)`

Applies discount services (both wari-biki services and data extraction items) automatically.

**Parameters:**
- `ccMap` — work area map containing all business data.
- `wribDchsSkbtFlagList` — array of two flags: `[WRIB]` for discount services, `[DCHS]` for data extraction items.

**Behavior:** Builds a service group list via `makeSvcKeiGrpList()`, checks eligibility for both discount services and data extraction items via `chkWrisvcDchskmJoken()`, merges the lists, runs dependency checks via `sokanChkAndRegist()`, and calls `addWribsvkDchskmst()` to register the contracts.

### `chkWrisvcDchskmJoken(HashMap<String, Object> ccMap, ArrayList<HashMap<String, Object>> svcKeiGrpList, String wribDchsSkbtFlag)`

Determines which discount services (or data extraction items) are eligible for application.

**Parameters:**
- `ccMap` — work area map.
- `svcKeiGrpList` — service contract group list.
- `wribDchsSkbtFlag` — either `WRIB` or `DCHS` to distinguish the type.

**Returns:** An `ArrayList` of eligible service maps.

**Behavior:** Searches for existing discount/service data via `searchWrisvcDchskm()`, then checks conditions against the service list. Only returns services that pass the eligibility criteria.

### `sokanChkAndRegist(HashMap<String, Object> ccMap, ArrayList<HashMap<String, Object>> wrisvcList, ArrayList<HashMap<String, Object>> dchskmList, String[] wribDchsSkbtFlagList)`

Dependency check and registration. Merges the discount service list and data extraction list, verifies there are no conflicting simultaneous applications (`jdgDojiAplyKh()`), removes applications that failed (`removeAplyFailWrisvcDchskm()`), and proceeds to registration or cancellation handling.

### `addWribsvkDchskmst(HashMap<String, Object> ccMap, String funcCd, String[] flgs)`

The core registration method. Creates new discount service contracts and data extraction item contracts.

**Parameters:**
- `ccMap` — work area map.
- `funcCd` — function code.
- `flgs` — the two flags (WRIB/DCHS).

**Behavior:** This is the longest method in the class (spanning roughly 1,400 lines). It:
1. Separates data into "search" (shokai), "set" (registration), and "rls" (cancellation) groups for both discount services and data extraction items.
2. Calls utility methods to prepare registration data with the operation date.
3. Merges the discount and data extraction item lists.
4. Handles recovery cases where the original operation was a cancellation.
5. For each contract, creates the appropriate registration via SC calls like `callWribsvkDchskmstAdd()`, `callWribSvcTgKeiDsl()`, etc.
6. Handles complex conditional logic for plan change dates, retroactive applications, address changes, and various CP (contract) conditions.

### `createWribsvkDchskmstAdd(HashMap<String, Object> ccMap, HashMap<String, Object> inMapWribsvkDchskmst, ArrayList<HashMap<String, Object>> havingWribsvcList, String wribDchsSkbtFlag, String funcCd, String renbanNo, ArrayList<HashMap<String, Object>> wribsvkDchskmstKaisenList)`

Creates individual discount service contract records for application. Handles:
- Different discount types: temporary fees (`ICHIWRI`), monthly fees (`GTGK`), equipment gifts, etc.
- Post-installation timing calculations.
- Standard service eligibility checks.

### `createWribsvkDchskmstDslCncl(HashMap<String, Object> ccMap, HashMap<String, Object> inMapWribsvkDchskmst, String wribDchsSkbtFlag, String funcCd, String renbanNo)`

Creates cancellation records for discount services. Handles the logic for:
- Determining whether a contract should be released.
- Setting cancellation dates and reason codes.
- Handling plan end types (`PLAN_END_SBT_CD_DSL` for normal, `PLAN_END_SBT_CD_KSI_DSL` for forced).
- Standard installation fee CP handling (post v60.00.00).

### `deleteWribsvkDchskmst(HashMap<String, Object> ccMap, ArrayList<HashMap<String, Object>> wribsvkDchskmstGrpList, String wribDchsSkbtFlag, String funcCd)`

Executes the cancellation/release of discount service contracts. For each contract:
1. Prepares cancellation data via `editWribsvkDchskmstMapForRls()`.
2. Checks if the contract is eligible for release.
3. Invokes the SC's cancellation method.

### `updateAplyZm(HashMap<String, Object> ccMap, String funcCd)`

Handles automatic cancellation for long-term continuous discount services. Only processes when `addChgeDiv` is `"DSL"` (cancellation). It finds long-term services (wrib service code `"W00000005"`) where the cancellation date is past the delivery date, and automatically cancels them with appropriate penalty fees.

### `executeWrisvcDchskmAutoRls(HashMap<String, Object> ccMap, String[] wribDchsSkbtFlagList)`

Auto-release/dismissal of discount services. Sets up address change flags (`addrChgFlg`, `addrChgSvcFlg`) and then iterates through each service type, building cancellation lists for each contract.

### `executeWrisvcDchskmAutoRecover(HashMap<String, Object> ccMap, String[] wribDchsSkbtFlagList)`

Recovery of previously cancelled discount services. Steps:
1. Creates the service group list.
2. Calls `updateKihkNetMovaSet()` to restore network/mobile base service contracts.
3. Sets `motoAddChgeDiv` to `"KAIHK"` to preserve the original operation.
4. Temporarily changes `addChgeDiv` to `"ADD"` and calls `executeWrisvcDchskmAutoSet()` to re-apply discounts.
5. Restores `addChgeDiv` to `"KAIHK"`.

### `updateWriSvcTgKei(HashMap<String, Object> ccMap, HashMap<String, Object> mapWribsvkDchskmstGrp, String wribDchsSkbtFlag, String funcCd, String renbanNo)`

Updates the target service relationships for discount services. Specifically handles the case where a base network service has multiple target contracts — ensuring that if there are 3+ services in a billing group and at least one is mobile, the target service relationships are properly updated.

### `searchWribsvkDchskmst(HashMap<String, Object> ccMap, HashMap<String, Object> inMapWribsvkDchskmstGrp, String wribDchsSkbtFlag)`

Searches for existing discount service contracts. Based on the flag, it calls either:
- `callWribSvcKeiIcrnShokai()` for discount services (wari-biki).
- `callDchskmstIcrnShokai()` for data extraction items.

Returns the list with sequential numbering (`renbanNo`).

### `searchWrisvcDchskm(HashMap<String, Object> ccMap, String wribDchsSkbtFlag)`

Searches for eligible discount services. Calls:
- `callEKK0841B004_2()` for discount services (post v9.00.00 optimization).
- `callDchskmIcrnShokai()` for data extraction items.
- Handles cache via `setWribSvc()` — if data was already set, returns it immediately.

### `makeSvcKeiGrpList(HashMap<String, Object> ccMap)`

Builds the service contract group list from the request data. This is a prerequisite for most operations — it organizes service contracts into groups based on the base service and condition codes.

### `setMskmDtlNo(HashMap<String, Object> ccMap, HashMap<String, Object> inMapWribsvkDchskmst, String wribDchsSkbtFlag, String renbanNo)`

Sets the application detail number (shinsei mei sai bangou) on the discount service contract. This is required for tracking which application form a discount is associated with.

### `retMskmDtlNo(HashMap<String, Object> ccMap, String sMskmNo, String mskmDtlNo, String svcKeiNo, ...)`

Returns the application detail number considering priority. Uses the standard service to determine priority ordering among multiple service contract numbers (base, UCWK, OP, SBOP, KKTK, SEIOP, KKOP).

### `chkCcMapInputData(String ccMapNm, IRequestParameterReadWrite cmnParam)`

Validates the input data. Checks that `ccMap` exists, `funcCd` is valid (only `CHK_ONLY` or `CHK_ADD` accepted), `sysid` is present, and `addChgeDiv` is one of the recognized values in `ADD_CHGE_DIV_ARY`.

### `retSvcKeiNoForSvcKeiNo(HashMap<String, Object> ccMap, String svcKeiNo)`

Returns a list of related service contract numbers for a given service contract number.

### `retRequestParaMap(HashMap<String, Object> ccMap, String sysId, String svcKeiNo)`

Constructs a HashMap for a service inquiry request from the current `ccMap` data.

### `isAddrMod(HashMap<String, Object> ccMap)` / `isAddrModSvcYuko(HashMap<String, Object> ccMap)`

Checks whether the operation is an address change and whether address change discount services are applicable. These flags affect cancellation date calculations.

### `retPlanChgYmd(HashMap<String, Object> ccMap)`

Calculates the plan change effective date (YMd). Used to determine when a plan change takes effect.

### `isBatchAndDslAndCncl(HashMap<String, Object> ccMap)`

Checks if the operation is a batch-style cancellation (kaihk) operation.

### `getMapper()`

Returns the `JKKWrisvcAutoAplyCCMapper` instance. The mapper provides the bridge between this CC class and the underlying Service Components (SCs) for database operations.

### Utility / Support Methods

- `calcRenbanDigitSize(int size)` — Calculates the digit width for sequential numbering.
- `nullToBlank(Object str)` — Converts null to empty string.
- `mergeList(ArrayList, ArrayList)` — Merges two lists of maps.
- `jdgDojiAplyKh(ArrayList, ArrayList)` — Judgment: simultaneous application exclusion (checks for conflicting applications).
- `sortArrayList(ArrayList)` — Sorts by `WRIB_SVC_CD` ascending.
- `isExistSvcKei(...)` — Checks if a service contract exists.
- `getLastUpdDtm(...)` / `setMaxLastUpdDtm(...)` — Gets/sets last update timestamp.
- `isBaseSvcReration(...)` — Determines if a base service should be re-created.
- `getWribSvcTgSvcKeiNo(...)` — Gets the target service number for a given service type code.

### Date Calculation Methods

Several methods handle the complex date arithmetic for when discounts take effect and end:
- `setWriStaCYmd()` — Sets the start YMd.
- `setDslWribStaCYmd()` — Sets cancellation start dates.
- `setSvcChrgStaYmd()` — Sets service charge start date.
- `setSvcChrgEndYmd()` — Sets service charge end date.
- `setRetroMapForRlsInf()` — Sets retroactive cancellation information.
- `isEndYmdForZengetu()` — Checks if end date is for all-month (zengetu).
- `getSvcChrgStaYmd()` / `getSvcChrgEndYmd()` — Calculate start/end charge dates based on service type code and other factors.

### Construction Fee Gift CP Methods (v37.00.00+)

A substantial portion of the class (roughly 6,000+ lines) is dedicated to **construction fee gift contract CP (keiyaku koumou)** handling, added for the "Construction Fee Gift Billing" (koujiki kapu sekkyuu) feature:

- `addChgNoDtl()` / `addChgNoDtl2()` — Detailed processing for adding/changing construction fee gift contracts.
- `adChgKojihiKapCp()` / `adChgKojihiKapCp2()` — Handles non-taxable construction fee gift contracts.
- `delKojihiKapCp()` / `delKojihiKapCp2()` — Deletes construction fee gift contracts.
- `getKojihiKapCpNew()` / `getKojihiKapCpNew2()` — Retrieves construction fee gift CP data.
- `hasFinishKojihiCp()` / `hasFinishKojihiCpUnderSvcKei()` — Checks if construction fee gift contracts are complete.
- `isTelTandoku()` / `isTelTandoku2()` — Checks if phone service is standalone (not bundled with network).
- `netFromTelCp()` / `telFromNetCp()` — Handles CP conversion between network and phone services.
- `delSpCp()`, `delMusenRtrCp()`, `delTVPacCp()`, `delSecondCp()` — Delete specific CP types (SP, free return, TV package, second contract).
- `isDuplicateCp()` — Checks for duplicate CPs.
- `recheckDslAfJuhen()` — Re-checks cancellation after penalty occurrence.

## Relationships

```mermaid
flowchart TD
    SUB["JFUCngSeikyushoYohiCC"] -->|extends| MAIN["JKKWrisvcAutoAplyCC"]
    MAIN -->|uses| MAPPER["JKKWrisvcAutoAplyCCMapper"]
    MAIN -->|delegates to| COMMON["JKKWrisvcDchskmCommonUtil"]

    subgraph ExecuteFlow
        EXEC["execute()"] --> DISPATCH{"addChgeDiv<br>value?"}
        DISPATCH -->|"ADD"| AUTOSET["executeWrisvcDchskmAutoSet()"]
        DISPATCH -->|"PLAN_CHG"| PLNCHG["executeWrisvcDchskmAutoPlnChg()"]
        DISPATCH -->|"DSL"| AUTO_RLS["executeWrisvcDchskmAutoRls()"]
        DISPATCH -->|"KAIHK"| RECOVER["executeWrisvcDchskmAutoRecover()"]
        DISPATCH -->|"CNCL"| CNCL["executeWrisvcDchskmAutoRls()"]
        DISPATCH -->|"CRS_CHG"| CRSCHG["executeWrisvcDchskmAutoCrsChg()"]
        DISPATCH -->|"CUST_PLS"| CUSTPLS["executeWrisvcDchskmAutoCustPls()"]
        DISPATCH -->|"CUST_SLT"| CUSTSLT["executeWrisvcDchskmAutoCustSlt()"]
        DISPATCH -->|"BILL_PLS"| BILLPLS["executeWrisvcDchskmAutoBillPls()"]
        DISPATCH -->|"BILL_SLT"| BILLSLT["executeWrisvcDchskmAutoBillSlt()"]
        DISPATCH -->|"LINE_PLS"| LINEPLS["executeWrisvcDchskmAutoLinePls()"]
        DISPATCH -->|"STB"| STBSET["executeWriTgSvcAutoSet()"]
        DISPATCH -->|"KOJIHI_KAP_CP_DEL"| KAPDEL["executeKojihiKapCpDel()"]
        DISPATCH -->|"CHK_ONLY"| EARLYRET["early return"]
    end

    subgraph CoreOps
        AUTOSET --> JOKEN["chkWrisvcDchskmJoken()"]
        AUTOSET --> SOKAN["sokanChkAndRegist()"]
        SOKAN --> ADDWRI["addWribsvkDchskmst()"]
        SOKAN --> DELETEWRI["deleteWribsvkDchskmst()"]
        ADDWRI --> CREATEADD["createWribsvkDchskmstAdd()"]
        CREATEADD --> DTLDETAIL["addChgNoDtl()"]
        CREATEADD --> ADCHK["adChgKojihiKapCp()"]
        CREATEADD --> RETPLAN["retPlanChgYmd()"]
        AUTO_RLS --> CREATDSL["createWribsvkDchskmstDslCncl()"]
        AUTO_RLS --> DELETERLS["deleteWribsvkDchskmst()"]
        AUTO_RLS --> UPDATEAply["updateAplyZm()"]
        RECOVER --> CHKRECOVER["chkWrisvcJokenRecover()"]
        RECOVER --> RECOVERADD["addWribsvkDchskmst()"]
    end

    subgraph DataAccess
        MAPPER --> CALLS["call*ServiceIF methods"]
        COMMON --> UTILS["utility helpers"]
        JOKEN --> SEARCHW["searchWrisvcDchskm()"]
        SEARCHW --> CALLS
    end

    MAIN --> EXEC
```

### Who uses this class

- **`JFUCngSeikyushoYohiCC`** — This class extends `JKKWrisvcAutoAplyCC`, inheriting all its methods. It is a specialized subclass, likely for a specific billing/notification screen or workflow that reuses the discount auto-application logic.

### What this class depends on

- **`AbstractCommonComponent`** — The base class providing common CC infrastructure.
- **`JKKWrisvcAutoAplyCCMapper`** — A mapper class created per `execute()` call. This is the bridge to Service Components (SCs) that perform actual database CRUD operations.
- **`JKKWrisvcDchskmCommonUtil`** — Static utility methods for building data structures, setting data, and common operations.
- Various **EJB CBS message classes** (`EKKxxxxxCBSMsg1List`) — These are the data transfer objects used in SC calls.
- **`JKKStringUtil`**, **`JPCDateUtil`** — String and date utility libraries.
- **`JKKSvcConst`** — Service constant definitions.

## Usage Example

A typical invocation follows this pattern:

```java
// 1. Create the CC instance
JKKWrisvcAutoAplyCC cc = new JKKWrisvcAutoAplyCC();

// 2. Build the request parameter object
IRequestParameterReadWrite param = new RequestParameterReadWrite();
HashMap<String, Object> ccMap = new HashMap<>();
ccMap.put(KKSV0313_KKSV0313OP_WORK.FUNC_CODE, "CHK_ADD");
ccMap.put(KKSV0313_KKSV0313OP_WORK.SYSID, "SYS001");
ccMap.put(KKSV0313_KKSV0313OP_WORK.ADD_CHGE_DIV, "ADD");  // or "DSL", "CRS_CHG", etc.
ccMap.put(KKSV0313_KKSV0313OP_WORK.BASE_SVC_KEI_NO, "SVC001");

// Put the work area in the request
param.setData("JKKWrisvcAutoAplyCC", ccMap);

// 3. Execute
SessionHandle handle = /* ... get session handle ... */;
IRequestParameterReadWrite result = cc.execute(handle, param, "JKKWrisvcAutoAplyCC");
```

The `fixedText` parameter is the key used to store and retrieve the work area (`ccMap`) from the `IRequestParameterReadWrite` object. The `funcCd` field in `ccMap` determines the execution mode:
- `"CHK_ONLY"` — validation only, no processing performed.
- `"CHK_ADD"` — check and apply discounts.

## Notes for Developers

### Thread Safety (v5.00.39)

Prior to v5.00.39, the class used `ThreadLocal<JKKWrisvcAutoAplyCCMapper>` for the mapper. This was changed to an instance field (`private JKKWrisvcAutoAplyCCMapper mapper`) in v5.00.39 to remove ThreadLocal dependency. **The class is NOT thread-safe** — it should not be shared across threads. Each request should create a new instance or the caller must synchronize access.

### Stateful Instance Fields

The class maintains several instance fields that are set during `execute()`:
- `mapper` — the SC mapper instance.
- `msgMap` — message map for completion messages.
- `iRparaReadW` — reference to the input parameter object.
- `addrChgFlg` — address change flag.
- `addrChgSvcFlg` — address change service flag.

These fields are reset on each `execute()` call. Never reuse a CC instance across multiple concurrent requests.

### Massive Code Size

The file is ~22,800 lines long. Roughly half of this is dedicated to construction fee gift CP (koujiki kapu) handling (added in v37.00.00 and extended through v37.xx), which includes methods for `addChgNoDtl`, `adChgKojihiKapCp`, `delKojihiKapCp`, `getKojihiKapCpNew`, etc. The complexity of this subsystem alone is approximately 6,000 lines.

### Data Flow Pattern

The class follows a consistent pattern throughout:
1. **Extract** data from the `ccMap` into local variables.
2. **Search** existing data via `getMapper().call*IcrnShokai()` or `call*SvcKeiIchiiShokai()` SC methods.
3. **Validate** conditions using helper methods (`chkWrisvcDchskmJoken()`, `isSvcNet()`, etc.).
4. **Apply** changes via `addWribsvkDchskmst()` or `createWribsvkDchskmstDslCncl()` which invoke the appropriate SC registration methods.
5. **Clean up** by releasing contracts that are no longer eligible.

### The `renbanNo` (sequential number) Convention

Many methods use a `renbanNo` parameter — a zero-padded sequential number used as a map key suffix. The digit size is calculated via `calcRenbanDigitSize()` to accommodate the size of the data set. This is used for disambiguating multiple entries within the same operation.

### Date Calculations Are Complex

Methods like `setSvcChrgYmdInfToStat910()`, `setSvcChrgYmdInfToNotStat910()`, `getSvcChrgStaYmd()`, and `getSvcChrgEndYmd()` implement complex date logic involving:
- Base date (standard YMd).
- Service start/end dates.
- Plan change dates.
- Cancellation dates.
- Address change dates.
- Installation date (mskmYmd).

These date calculations must account for consumption tax law changes, long-term continuous discount rules, and retroactive applications.

### The `sokanChkAndRegist()` Dependency Check

Before registering new discounts, `sokanChkAndRegist()` calls `jdgDojiAplyKh()` to prevent simultaneous applications that conflict (e.g., applying both a customer-based discount and a billing-based discount that shouldn't coexist). Failed applications are removed before proceeding.

### Known Edge Cases

- Recovery (KAIHK) is handled by first performing pre-recovery processing, then temporarily changing the operation type to "ADD" and re-applying — this is a deliberate design to reuse the application logic rather than duplicating it.
- When `addChgeDiv` is `"CNCL"` (contract cancellation), the same handler as `"DSL"` (release) is used, as both result in the same outcome.
- The `editWribRls()` and `editWribRlsForKaihk()` methods handle special cases where cancellation data should be initialized (e.g., when a service is not actually being released).
- Multiple parallel methods exist for similar operations (e.g., `isTelTandoku()` vs `isTelTandokuNew()`, `addChgNoDtl()` vs `addChgNoDtl2()`, `hasFinishKojihiCp()` vs `hasFinishKojihiCp2()`) — these are evolutionary artifacts from incremental feature additions and may represent different implementations for different business scenarios.

### Version History Highlights

- **v2.00.00** (2011): Initial creation.
- **v3.00.00** (2012): Message output handling.
- **v4.00.01** (2012): Line merge support.
- **v5.00.00** (2013): Plan change/course change post-info preservation.
- **v5.00.39** (2013): ThreadLocal removal — changed to instance fields.
- **v6.00.00** (2013): CP cancellation exception handling.
- **v7.00.00** (2013): Equipment option support.
- **v8.00.00** (2014): Overdue penalty handling.
- **v9.00.00** (2014): Performance improvements, gread up CP processing.
- **v37.00.00** (2018): Construction fee gift billing (koujiki kapu sekkyuu) — massive addition of CP handling methods.
- **v50.00.00** (2020): Mesh WiFi introduction support.
- **v60.00.00** (2022): Consumer protection guideline compliance.

### Performance Considerations

- The class iterates through potentially large lists of service contracts. The `calcRenbanDigitSize()` method and sequential numbering suggest batch processing of many contracts.
- Early return optimizations exist (e.g., `setWribSvc()` caches results to avoid re-querying).
- The `addrChgFlg` and `addrChgSvcFlg` flags are computed once and cached as instance fields to avoid repeated checks.
