# BCP Data Integration Guide

## Global Notes

This document describes the data integration specifications between BCP (Billing, Collection & Payment) module and various business modules (PA, Claim, RI, etc.).

### Important Notes

1. **Interface Structure Universality**: The interface structure described in this document (e.g., request/response format, field hierarchy) is the universal standard specification. All tenants/projects should follow this structure for integration.

2. **Fields and Code Values are References**: The specific field names, enumeration values, and code tables listed in this document are **reference suggestions only**. During actual implementation:
   - Specific fields can be added or removed based on business requirements
   - Code values (such as `BizModule`, `BizSource`, `BcpFeeType`, etc.) should be based on the DataTable configured in the actual project
   - Dynamic extension fields can be added at root level (configured in BcpBizTransaction object) and fee level (configured in BcpFee object)

3. **Integration Method**: All data interaction between business modules and BCP is implemented through **direct API calls** to the REST API interfaces provided by BCP.

---

## API Overview

### Core APIs

| API | Method | Description |
|-----|--------|-------------|
| `/bcp-core/fee/v1/syncDataToBCP` | POST | Synchronize business data to BCP (main interface) |
| `/bcp-core/fee/v1/syncAdditionalFeeToBCP` | POST | Append fee data to BCP |

### Batch Data Processing

When the fee list contains a large number of records (over 1000), data needs to be transmitted through multiple requests:
- **First request**: `GenerateNewTransaction = true`
- **Subsequent requests**: `GenerateNewTransaction = false`

---

## Common Enumeration Values

The following enumeration values are for reference only. Please refer to the DataTable configured in the project for actual usage.

### Module Code

| Code | Module | Description |
|------|--------|-------------|
| 10 | PA | Policy Administration |
| 20 | Claim | Claim Management |
| 30 | Reinsurance | Reinsurance |
| 40 | Channel | Channel/Commission |
| 50 | Finance | Finance |

### BizSource

| Code | Source | Description |
|------|--------|-------------|
| 1 | Direct Business | Direct business |
| 2 | RI Fac-In | Facultative inward |
| 3 | Coinsurance-In | Coinsurance inward |

### TransactionType

| Code | Description |
|------|-------------|
| NEWBIZ | New business |
| ENDORSEMENT | Endorsement |
| RENEWAL | Renewal |
| CLAIM | Claim |
| REINSURANCE | Reinsurance |
| COMMISSION | Commission settlement |
| COLLECTION | Collection |
| PAYMENT | Payment |
| APPLICATION | Application |
| SUSPENSE | Suspense |
| OFFSET | Offset |
| REVERSE | Reversal |

---

## PA → BCP (Policy Module Integration)

### Business Scenarios

PA module synchronizes data to BCP in the following scenarios:
- Upon new business/renewal/endorsement submission
- Distinguished by `IsPrepay` parameter for **CBC (Cash Before Cover)** and **NCBC (Non Cash Before Cover)** modes

### Request Structure

```json
{
  "BizModule": "10",
  "BizSource": "1",
  "BizTransType": "NEWBIZ",
  "BizUniqueId": 23865192828,
  "BranchCode": "10001",
  "LocalCurrencyCode": "SGD",
  "BookingCurrencyCode": "SGD",
  "CurrencyCode": "SGD",
  "DirectEr": 1,
  "DirectBookingEr": 1,
  "IsPrepay": "N",
  "PaymentMethod": "30",
  "PaymentType": "1",
  "PolicyHolderTypeCode": "",
  "PolicyHolderName": "cc cc",
  "PolicyHolderCode": "",
  "PolicyId": 23865192828,
  "PolicyNo": "POMI00000012",
  "MasterPolicyNo": "",
  "EndoId": "",
  "EndoNo": "",
  "EndoType": "",
  "SubEndoType": "",
  "EndoEffDate": "",
  "PolicyEffDate": "",
  "PolicyExpDate": "",
  "ChannelCode": "",
  "ProductCode": "MI",
  "ProductLineCode": "Bond",
  "QuotationNo": "PMI0000000012",
  "RefTransId": 23865192828,
  "RefTransNo": "PMI0000000012",
  "TotalPeriods": 26,
  "FeeList": [
    {
      "Amount": 10,
      "AmountSign": "+",
      "ArapCate": "1",
      "Balance": 10,
      "BcpFeeType": "100101",
      "BranchCode": "370068002",
      "CurrentPeriod": 1,
      "CurrencyCode": "SGD",
      "DirectEr": 1,
      "DirectBookingEr": 1,
      "PayerPayeeCode": "",
      "PayerPayeeName": "cc cc",
      "PayerPayeeType": "",
      "PayerPayeeCate": "",
      "PeriodEndDate": "2021-06-24",
      "PeriodStartDate": "2021-05-25",
      "TotalPeriods": 26
    },
    {
      "Amount": 10,
      "AmountSign": "+",
      "ArapCate": "1",
      "Balance": 10,
      "BcpFeeType": "100501",
      "BranchCode": "370068002",
      "CurrentPeriod": 1,
      "CurrencyCode": "SGD",
      "DirectEr": 1,
      "DirectBookingEr": 1,
      "PayerPayeeCode": "",
      "PayerPayeeName": "cc cc",
      "PayerPayeeType": "",
      "PayerPayeeCate": "",
      "PeriodEndDate": "2021-06-24",
      "PeriodStartDate": "2021-05-25",
      "TotalPeriods": 26
    }
  ]
}
```

### Key Field Descriptions

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `BizModule` | String | Y | Business module code, PA is fixed as "10" |
| `BizSource` | String | Y | Business source: 1-Direct, 2-Fac-in, 3-Coinsurance-in |
| `BizTransType` | String | Y | Transaction type: NEWBIZ/ENDORSEMENT/RENEWAL |
| `BizUniqueId` | Long | Y | Business unique identifier, recommend using PolicyId + EndoId |
| `BranchCode` | String | Y | Branch/Organization code |
| `IsPrepay` | String | Y | Cash before cover flag: Y-CBC, N-NCBC |
| `BcpFeeType` | String | Y | Fee type, refer to BcpFeeType DataTable |
| `ArapCate` | String | Y | AR/AP category: 1-Receivable, 2-Payable |
| `Amount` | Decimal | Y | Amount (absolute value) |
| `AmountSign` | String | Y | Amount sign: +/- |

### CBC Mode Additional Fields

When `IsPrepay = "Y"`, pass `PrepayOrderList`:

```json
{
  "PrepayOrderList": [
    {
      "Amount": 196.34,
      "Balance": 196.34,
      "CurrentPeriod": 1,
      "DueDate": "2024-05-21",
      "PayerPayeeName": "CC",
      "PayerPayeeType": "IndiCustomer",
      "PeriodEndDate": "2024-05-21",
      "PeriodStartDate": "2024-05-21",
      "TotalPeriods": 2
    }
  ]
}
```

---

## Claim → BCP (Claim Module Integration)

### Business Scenarios

Claim module synchronizes data to BCP in the following scenarios:
1. **Indemnity**: Settlement submit, prepay application, recovery submit
2. **Reserve**: Registration submit, manual reserve adjustment, settlement, subrogation, salvage, etc.

### Indemnity Sync Request

```json
{
  "BizModule": "20",
  "BizSource": "1",
  "BizTransType": "CLAIM",
  "BizUniqueId": "858278123_12312_20210101120000",
  "BranchCode": "370068002",
  "FeeList": [
    {
      "ClaimReserveType": "01",
      "SubClaimId": "1",
      "CoverageCode": "C001",
      "Amount": 1000,
      "AmountSign": "+",
      "ArapCate": "2",
      "Balance": 1000,
      "BcpFeeType": "200100",
      "CurrencyCode": "SGD",
      "FeeId": 23865192828,
      "PaymentMethod": "30",
      "PayerPayeeName": "Payee Name",
      "PeriodEndDate": "2021-06-24",
      "PeriodStartDate": "2021-05-25"
    },
    {
      "ClaimReserveType": "01",
      "SubClaimId": "1",
      "CoverageCode": "C001",
      "Amount": 1000,
      "AmountSign": "+",
      "ArapCate": "2",
      "Balance": 1000,
      "BcpFeeType": "200312",
      "CurrencyCode": "SGD",
      "FeeId": 23865192828,
      "PaymentMethod": "30",
      "PayerPayeeName": "Payee Name",
      "PeriodEndDate": "2021-06-24",
      "PeriodStartDate": "2021-05-25"
    }
  ],
  "PolicyId": 23865192828,
  "PolicyNo": "POMI00000012",
  "ClaimNo": "CLM000001",
  "ClaimId": 12345,
  "ProductCode": "MI"
}
```

### Reserve Sync Request

```json
{
  "BizModule": "20",
  "BizSource": "1",
  "BizTransType": "CLAIM",
  "BizUniqueId": "858278123_Reserve_20210101120000",
  "BranchCode": "370068002",
  "FeeList": [
    {
      "ClaimReserveType": "01",
      "SubClaimId": "1",
      "CoverageCode": "C001",
      "UpdateType": "03",
      "Amount": 5000,
      "AmountSign": "+",
      "ArapCate": "2",
      "Balance": 5000,
      "BcpFeeType": "200201",
      "CurrencyCode": "SGD",
      "FeeId": 23865192828
    }
  ]
}
```

### Key Field Descriptions

| Field | Description |
|-------|-------------|
| `BizUniqueId` | Format: `{ClaimId}_{settlementId/ssrId}_{yyyyMMddHHmmss}` or `{ClaimId}_Reserve_{yyyyMMddHHmmss}` |
| `ClaimReserveType` | Reserve type: 01-Loss(Indemnity), 02-Loss(Expense), 03-Subrogation, 05-Salvage |
| `UpdateType` | Reserve update type: 03-New, 01-Manual Update, 05-Final Settlement, 02-Decline |
| `FeeId` | Primary key of fee table, must be unique |

---

## RI → BCP (Reinsurance Module Integration)

### Business Scenarios

1. When RI generates expenses, directly call BCP API to synchronize each transaction
2. RI sends summary settlement to BCP
3. BCP provides cancellation interface, ARAP can be cancelled before actual payment/collection

### Request Structure

```json
{
  "BizModule": "30",
  "BizSource": "1",
  "BizTransType": "REINSURANCE",
  "BizUniqueId": "RI_FEE_12345",
  "BranchCode": "370068002",
  "CurrencyCode": "SGD",
  "DirectEr": 1,
  "DirectBookingEr": 1,
  "IsPrepay": "N",
  "RiPolicyId": "RI001",
  "RiPolicyNo": "RI0000001",
  "RiStatementId": 12345,
  "RiStatementNo": "STMT001",
  "FeeList": [
    {
      "Amount": 10000,
      "AmountSign": "+",
      "ArapCate": "2",
      "Balance": 10000,
      "BcpFeeType": "300110",
      "CurrencyCode": "SGD",
      "CurrentPeriod": 1,
      "DirectEr": 1,
      "DirectBookingEr": 1,
      "FeeId": "FEE001",
      "RefTransType": null,
      "TotalPeriods": 1,
      "PeriodStartDate": "2021-05-25",
      "PeriodEndDate": "2021-06-24",
      "PayerPayeeName": "Reinsurer A"
    }
  ]
}
```

### Key Field Descriptions

| Field | Description |
|-------|-------------|
| `BizUniqueId` | Accounting scenario uses RI fee ID; reconciliation scenario uses summary settlement number |
| `RefTransType` | Pass "OFFSET" for settlement statement details, null for other scenarios |
| `TotalPeriods` | RI has no installment concept, always pass 1 |

---

## BCP → PA (BCP Callback to Policy)

### Business Scenario

BCP returns payment information to PA module after collection/payment is completed.

### Response Structure

```json
{
  "NewBiz23866962810": [
    {
      "PrepayOrder": true,
      "PaymentNo": "R100001",
      "Amount": 26.60,
      "FeeType": "100101",
      "InstallmentPeriodSeq": 6,
      "PaidDate": "2021-06-07T15:02:09",
      "PaidUp": "Y"
    }
  ]
}
```

### Field Descriptions

| Field | Description |
|-------|-------------|
| `Key` | Format: `{BizTransType}{PolicyId}` |
| `PrepayOrder` | Whether it is a prepay order |
| `PaymentNo` | BCP receipt number (returned only when PrepayOrder=true) |
| `PaidUp` | Whether fully settled: Y/N |

---

## BCP → Claim (BCP Callback to Claim)

### Business Scenario

BCP returns payment/collection status information to Claim module.

### Response Structure

```json
{
  "ClaimPaymentInfo": [
    {
      "ClaimId": 23866962810,
      "PaymentInfo": [
        {
          "Amount": 26.60,
          "FeeSeq": 6,
          "FeeType": "200100",
          "InstallmentPeriodSeq": 6,
          "PaidDate": "2021-06-07T15:02:09",
          "PaidUp": "Y",
          "FeeId": 23865192828
        }
      ]
    }
  ]
}
```

### Partial Collection Notes

For AR (such as recovery), BCP supports partial collection with multiple operations until fully collected:
- `Amount`: Current accumulated amount
- `PaidUp`: Y indicates fully settled, N indicates partial collection

---

## BCP → RI (BCP Callback to Reinsurance)

### API

**URL**: `/v1/settleInfoResultNotify`

### Request Structure

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| SettleNo | String | N | Summary settlement number |
| SendDate | String | Y | Date of sending to GL |
| ProcessType | String | N | Payment result: 0-payment success |

### Response Structure

| Field | Type | Description |
|-------|------|-------------|
| status | String | OK/ERROR |
| message | String | Error message (when status=ERROR) |

---

## BcpFeeType Reference

> **Note**: The following are only common fee type examples. For complete and up-to-date fee type definitions, please refer to the **BcpFeeType DataTable** configured in the project.

### PA Module (10)

| FeeType | Name | Description |
|---------|------|-------------|
| 100101 | Policy ARAP - Direct | Direct business AR/AP |
| 100501 | Premium - Direct | Direct business premium income |
| 100601 | Broker Commission - Direct | Direct business broker commission |
| 100400 | Policy Tax | Policy tax |

### Claim Module (20)

| FeeType | Name | Description |
|---------|------|-------------|
| 200100 | Claim ARAP | Claim AR/AP |
| 200201 | Reserve - Direct | Direct business reserve movement |
| 200301 | Settlement - Direct | Direct business claim settlement |
| 200400 | Claim Tax | Claim tax |

### RI Module (30)

| FeeType | Name | Description |
|---------|------|-------------|
| 300110 | Treaty Inward - Premium | Treaty inward premium |
| 300111 | Treaty Outward - Statement | Treaty outward quarterly statement |
| 300302 | Settlement - Fac-In | Fac-in claim settlement |
| 300600 | Broker Commission | RI broker commission |

### Channel/Finance Module (40/50)

| FeeType | Name | Description |
|---------|------|-------------|
| 400100 | Settled Commission ARAP | Settled commission AR/AP |
| 400800 | Collection | Collection |
| 401100 | Payment Approval | Payment approval |
| 401400 | Write Off | Write off |

---

## Payment Method Mapping

### BCP Payment Method

| Code | Name |
|------|------|
| 100 | Cash |
| 101 | Cheque |
| 102 | Direct Debit |
| 106 | Bank Transfer |
| 107 | Post Pay |
| 108 | Online Pay |
| 109 | Direct Credit |

### Claim → BCP Payment Method Mapping

| Claim Code | Claim Name | BCP Code |
|------------|------------|----------|
| 01 | Cash | 100 |
| 02 | Online Pay | 108 |
| 03 | Unionpay | 110 |
| 04 | Direct Credit | 109 |
