# Collection

Collection is the formal process by which our client receives payments from others.

## API List
*  /bcp-core/prepay/v1/prepaidwithModel
*  /bcp-core/collection/v1/policyCollectionAndOffset
*  /bcp-core/collection/v1/collectionApplication
*  /bcp-core/collection/v1/confirmCollection
*  /bcp-core/collection/v1/producerCollect
*  /bcp-core/collection/v1/application
*  /bcp-core/collection/v1/reverseCollection

<div class="docs-note"><span class="docs-admonitions-text">note</span>

In the following API, if a Receipt No. is passed in the request, this Receipt No. will be used directly and the system will no longer automatically generate a new one. 

Meanwhile, these APIs also support the transmission of dynamic fields, which need to be configured in advance in the Data Dictionary of the Collection.

*  /bcp-core/prepay/v1/prepaidwithModel
*  /bcp-core/collection/v1/policyCollectionAndOffset
*  /bcp-core/collection/v1/collectionApplication
*  /bcp-core/collection/v1/producerCollect

</div>

## Premium Pre-paid API (Cash Before Cover - Prepayment)
### API Path
/bcp-core/prepay/v1/prepaidwithModel

### Business Usage

Collect premium from the policyholder before policy issuance.

This is a separate process due to the extensive integration required for automated policy issuance after prepayment.

The premium pre-paid API facilitates the collection of premiums from prepaid policies, ensuring that clients make cash payments before the coverage case. No real fee information will be generated on the backend.

### API Sample
  Sample Request
  ```json
  {
    "Amount": 1004.4,
    "CurrencyCode": "BRL",
    "CollectionType": 2,
    "Payer": {
        "AccountId": "",
        "AccountNo": "",
        "BankCode": "",
        "PartyId": "",
        "PartyCode": "CI00001023",
        "PartyName": "0629",
        "Paymode": "100",
        "PartyRole": "1",
        "BankId": "",
        "ChequeNo": ""
    },
    "ExpenseModelList": [],
    "ReceiptDate": "2023-12-20T14:55:55",
    "NoteContent": "",
    "BranchCode": "10002",
    "ManualReceipt": 1,
    "ReferencePerson": "",
    "InsuranceAccountId": "",
    "PolicyCurrency": "BRL",
    "ProposalNoList":["PABTBTI0001295167"],
    "ReferenceType": 1,
    "RequestSystem": 1,
    "PerpaidMaxPremium": 1004.4,
    "ExchangeRate": 1,
    "CustomerField001":"Field001",
    "CustomerField002":"Field002"

}
  
  ```
  
  Sample Response
  ```json
  {
    "Collection": {
        "@pk": 9699282056,
        "@type": "BcpCollection-Collection",
        "Amount": 1004.4,
        "Balance": 1004.4,
        "BankAccountNo": "",
        "BankCode": "",
        "BizTransId": "969XXXXX54,B4FXXXXX6C76AXXXXXBD3F6A080XXXXX",
        "BookingCurrencyCode": "BRL",
        "BranchCode": "10002",
        "BusinessObjectId": 1100002651715,
        "ChequeNo": "",
        "CollectionId": "969XXXXX56,13XXXXXB518A0DXXXXX43F84D58XXXXX",
        "CollectionStatus": "1",
        "CollectionType": "1",
        "CurrencyCode": "BRL",
        "DetailList": [{
            "@pk": 9699282057,
            "@type": "BcpCollectionDetail-CollectionDetail",
            "Amount": 1004.4,
            "BookingCurrencyCode": "BRL",
            "BusinessObjectId": 110XXXXX51850,
            "CollectionDetailId": 969XXXXX57,
            "CurrencyCode": "BRL",
            "DirectBookingEr": 1,
            "DirectEr": 1,
            "IsExpense": "N",
            "LocalCurrencyCode": "BRL",
            "RefId": "969XXXXX58,97BXXXXXAC2FXXXXX0B2A2E6AB4XXXXX",
            "RefType": "2"
        }],
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "HasMandate": "N",
        "HasNote": "N",
        "IsManualReceipt": "N",
        "LocalCurrencyCode": "BRL",
        "OrderIds": [9699282055],
        "PayerPayeeCode": "CI00001023",
        "PayerPayeeName": "PrePaidPolicy",
        "PayerPayeeType": "1",
        "PaymentMethod": "100",
        "ReceiptNo": "RCT20231200000020",
        "ReceiveBy": 10000001178005,
        "ReceiveTime": "2023-12-20T14:02:36",
        "ReferencePerson": "",
        "VersionSeq": 1
    },
    "IsSuccessful": true,
    "ReceiptNo": "RCT20231200000020",
    "SuspenseNo": "RCT20231200000020"
}
  
  ```
### Internal Data Behavior
Related data dictionary:  
`BizTransaction`,`BcpPrepayOrder`,`BcpCollection`,`BcpCollectionDetail`
1. Input QuotationNo in the UI to query the associated data in `BcpBizTransaction` and `BcpPrepayOrder` through the field **QuotationNo** stored in the main transaction data. 
2. `BcpCollection` will be generated to store the main collection information, and is associated with `BcpPrepayOrder` through the primary key `OrderId`.
3. `BcpCollectionDetail` will be generated to store collection details.
4. Renew the field **Balance** and **CommissionStatus**.

### What You Can Extend
After finishing the business process of BCP, relevant data should be sent back to PA to renew the status of PA orders and activate the automatic issue function.

## Policy Premium Collection API
### API Path
/bcp-core/collection/v1/policyCollectionAndOffset

### Business Usage
The policy premium collection API facilitates the collection of premiums from issued policies. It involves a complex process that includes not only collecting money but also offsetting it against premiums and commission ARAP.

This process is usually applicable to customer billing and those personal product lines.

It is to collect money and perform offset directly so that AR can be directly collected in one step. Such collection and offset combination allows great transaction convenience.

### API Sample
 Sample Request
  ```json
  {
    "Collection": {
        "DetailList": [
            {
                "@type": "BcpCollectionDetail-CollectionDetail",
                "Amount": 1004.4,
                "CurrencyCode": "BRL",
                "IsExpense": "N",
                "BookingCurrencyCode": "BRL",
                "LocalCurrencyCode": "BRL",
                "DirectEr": 1,
                "DirectBookingEr": 1
            }
        ],
        "@type": "BcpCollection-Collection",
        "IsManualReceipt": 1,
        "Amount": 1004.4,
        "BranchCode": "{{orgCode}}",
        "CurrencyCode": "BRL",
        "BookingCurrencyCode": "BRL",
        "LocalCurrencyCode": "BRL",
        "PaymentMethod": "100",
        "DirectEr": 1,
        "DirectBookingEr": 1,
        "InsurerAccountCode": "",
        "DirectBusiEr": 1,
        "PayerPayeeName": "PolicyCollection",
        "CustomerField001":"Field001",
        "CustomerField002":"Field002"

    },
    "ArapList": [
        {
            "@type": "BcpArap-Arap",
            "ArapId": "969XXXXX78,33BXXXXX8394AXXXXX6B0862AD1XXXXX",
            "IsOffsetByCommission": "N",
            "OffsetByCommissionAmount": 93
        }
    ]
}
  ```
  
  Sample Response
  ```json
  {
    "ArapList": [{
        "@pk": 9699392278,
        "@type": "BcpArap-Arap",
        "Amount": 1004.4,
        "ArapCate": "1",
        "ArapId": "969XXXXX78,33BXXXXX8394A5A4XXXXX862AD1XXXXX",
        "ArapNo": "DR20231200002668",
        "ArapStatus": "2",
        "ArapType": "-1001",
        "Balance": 0,
        "BizTransId": "969XXXXX74,293XXXXXC7E70XXXXXCC93136BDXXXXX",
        "BookingCurrencyCode": "BRL",
        "BusinessObjectId": 110XXXXX51088,
        "Commission": 93,
        "CurrencyCode": "BRL",
        "CurrentPeriod": 1,
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "DueDate": "2023-12-21",
        "GenerateDate": "2023-12-20T11:49:38",
        "HasMandate": "N",
        "HasNote": "N",
        "IsApproved": "N",
        "IsOffsetByCommission": "N",
        "LocalCurrencyCode": "INR",
        "NeedStatement": "N",
        "OffsetAmount": 0,
        "OffsetByCommissionAmount": 0,
        "PayerPayeeName": "PolicyCollection",
        "PayerPayeeType": "IndiCustomer",
        "PaymentMethod": "100",
        "PeriodEndDate": "2023-12-21",
        "PeriodStartDate": "2023-12-21",
        "RefFeeId": 969XXXXX75,
        "Tax": 74.4,
        "TotalPeriods": 1,
        "Transaction": {
            "@pk": 9699392274,
            "@type": "BcpBizTransaction-BizTransaction",
            "BizModule": "10",
            "BizSource": "1",
            "BizTransId": "969XXXXX74,293XXXXXC7E702XXXXXC93136BDXXXXX",
            "BizTransTime": "2023-12-20T11:49:35",
            "BizTransType": "NEWBIZ",
            "BizUniqueId": "972XXXXX05,CC1XXXXX66110XXXXX0B25D7E9CXXXXX",
            "BookingCurrencyCode": "BRL",
            "BranchCode": "10006",
            "BranchName": "India Branch",
            "BusinessObjectId": 110XXXXX51370,
            "ChannelCode": "PTY10000052462004",
            "ChannelName": "TEST0926",
            "ChannelType": "14",
            "ChannelTypeName": "Agent Company",
            "CurrencyCode": "BRL",
            "DirectBookingEr": 1,
            "DirectEr": 1,
            "HasMandate": "N",
            "LocalCurrencyCode": "INR",
            "PaymentMethod": "100",
            "PaymentType": "1",
            "PolicyHolderName": "PolicyCollection",
            "PolicyNo": "POTBTI01226628",
            "ProductCode": "TBTI",
            "ProductLineCode": "Travel",
            "ProductName": "API TEST",
            "RefTransId": "972XXXXX05,CC1XXXXX66110XXXXX0B25D7E9CXXXXX",
            "RefTransNo": "POTBTI01226628",
            "TotalPeriods": 1
        },
        "VersionSeq": 2
    }],
    "Collection": {
        "@pk": 9699392282,
        "@type": "BcpCollection-Collection",
        "Amount": 1004.4,
        "ArapIds": [9699392278],
        "Balance": 0,
        "BookingCurrencyCode": "BRL",
        "BranchCode": "{{orgCode}}",
        "BusinessObjectId": 110XXXXX51715,
        "CollectionId": "969XXXXX82,7C4XXXXXA0044CBXXXXX8702DEFXXXXX",
        "CollectionStatus": "1",
        "CollectionType": "3",
        "CurrencyCode": "BRL",
        "DetailList": [{
            "@pk": 9699392283,
            "@type": "BcpCollectionDetail-CollectionDetail",
            "Amount": 1004.4,
            "BookingCurrencyCode": "BRL",
            "BusinessObjectId": 110XXXXX51850,
            "CollectionDetailId": 9699392283,
            "CurrencyCode": "BRL",
            "DirectBookingEr": 1,
            "DirectEr": 1,
            "IsExpense": "N",
            "LocalCurrencyCode": "BRL",
            "RefId": "969XXXXX84,FD0XXXXX48D59XXXXXD61CBE240XXXXX",
            "RefType": "2"
        }],
        "DirectBookingEr": 1,
        "DirectBusiEr": 1,
        "DirectEr": 1,
        "HasMandate": "N",
        "HasNote": "N",
        "InsurerAccountCode": "",
        "IsManualReceipt": "1",
        "LocalCurrencyCode": "BRL",
        "PayerPayeeName": "PolicyCollection",
        "PaymentMethod": "100",
        "ReceiptNo": "RCT20231200000019",
        "ReceiveBy": 10000001178005,
        "ReceiveTime": "2023-12-20T11:49:43",
        "VersionSeq": 1
    }
}
  ```

### Internal Data Behavior

The `policyCollectionAndOffset` business code is divided into three parts in practice.

* Step 1：Generate Collection  

The following are data dictionaries involved in generating collections and their associative relationships. 

1. Generate the data of `BcpCollection` and associate it with the primary key `ArapId of all BcpArap` charge data through **ArapId**.
2. Generate the data of `BcpCollectionDetail` and associate it with `BcpCollection` through the field of  **CollectionId**.
3. Generate the data of `BcpSuspense`, and **ReferenceNo** is the **ReceiptNo** field of `BcpCollection`. Update the primary key field **SuspenseId** of `BcpSuspense` to the **RefId** field of all `BcpCollectionDetail` data generated in the second step.
4. Generate the data of `BcpSuspenseDetail`and associate it with `BcpSuspense` through **SuspenseId**, with the primary key field **CollectionId** of `BcpCollection` through the **RefId** field, and with the primary key field **CollectionDetailId** of `BcpCollectionDetail` through the **RefDetailId** field.
5. Generate the fee data that needs to be sent to GL for the current operation, and send the data to GL based on the data table. The fee type in the data table corresponds to BcpExpenseType. 

* Step 2-1: Use Commission Offset  

Users can select commission offset on the UI. In the commission offset, the involved models and their associative relationships are as follows:  

1. `BizTransId`, `CurrentPeriod`, and `BcpFeeType=100600` are used to query the `BcpFee` associated with the commission fee.  
2. Query the associated data of `SalesCommission` through the **FeeId** and update the balance of commission to 0 and the `CommissionStatus` turns into 4 (offset). 
3. Generate `BcpOffset` data, and the main data comes from the `BcpArap`.    
4. Generate two sets of `BcpOffsetDetail` data. One is about ARAP offset (RefType=3 ARAP), and the other is about commission offset (RefType=1 FEE). 
5. Generate the fee data that needs to be sent to GL for the current operation, ensuring the data includes the fee type corresponding to BcpExpenseType. 

* Step 2-2: Don't Use Commission Offset   
 
Users don't select commission offset on UI. In the collection, the models involved in the commission and their associative relationship are as follows: 
1. `BizTransId`, `CurrentPeriod`, and `BcpFeeType=100600` are used to query the `BcpFee` associated with the commission fee.  
2. Query the associated data of `SalesCommission` through the **FeeId** and update the `CommissionStatus` turns into 2 (Waiting for Issue). 

* Step 3: Use the Collection Generated in Step 1 to Offset  

To offset the collection generated in Step 1, the involved data dictionaries and their associative relationships are as follows:  

1. Obtain the collection details through the primary key of the collection generated in Step 1 and RefType=2.
2. Obtain the `BcpSuspense` data generated in Step 1 through **the RefId** of `BcpCollectionDetail`.
3. Generate offset data, and the main data comes from `BcpArap`.
4. Generate two pieces of `BcpOffsetDetail` data. When **RefType**=3, the data is about ARAP; and when **RefType**=2, it is about suspense.  
5. Generate the fee type data that needs to be sent to GL for the current operation and send the data to GL based on the data table, namely the fee type corresponding to offsettype=2 (application) of BcpOffsetType.     

### What You Can Extend
When the above settlement is finished, it is required to transmit the data back to the business party.

## Single Collection API
### API Path
/bcp-core/collection/v1/collectionApplication

### Business Usage
The single collection API collects premiums from any party and any operation, focusing solely on fees unrelated to customers and producers. It also incorporates an AR offsetting process.

This process is usually applicable to customer billing and those personal product lines.

It is to collect money and perform offset directly so that AR can be directly collected in one step. Such collection and offset combination allows great transaction convenience.

### API Sample
 Sample Request
  ```json
  {
    "Collection": {
        "DetailList": [
            {
                "@type": "BcpCollectionDetail-CollectionDetail",
                "Amount": 256.12,
                "CurrencyCode": "BRL",
                "IsExpense": "N",
                "BookingCurrencyCode": "BRL",
                "LocalCurrencyCode": "BRL",
                "DirectEr": 1,
                "DirectBookingEr": 1
            }
        ],
        "@type": "BcpCollection-Collection",
        "IsManualReceipt": 1,
        "Amount": 256.12,
        "BranchCode": "10001",
        "CurrencyCode": "BRL",
        "ReceiveTime": "2023-12-20T15:35:08",
        "BookingCurrencyCode": "BRL",
        "LocalCurrencyCode": "BRL",
        "PaymentMethod": "100",
        "DirectEr": 1,
        "DirectBookingEr": 1,
        "InsurerAccountCode": "",
        "DirectBusiEr": 1,
        "PayerPayeeCode": "CI00001023",
        "PayerPayeeName": "StatementCollection",
        "ReferenceInfo": "",
        "InsurerAccountCode": "",
        "BankAccountName": "",
        "ChequeDate": null,
        "CreditCardNo": "",
        "CreditCardType": "",
        "ApplyDate": null,
        "BankAccountNo": "",
        "DueDate": null,
        "HolderCategory": "",
        "HolderIdType": "",
        "HolderIdNo": "",
        "BankAgency": "",
        "AgencyDigit": "",
        "AccountDigit": "",
        "AccountType": "",
        "BankChargePre": "0",
        "CustomerField001":"Field001",
        "CustomerField002":"Field002"

    },
    "RefNo": "CI00001023",
    "ArapList": [
        {
            "@type": "BcpArap-Arap",
            "ArapId": "969XXXXX21,42EXXXXXE7BA22XXXXX3A31D706XXXXX",
            "IsOffsetByCommission": "N",
            "OffsetByCommissionAmount": 0
        }
    ]
}
  ```
  
  Sample Response
  ```json
  {
    "ArapList": [
        {
            "@pk": 9699392421,
            "@type": "BcpArap-Arap",
            "ArapId": "969XXXXX21,42EXXXXXE7BA22XXXXX3A31D706XXXXX",
            "ArapStatus": "1",
            "HasMandate": "N",
            "HasNote": "N",
            "IsApproved": "N",
            "IsOffsetByCommission": "N",
            "NeedStatement": "N",
            "OffsetAmount": 0,
            "OffsetByCommissionAmount": 0,
            "VersionSeq": 0
        }
    ],
    "Collection": {
        "@pk": 9699392439,
        "@type": "BcpCollection-Collection",
        "AccountDigit": "",
        "AccountType": "",
        "AgencyDigit": "",
        "Amount": 256.12,
        "ArapIds": [
            9699392421
        ],
        "Balance": 0,
        "BankAccountNo": "",
        "BankAgency": "",
        "BankChargePre": 0,
        "BookingCurrencyCode": "BRL",
        "BranchCode": "10001",
        "BusinessObjectId": 1100002651715,
        "CollectionId": "969XXXXX39,E91XXXXXD01AC8XXXXX3ADEEA23XXXXX",
        "CollectionStatus": "1",
        "CollectionType": "2",
        "CreditCardNo": "",
        "CreditCardType": "",
        "CurrencyCode": "BRL",
        "DetailList": [
            {
                "@pk": 9699392440,
                "@type": "BcpCollectionDetail-CollectionDetail",
                "Amount": 256.12,
                "BookingCurrencyCode": "BRL",
                "BusinessObjectId": 1100002651850,
                "CollectionDetailId": 9699392440,
                "CurrencyCode": "BRL",
                "DirectBookingEr": 1,
                "DirectEr": 1,
                "IsExpense": "N",
                "LocalCurrencyCode": "BRL",
                "RefId": "969XXXXX41,9ECXXXXX63B4CA4XXXXXC0D9731XXXXX",
                "RefType": "2"
            }
        ],
        "DirectBookingEr": 1,
        "DirectBusiEr": 1,
        "DirectEr": 1,
        "HasMandate": "N",
        "HasNote": "N",
        "HolderCategory": "",
        "HolderIdNo": "",
        "HolderIdType": "",
        "InsurerAccountCode": "",
        "IsManualReceipt": "1",
        "LocalCurrencyCode": "BRL",
        "PayerPayeeCode": "CI00001023",
        "PayerPayeeName": "StatementCollection",
        "PaymentMethod": "100",
        "ReceiptNo": "RCT20231200000022",
        "ReceiveBy": 10000046972028,
        "ReceiveTime": "2023-12-20T15:35:21",
        "ReferenceInfo": "",
        "VersionSeq": 1,
        "BankAccountName": ""
    },
    "RefNo": "CI00001023"
}
  ```
### Internal Data Behavior
The business code for "Collect" is similar to that of the policyCollectionAndOffset. However, "Collect" does not include a commission offset, which aligns with the process in Step 1, Step 2-1 and Step 3 of the policyCollectionAndOffset.  

### What You Can Extend
When the above settlement is finished, the data must be transmitted back to the business party.

## Confirm Collection API
### API Path
/bcp-core/collection/v1/confirmCollection

### Business Usage
The confirm collection API facilitates secondary fee confirmation for special payment methods, such as checks, addressing scenarios where additional verification is necessary.

### API Sample
Sample Request
  ```json
  [{
    "@pk": 10473691741,
    "@type": "BcpCollection-Collection",
    "Amount": 1004.4,
    "ArapIds": [10473721498],
    "BookingCurrencyCode": "BRL",
    "BranchCode": "10006",
    "BusinessObjectId": 1100002651715,
    "CollectionId": "104XXXXX741,72EXXXXXFDA287XXXXXBC89709CXXXXX",
    "CollectionStatus": "1",
    "CollectionType": "3",
    "CurrencyCode": "BRL",
    "DetailList": [{
        "@pk": 10473691742,
        "@type": "BcpCollectionDetail-CollectionDetail",
        "Amount": 1004.4,
        "BookingCurrencyCode": "BRL",
        "BusinessObjectId": 1100002651850,
        "CollectionDetailId": 10473691742,
        "CurrencyCode": "BRL",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "IsExpense": "N",
        "LocalCurrencyCode": "BRL",
        "RefId": "104XXXXX743,ACBXXXXX68A7497XXXXXF35D23EXXXXX",
        "RefType": "2"
    }],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasMandate": "N",
    "HasNote": "N",
    "InsurerAccountCode": "",
    "IsManualReceipt": "1",
    "LocalCurrencyCode": "BRL",
    "PayerPayeeName": "10000046972028",
    "PaymentMethod": "102",
    "ReceiptNo": "RCT20240500000006",
    "ReceiveBy": 10000001178005,
    "ReceiveTime": "2024-05-20T15:02:03",
    "SystemReceiveBy": 10000001178005,
    "SystemReceiveTime": "2024-05-20T15:02:03",
    "VersionSeq": 1,
    "ConfirmTime": "2024-01-01"
}]
  ```
  
  Sample Response
  ```json
  No return
  
  ```

## Producer Collection API (Suspense Collection)
### API Path
/bcp-core/collection/v1/producerCollect

### Business Usage
The producer collection API is designed for collecting money specifically at the producer level.

This process is usually applicable to agent billing and those commercial product lines.

It is to collect money and park it in a temporary account, which is also called a Suspense Account. Later on, the account can be used to offset multiple ARs.

Such collection and offset separation allows for greater transaction flexibility.

### API Sample
 Sample Request
  ```json
  {
    "Collection": {
        "DetailList": [
            {
                "@type": "BcpCollectionDetail-CollectionDetail",
                "Amount": 100000,
                "CurrencyCode": "BRL",
                "IsExpense": "N",
                "BookingCurrencyCode": "BRL",
                "LocalCurrencyCode": "BRL",
                "DirectEr": 1,
                "DirectBookingEr": 1
            }
        ],
        "@type": "BcpCollection-Collection",
        "IsManualReceipt": 1,
        "Amount": 100000,
        "BranchCode": "10002",
        "CurrencyCode": "BRL",
        "BookingCurrencyCode": "BRL",
        "LocalCurrencyCode": "BRL",
        "PaymentMethod": "100",
        "DirectEr": 100000,
        "DirectBookingEr": 100000,
        "InsurerAccountCode": "",
        "DirectBusiEr": 100000,
        "PayerPayeeCode": "PTY10000052461005",
        "PayerPayeeName": "leitest0011",
        "CustomerField001":"Field001",
        "CustomerField002":"Field002"

    },
    "RefNo": "PTY10000052461005"
}
  ```
  
  Sample Response
  ```json
  {
    "Collection": {
        "@pk": 9699282068,
        "@type": "BcpCollection-Collection",
        "Amount": 100000,
        "Balance": 100000,
        "BookingCurrencyCode": "BRL",
        "BranchCode": "10002",
        "BusinessObjectId": 1100002651715,
        "CollectionId": "969XXXXX68,408XXXXXB2C3BCXXXXXBAA1F90DXXXXX",
        "CollectionStatus": "1",
        "CollectionType": "4",
        "CurrencyCode": "BRL",
        "DetailList": [{
            "@pk": 9699282069,
            "@type": "BcpCollectionDetail-CollectionDetail",
            "Amount": 100000,
            "BookingCurrencyCode": "BRL",
            "BusinessObjectId": 1100002651850,
            "CollectionDetailId": 9699282069,
            "CurrencyCode": "BRL",
            "DirectBookingEr": 1,
            "DirectEr": 1,
            "IsExpense": "N",
            "LocalCurrencyCode": "BRL",
            "RefId": "969XXXXX70,466XXXXX503F0C8XXXXXC9B0173XXXXX",
            "RefType": "2"
        }],
        "DirectBookingEr": 100000,
        "DirectBusiEr": 100000,
        "DirectEr": 100000,
        "HasMandate": "N",
        "HasNote": "N",
        "InsurerAccountCode": "",
        "IsManualReceipt": "1",
        "LocalCurrencyCode": "BRL",
        "PayerPayeeCode": "PTY10000052461005",
        "PayerPayeeName": "leitest0011",
        "PaymentMethod": "100",
        "ReceiptNo": "RCT20231200000021",
        "ReceiveBy": 10000001178005,
        "ReceiveTime": "2023-12-20T14:52:48",
        "VersionSeq": 1
    },
    "RefNo": "PTY10000052461005"
}
  ```
### Internal Data Behavior
The business code for "Collect" is similar to that of the policyCollectionAndOffset. "Collect" does not include commission and actual offset, which aligns with the process in Step 1 of the policyCollectionAndOffset. 

## Application API
### API Path
/bcp-core/collection/v1/application

### Business Usage

The application process offsets the AR with collected funds. It can be against multiple AR/AP to facilitate a large amount of collection, especially on behalf of channels.
 
### API Sample
Sample Request
  ```json
  {
    "ArapList": [
        {
            "@type": "BcpArap-Arap",
            "ArapId":"969XXXXX65,5739XXXXX708F12F8B02D5676E1XXXXX"
        }
    ],
    "RefNo": "RCT20231200000021"
}
  ```
  
  Sample Response
  ```json
  [{
    "@pk": 9699392312,
    "@type": "BcpOffset-Offset",
    "Amount": 1004.4,
    "ApplicationNo": "RCT20231200000021",
    "BookingCurrencyCode": "BRL",
    "BusinessObjectId": 1100002652393,
    "CurrencyCode": "BRL",
    "DetailList": [{
        "@pk": 9699392313,
        "@type": "BcpOffsetDetail-OffsetDetail",
        "Amount": 1004.4,
        "BookingCurrencyCode": "BRL",
        "BusinessObjectId": 1100002652469,
        "CurrencyCode": "BRL",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "LocalCurrencyCode": "BRL",
        "OffsetDetailId": 9699392313,
        "RefId": "969XXXXX65,573XXXXX3708F12XXXXXD5676E1XXXXX",
        "RefType": "3"
    }, {
        "@pk": 9699392314,
        "@type": "BcpOffsetDetail-OffsetDetail",
        "Amount": 1004.4,
        "BookingCurrencyCode": "BRL",
        "BusinessObjectId": 1100002652469,
        "CurrencyCode": "BRL",
        "DirectBookingEr": 1,
        "DirectEr": 1,
        "LocalCurrencyCode": "BRL",
        "OffsetDetailId": 9699392314,
        "RefId": "969XXXXX70,466XXXXX503F0C8XXXXXC9B0173XXXXX",
        "RefType": "2"
    }],
    "DirectBookingEr": 1,
    "DirectEr": 1,
    "HasNote": "N",
    "LocalCurrencyCode": "BRL",
    "OffsetBy": 10000001178005,
    "OffsetCurrencyCode": "BRL",
    "OffsetId": "969XXXXX12,35DXXXXX2020XXXXX9FC74C7B14XXXXX",
    "OffsetNo": "OFS20231200000030",
    "OffsetStatus": "1",
    "OffsetTime": "2023-12-20T14:52:54",
    "OffsetType": "2",
    "VersionSeq": 1
}]
  ```
### Internal Data Behavior
The business code for "Collect" is similar to that of the policyCollectionAndOffset.
However, "Collect" does not generate collection data and lacks a commission offset, making it consistent with step 2-1 and step 3 in the policyCollectionAndOffset.

### What You Can Extend
When the above settlement is finished, it is required to transmit the data back to the business party.  

## Reverse Collection API
### API Path
/bcp-core/collection/v1/reverseCollection

### Business Usage
The reverse collection API is designed to reverse a collection transaction.

### API Sample
  Sample Request
  ```json
  [
    "969XXXXX68,408XXXXXB2C3BC7XXXXXAA1F90XXXXX"
  ]
  ```
  
  Sample Response
  ```json
  {
    "Model": [
        {
            "@pk": 9699282080,
            "@type": "BcpReverse-Reverse",
            "BusinessObjectId": 1100002652882,
            "HasNote": "N",
            "RefId": "969XXXXX68,408XXXXXB2C3BC7XXXXXAA1F90XXXXX",
            "ReverseBy": 10000001178005,
            "ReverseId": 9699282080,
            "ReverseReason": "manual",
            "ReverseTime": "2023-12-20T15:07:17",
            "ReverseType": "1"
        }
    ],
    "Status": "OK"
    }
  ```
  
### Internal Data Behavior
The business code of reverseCollection is divided into three parts in practice.  
* Step 1: Generate Reversal Records and Details  
The involved data dictionaries and their associative relationships are as follows:   
Generate `BcpReverse` with a collection type, and associate it with **CollectionId** and the primary key of `BcpCollection` through **RefId**.  
* Step 2: Reverse Offset  
The data dictionaries involved in reverse offset and their associative relationships are as follows:  
1.  Query the associated data from `BcpCollectionDetail` where the RefType is suspense through the **CollectionId** of `BcpCollection`.
2.  Query the `BcpSuspense` data through the field **RefId** of `BcpCollectionDetail`.
3.  Query the associated Data of `BcpSuspenseDetail`.
4.  Query `BcpOffset` data through **ReceiptNo** and **BcpSuspenseDetail** of `BcpCollection`.
5.  Use the **RefId** and `RefType of BcpSuspenseDetail` to query the data concerning ARAP and suspense respectively.
6.  Restore the values of fields where the data and status of ARAP and Commission change during the collection process to the ones before collection after querying the ARAP data.
7.  Generate the `BcpSuspenseDetail` data after querying the suspense data.
8.  Generate the fee data that needs to be sent to GL for the current operation, and send the data to GL based on the data table. The fee type in the data table is corresponding to SuspenseType in BcpSuspenseType.   

* Step 3: Reverse Collection  
Data dictionaries involved in the reverse collection and their associative relationships are as follows: 
1.  Query the associated data from `BcpCollectionDetail` where the RefType is suspense through the CollectionId of `BcpCollection`.
2.  Query the `BcpSuspense` data through the field RefId of `BcpCollectionDetail` associated with the `BcpSuspense` primary key SuspenseId, and change SuspenseStatus into inactive.
3.  Generate the fee data that needs to be sent to GL for the current operation, and send the data to GL based on the data table. The fee type is corresponding to SuspenseType in BcpSuspenseType.

### What You Can Extend
After completing the reverse collection.