Collection Migration V1 to V2

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

 

In old collection, for every transaction the receipt number is generated on bill detail level, as bill contains multiple bill details each transaction is map to multiple receipt number, so after payment of a single bill multiple receipt number is generated for it . These mapping of transaction to receipt number is changed in new collection system.

In new collection system the receipt number is generated on bill level, so for every transaction for each bill one receipt number is generated. So each bill for a consumer code and business service have 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 transaction of data, the record from old receipt has been mapped according to payment structure, so that new payment response can be formed with receipt data.

Bellow is the mapping between receipt and payment structure with some remarks.

Field from Payments

Field from Receipts

Remark

Payments.Id 

  • ---

Set as UUID

Payments.tenantId

Receipt.tenantId



Payments.totalDue

  • ---

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

If mobileNumber from Receipt.bill is null it has to set with some value e.g: “NA”

Note: Payments.mobileNumber should not be null

Payments.payerName

Receipt.Bill.payerName



Payments.payerAddress

Receipt.Bill.payerAddress



Payments.payerEmail

Receipt.Bill.payerEmail



Payments.payerId

Receipt.Bill.payerId



Payments.paymentStatus

  • --

Based on paymentMode from Payment, the paymentStatus is set.

If paymentMode is ONLINE or CARD then  paymentStatus is set to DEPOSITED otherwise it is set to NEW

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 

  • ---

Set as UUID

Payments.paymentDetails.tenantId

Receipt.tenantId



Payments.paymentDetails.totalDue

  • ---

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

  • ---

auditDetail for paymentDetail is same as payment auditDetail

Payments.paymentDetails.billId

  • ---

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

  • ---

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 creation of payment response with receipt data,  it has been pushed into kafka topic “egov.collection.migration-batch” and with the persister, payment data is inserted 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  

Please get these promoted before initiating the migration process. Migration happens through an API call, add role-actions based on your requirement. Otherwise, port-forwarding should work. 

Find the API details below:

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"
}

While restarting migration due to any failure, take the value of offset and tenantId printed in the logs and resume the migration process where it ended.

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


Collection-service build:- collection-services-db:9-COLLECTION_MIGRATION-e9701c4