> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruloans.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Vendor claim matching and bank file validation logic

# **Vendor Claim Matching & Bank File Validation Logic**

## **Objective**

Implement enhanced vendor claim matching logic to ensure proper priority-based attachment with Bank Files (Bank File) and Tentative Bank Files (Tentative Bank File), along with ERP push validations and optimized search filtering.

***

# **1. Vendor Claim Matching Priority Logic**

## **Requirement**

All vendor claims must first attempt matching with the **Main Bank File (Bank File)**.\
If no match is found in Bank File, then matching should be attempted with the **Tentative Bank File (Tentative Bank File)**.

Additionally:

* If a lead is already attached with a Tentative Bank File
* And later a valid Bank File entry is received for the same lead
* Then the system must:
  * Detach the Tentative Bank File association
  * Attach the lead with the Bank File record instead

## **Matching Priority Flow**

1. Search in Main Bank File (Bank File)
2. If match found:
   * Attach Bank File
   * Ignore Tentative Bank File
3. If Bank File match not found:
   * Search in Tentative Bank File (Tentative Bank File)
4. If Tentative Bank File match found:
   * Attach Tentative Bank File
5. If lead already attached with Tentative Bank File and Bank File becomes available later:
   * Replace Tentative Bank File with Bank File attachment automatically

***

# **2. ERP Push Validation**

## **Requirement**

Users should not be allowed to push cases to ERP if:

* Lead disbursal amount is greater than
* The amount available in the attached Bank File

## **Validation Condition**

If Lead Disbursal Amount > Attached Bank File Amount\
→ Block ERP Push

## **Expected System Behavior**

* ERP push action should be restricted
* Proper validation message should be shown to user

## **Suggested Validation Message**

## ERP push is not allowed because the disbursal amount exceeds the attached Bank File amount.

# **3. Allowed Business Categories for Matching**

## **Requirement**

Only the following business categories should be considered during matching between Lead Forms and Bank Files.

## **Allowed Categories**

| Business Category   | ID |
| ------------------- | -- |
| Loan TBC            | 11 |
| Loan TBC Trench     | 21 |
| In-house Case       | 20 |
| Payout Sharing Case | 17 |
| Insurance LPP       | 9  |
| Insurance Others    | 10 |

## **Matching Restriction**

System should:

* Consider only the above categories during Bank File/Tentative Bank File matching
* Ignore all other business categories

***

# **4. Bank File Search Optimization (180-Day Filter)**

## **Requirement**

While matching Lead Forms with Bank Files:

* Do not show or consider any Bank File records
* Which were received via webhook
* Earlier than 180 days from current date

This restriction is applicable only for the search engine layer to reduce load and improve performance.

## **Purpose**

* Reduce search engine load
* Improve matching performance
* Avoid unnecessary historical record scanning

## **Note**

If database load also increases in future, similar filtering logic can additionally be implemented at DB level.

***

# **5. Expected System Behavior Summary**

| Scenario                                                       | Expected Action                            |
| -------------------------------------------------------------- | ------------------------------------------ |
| Bank File match found                                          | Attach Bank File                           |
| Bank File not found, Tentative Bank File found                 | Attach Tentative Bank File                 |
| Tentative Bank File already attached, Bank File later received | Replace Tentative Bank File with Bank File |
| Disbursal amount > Bank File amount                            | Block ERP Push                             |
| Business category not in allowed list                          | Ignore from matching                       |
| Bank File older than 180 days                                  | Exclude from search matching               |

***

# **6. Technical Considerations**

## **Matching Sequence**

* Bank File matching must always execute before Tentative Bank File matching

## **Reattachment Logic**

* Existing Tentative Bank File linkage should be safely replaceable by Bank File

## **Validation Layer**

* ERP amount validation should occur before ERP API trigger

## **Performance Optimization**

* 180-day filtering should preferably be applied at search-query/index level

## **Auditability**

System should maintain logs for:

* Bank File attachment
* Tentative Bank File attachment
* Tentative Bank File replaced by Bank File
* ERP push validation failures
