> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/local-governance/deploy/configure-digit/services-overview/business-services/collection-service/collection-service-migration.md).

# Collection Service Migration

## Overview

According to the new collection service, which follows the payment structure for storing information about payments and payment details, it is necessary to migrate the old collection structure into the new payment structure.

<div align="left"><img src="/files/-MbZf7k7lP2cRKKzWzVs" alt=""></div>

## Migration Details

In the old collection service, for every transaction, the receipt number is generated on the bill detail level. Since the bill contains multiple bill details each transaction is mapped to multiple receipt numbers. So after payment of a single bill, multiple receipt numbers are generated. The mapping of the transactions to the receipt number changed in the new collection service.

In the new collection service, the receipt number is generated at the bill level. For each bill transaction, one receipt number is generated. So every bill for a consumer code and business service has one receipt number.

The records from tables **egcl\_receiptheader**, **egcl\_receiptdetails**, **egcl\_instrument**, **egcl\_instrumentheader** need to be transferred into tables **egcl\_payment**, **egcl\_paymentdetail**, **egcl\_bill**, **egcl\_billdetial**, **egcl\_billaccountdetail.**

For smooth data transactions, the record from the old receipt is mapped according to the payment structure. The new payment response can be formed with receipt data.

The table below provides the mapping between receipt and payment structure with some remarks.

| Field From Payments                                    | Field from Receipts                              | Remark                                                                                                                                                                                                                                           |
| ------------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Payments.**Id**                                        | <ul><li>---</li></ul>                            | Set as UUID                                                                                                                                                                                                                                      |
| Payments.**tenantId**                                  | Receipt.**tenantId**                             |                                                                                                                                                                                                                                                  |
| Payments.**totalDue**                                  | <ul><li>---</li></ul>                            | Total due for payment is calculated by subtracting totalAmount from bill and amount from Receipt.instrument                                                                                                                                      |
| Payments.**totalAmountPaid**                           | Receipt.instrument.**amount**                    |                                                                                                                                                                                                                                                  |
| Payments.**transactionNumber**                         | Receipt.instrument.**transactionNumber**         |                                                                                                                                                                                                                                                  |
| Payments.**transactionDate**                           | Receipt.**receiptDate**                          |                                                                                                                                                                                                                                                  |
| Payments.**paymentMode**                               | Receipt.instrument.**instrumnetType**.**name**   |                                                                                                                                                                                                                                                  |
| Payments.**instrumentDate**                            | Receipt.instrument.**instrumentDate**            |                                                                                                                                                                                                                                                  |
| Payments.**instrumentNumber**                          | Receipt.instrument.**instrumentNumber**          |                                                                                                                                                                                                                                                  |
| Payments.**instrumentStatus**                          | Receipt.instrument.**instrumentStatus**          |                                                                                                                                                                                                                                                  |
| Payments.**ifscCode**                                  | Receipt.instrument.**ifscCode**                  |                                                                                                                                                                                                                                                  |
| Payments.**additionalDetails**                         | Receipt.Bill.**additionalDetails**               |                                                                                                                                                                                                                                                  |
| Payments.**paidBy**                                    | Receipt.Bill.**paidBy**                          |                                                                                                                                                                                                                                                  |
| Payments.**mobileNumber**                              | Receipt.Bill.**mobileNumber**                    | <p>If mobileNumber from Receipt.bill is null it has to set with some value e.g: <strong>“NA”</strong></p><p>Note: Payments.mobileNumber should not be null</p>                                                                                   |
| Payments.**payerName**                                 | Receipt.Bill.**payerName**                       |                                                                                                                                                                                                                                                  |
| Payments.**payerAddress**                              | Receipt.Bill.**payerAddress**                    |                                                                                                                                                                                                                                                  |
| Payments.**payerEmail**                                | Receipt.Bill.**payerEmail**                      |                                                                                                                                                                                                                                                  |
| Payments.**payerId**                                   | Receipt.Bill.**payerId**                         |                                                                                                                                                                                                                                                  |
| Payments.**paymentStatus**                             | <ul><li>--</li></ul>                             | <p>Based on paymentMode from Payment, the paymentStatus is set.</p><p>If paymentMode is <strong>ONLINE</strong> or <strong>CARD</strong> then paymentStatus is set to <strong>DEPOSITED</strong> otherwise it is set to <strong>NEW</strong></p> |
| Payments.auditDetails.**createdBy**                    | Receipt.auditDetails.**createdBy**               |                                                                                                                                                                                                                                                  |
| Payments.auditDetails.**createdTime**                  | Receipt.auditDetails.**createdTime**             |                                                                                                                                                                                                                                                  |
| Payments.auditDetails.**lastModifiedBy**               | Receipt.auditDetails.**lastModifiedBy**          |                                                                                                                                                                                                                                                  |
| Payments.auditDetails.**lastModifiedTime**             | Receipt.auditDetails.**lastModifiedTime**        |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**Id**                         | <ul><li>---</li></ul>                            | Set as UUID                                                                                                                                                                                                                                      |
| Payments.paymentDetails.**tenantId**                   | Receipt.**tenantId**                             |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**totalDue**                   | <ul><li>---</li></ul>                            | Total due for paymentDetails is calculated by subtracting totalAmount from bill and amount from Receipt.instrument                                                                                                                               |
| Payments.paymentDetails.**totalAmountPaid**            | Receipt.instrument.**amount**                    |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**receiptNumber**              | Receipt.**receiptNumber**                        |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**manualReceiptNumber**        | Receipt.Bill.billDetails.**manualReceiptNumber** |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**manualReceiptDate**          | Receipt.Bill.billDetails.**manualReceiptDate**   |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**receiptDate**                | Receipt.**receiptDate**                          |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**receiptType**                | Receipt.Bill.billDetails.**receiptType**         |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**businessService**            | Receipt.Bill.billDetails.**businessService**     |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**additionalDetail**           | Receipt.Bill.**additionalDetail**                |                                                                                                                                                                                                                                                  |
| Payments.paymentDetails.**auditDetail**                | <ul><li>---</li></ul>                            | auditDetail for paymentDetail is same as payment auditDetail                                                                                                                                                                                     |
| Payments.paymentDetails.**billId**                     | <ul><li>---</li></ul>                            | Based on id in **egbs\_billdetail\_v1** table billId is extracted,Where id in **egbs\_billdetail\_v1** is Receipt.Bill.billDetails.billNumber                                                                                                    |
| Payments.paymentDetails.**bill**                       | <ul><li>---</li></ul>                            | Based on the billid, tenantid and service the bill is search by calling the Billing service API and set it to Payments.paymentDetails.bill                                                                                                       |
| Payments.paymentDetails.bil.billDetails.**amountPaid** | Receipt.instrument.**amount**                    | For each amountPaid in billDetails, its value is set from Receipt.instrument.amount                                                                                                                                                              |

After the creation of the payment response with receipt data, it is pushed into the Kafka topic **“egov.collection.migration-batch”.** The persister inserts the payment data into tables - **egcl\_payment**, **egcl\_paymentdetail**, **egcl\_bill**, **egcl\_billdetial**, **egcl\_billaccountdetail.**

Indexer config for the legacy data index and new payments.

<https://github.com/egovernments/configs/blob/master/egov-indexer/payment-indexer.yml>

**persister config -**

<https://raw.githubusercontent.com/egovernments/configs/master/egov-persister/collection-migration-persister.yml?token=AGAOX7TAAE6QPRZBXU3QZV266URNW>

These need to get promoted before initiating the migration process. Migration happens through an API call, add role-actions based on your requirement. Otherwise, port-forwarding will work.

## API Details

Endpoint: /collection-services/payments/\_migrate?batchSize=100\&offset=\
Body:\
{\
"RequestInfo": {\
"apiId": "Rainmaker",\
"action": "",\
"did": 1,\
"key": "",\
"msgId": "20170310130900|en\_IN",\
"ts": 0,\
"ver": ".01",\
"authToken": "a6ad2a1b-821c-4688-a70e-4322f6c34e54"\
}

In case of any failure and restarting migration, take the value of ***offset*** and ***tenantId*** printed in the logs and resume the migration process.

**/collection-services/payments/\_migrate?batchSize=100\&offset=200\&tenantId='pb.tenantId'**

**Collection-service build:-** collection-services-db:9-COLLECTION\_MIGRATION-e9701c4

> [![Creative Commons License](https://i.creativecommons.org/l/by/4.0/80x15.png)\_\_](http://creativecommons.org/licenses/by/4.0/)*All content on this page by* [*eGov Foundation* ](https://egov.org.in/)*is licensed under a* [*Creative Commons Attribution 4.0 International License*](http://creativecommons.org/licenses/by/4.0/)*.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digit.org/local-governance/deploy/configure-digit/services-overview/business-services/collection-service/collection-service-migration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
