# Billing Fee Assistant

Corporate finance teams often face challenges when processing daily expense reimbursements, dealing with numerous receipts, time-consuming manual data entry, and error-prone processes. Traditional OCR tools typically only recognize text without understanding business context, making it impossible to automatically map department codes or expense categories, still requiring significant manual intervention for corrections. Now, you can leverage MaiAgent's intelligent vision technology to build a dedicated "Billing Expense Assistant" that achieves intelligent automation from receipt recognition to ERP form completion!

## Use Case: Building an AI Assistant for Automated Corporate Bill Recognition

Imagine you are a corporate finance accountant who needs to process a large volume of utility bills, telecommunication fees, and other reimbursement receipts from various branch offices at the end of each month. Previously, you might have spent hours looking at paper receipts, manually entering invoice numbers, dates, and amounts into the ERP system one by one.

Traditional OCR tools often can only "read text" but cannot understand business rules. For example, when a receipt shows "Zuoying District, Kaohsiung City," traditional tools cannot automatically determine that this belongs to the "Kaohsiung Branch" with department code "K"; nor can they automatically set the payment date to "the 30th of each month" according to company regulations. This forces you to manually verify and modify data one by one, which is not only inefficient but also prone to input errors due to fatigue.

Now, through MaiAgent's intelligent vision and reasoning technology, you simply need to upload bill images to the AI assistant. The system can not only accurately extract invoice numbers and amounts but can also directly execute your company's internal business logic!

## Application Workflow

### 1. Create a Billing Expense AI Assistant <a href="#id-1.-jian-li-cai-wu-zi-liao-fen-xi-ai-zhu-li" id="id-1.-jian-li-cai-wu-zi-liao-fen-xi-ai-zhu-li"></a>

Enter the AI assistant name and select the language model

Recommended model: Gemini 2.5 Pro

Note: Since this application involves complex image text recognition and logical judgment (such as address-to-department code conversion), it is strongly recommended to use Pro-level or higher models to ensure recognition accuracy.

<figure><img src="/files/NZlZwpKtJWYsfhc5U7Pz" alt=""><figcaption></figcaption></figure>

Select Agent mode

<figure><img src="/files/0u5GW3HREb9em1IuVT0h" alt=""><figcaption></figcaption></figure>

### **2. Operational Logic Configuration**

To enable the assistant to not only "read text" but also "understand" business rules, we need to define the following field processing logic in the System Prompt. The following example uses a water bill from "Taiwan Water Corporation":

```
------------------------------------------------------------
|  Taiwan Water Corporation                                |
|  Taiwan Water Corporation                                |
|  May 2025 Auto-debit (Collection) Water Bill Receipt     |
|                                                          |
|  Carrier Category Number: /BB0001                        |
|  Period: 11405                                           |
|  E-Invoice Certificate Copy: TP88776655 [   QR Code   ]  |
|                                [     回回回      ]       |
|  Water Usage Address:                                    |
|  No. 7, Section 5, Xinyi Road, Xinyi District,          |
|  Taipei City 110 (Taipei 101)                            |
|                                                          |
|----------------------------------------------------------|
|  Account Name: Test Taipei Headquarters                  |
|                                                          |
|  Current Billing Water Usage Period   Water Usage Items |
|  2025/03/05 - 2025/05/04        Basic Fee         100 TWD|
|                                Water Usage Fee    950 TWD|
|  Current Payment Start Date             --------------   |
|  2025/05/21                    Business Tax        50 TWD|
|                                                          |
|  Next Payment Start Date       Pre-tax Subtotal          |
|  2025/07/21                    (Trap F)         1,050 TWD|
|                                                          |
|  Current Meter Reading Date    Collection Fee Subtotal   |
|  2025/05/04                    Disposal Fee       300 TWD|
|                                Water Resource Fee 100 TWD|
|----------------------------------------------------------|
|                                                          |
|  Total Amount Payable (Total)                            |
|  $ 1,500 TWD                                             |
|                                                          |
|  Payment Deadline: 2025/05/30  Account Number: 998877665544|
------------------------------------------------------------
```

**A. Basic Information Extraction**

The assistant needs to identify the following key raw data from the image:

* Invoice Number: Accurately extract the invoice number from the receipt.
* Amount Information: Extract "Total Amount" and "Pre-tax Amount".
* Date Information: Extract the relevant date range from the bill.

**B. Business Logic Mapping**

This is the core advantage of MaiAgent over traditional OCR. The assistant can automatically determine the classification based on content:

1. Address and Department Mapping:
   * Rule: If the recognized address contains "Kaohsiung," the "Expenditure Department" is automatically classified as "Kaohsiung Branch".
   * Code Conversion: Following the above, if the department is Kaohsiung Branch, the "Department Code" is automatically filled with "K".
2. Payee and Account:
   * Rule: If the payee is recognized as "Taiwan Water Corporation," the "Expense Item" is automatically classified as "Water Fee".
3. Payment Date Automation:
   * Rule: Regardless of the bill date, the "Payment Date" field is uniformly fixed to the 30th of each month.
4. Summary Format Standardization:
   * Rule: Combine the extracted dates and information into a fixed format string.
   * Example Format: `YY/MM/DD-YY/MM/DD` + `Region` + `Expense Item` (e.g., "114/08/20-114/10/18 Kaohsiung Water Fee").
5. Amount Calculation and Validation:
   * Rule: The system can automatically calculate or validate amount logic, for example: `Amount` = `Total Amount` - `Pre-tax Amount` (depending on ERP field definition).

Role instruction reference:

```
# Role
You are an enterprise-level "Intelligent Financial Accounting Assistant." Your core capabilities are visual recognition (OCR) combined with complex business logic reasoning.
Your task is to accurately extract various bill data and convert unstructured information into standard ERP format according to predefined [Business Configuration].

# Business Configuration
**Please perform reasoning and field mapping according to the following rule table:**

## 1. Department Mapping Rules (Department Logic)
* **Rule**: Read the "Address" or "Consumption Location" keywords on the bill.
    * Contains "Taipei" -> Expenditure Department: "Taipei Headquarters" | Department Code: "T"
    * Contains "Kaohsiung" -> Expenditure Department: "Kaohsiung Branch" | Department Code: "K"
    * Others -> Expenditure Department: "To Be Confirmed" | Department Code: "UNK"

## 2. Expense Category Rules (Expense Category Logic)
* **Rule**: Read the "Company Name," "Title," or "Transaction Details" on the bill.
    * Contains "Water" -> Expense Item: "Water Fee"
    * Contains "Power," "Taipower" -> Expense Item: "Electricity Fee"
    * Contains "Chunghwa Telecom" -> Expense Item: "Telecommunication Fee"

## 3. Date & Summary Rules (Date & Summary Logic)
* **Payment Date**: Uniformly set to "the 30th of the current or next month" of the document month (format YYYY-MM-DD).
* **Summary Format**: Must be combined into a standard string -> `[Period]-[Region][Expense Item]`
    * *Example*: `114/06/20-114/08/18 Kaohsiung Water Fee`

## 4. Calculation Rules (Calculation Logic)
* **Pre-tax Amount**: Must be obtained through calculation, formula = `[Total Amount] - [Business Tax/Tax Amount]`.
    * *Note*: Do not directly read the "subtotal" in the middle of the document; must use "total amount" deduction to avoid missing collection fees.

---

# Workflow

## Phase 1: Visual Recognition and Logic Reasoning
1.  **Analyze Image**: Scan invoice number, date range, address, transaction party, total amount, tax amount.
    * *Invoice Number Format Check*: Must match `^[A-Z]{2}\d{8}$`.
2.  **Execute Mapping**: Determine department, account, and code according to [Business Configuration].
3.  **Output Confirmation Table**: Please output results using a Markdown table for user verification.

**Phase 1 Output Example (Please strictly follow this format):**
Please reply directly: "Please confirm the following bill information:"
| Field Name | Recognition & Conversion Result | Logic Source |
| :--- | :--- | :--- |
| **A. Expenditure Department** | [e.g., Kaohsiung Branch] | [Based on address: Kaohsiung...] |
| **B. Expense Item** | [e.g., Water Fee] | [Based on payee: Water Corporation] |
| **C. Summary** | [Date range+Region+Item] | [Format combination] |
| **D. Invoice Number** | [Two letters+Eight digits] | [OCR recognition] |
| **E. Amount (Tax)** | [Tax amount number] | [OCR recognition] |
| **F. Pre-tax Amount** | [Calculated value] | [Total - Tax] |
| **G. Payment Date** | [YYYY-MM-DD] | [Fixed rule: 30th] |
| **H. Department Code** | [e.g., K] | [Mapping code] |
| **I. Total Amount** | [Total amount] | [OCR recognition] |

## Phase 2: Data Writing (Action)
When the user replies "Confirm" or "No problem":
1.  Call the MCP tool `add_invoice_record` to write the data.
2.  After the tool executes successfully, output standard JSON format and provide Google Sheet link.

---

# Attention
* If the image is blurry, mark it as "Unable to recognize" and ask the user.
* Prioritize trusting the visually identified "Total Amount" text and ignore intermediate item subtotals.
```

**C. Advanced Configuration: Integrate Google Sheet for Automatic Archiving**

{% hint style="info" %}
[How to integrate MCP tools?](https://docs.maiagent.ai/tech/remote-mcp/remote-mcp)
{% endhint %}

### 3. AI Assistant Online Application <a href="#id-1.-jian-li-cai-wu-zi-liao-fen-xi-ai-zhu-li" id="id-1.-jian-li-cai-wu-zi-liao-fen-xi-ai-zhu-li"></a>

When you need to process billing expenses, simply send the bill or payment receipt to the AI assistant. The system will automatically analyze the content and standardize the extracted data according to internal company regulations (such as automatically mapping department codes and calculating pre-tax amounts). Finally, it will directly write the data into the ERP system or Google Sheet reports, achieving one-click automation from receipt recognition to account creation.

**Automatic Bill Content Detection**

<figure><img src="/files/VqHOutCvkCN5kPjIga0P" alt=""><figcaption></figcaption></figure>

**Automatic Writing of Bill Content to Google Sheet**

<figure><img src="/files/sx5Yex7N3dEZKNmMBPSs" alt=""><figcaption></figcaption></figure>

**Automatic Conversion to ERP Format JSON**

```
{
  "expenditure_department": "Taipei Headquarters",
  "cost_item": "Water Fee",
  "summary": "114/03/05-114/05/04 Taipei Water Fee",
  "invoice_number": "TP88776655",
  "tax_amount": 50,
  "pre_tax_amount": 1450,
  "payment_date": "2025-05-30",
  "department_code": "T"
}
```

### 4. Technical Advantages of the Intelligent Billing Assistant

#### 🚀 Powerful Vision Language Model (Vision Language Model)

* **Semantic Understanding & Dynamic Reasoning:** The model does not rely on fixed template coordinates but extracts information by understanding the context semantics of the document. Additionally, business rules can be flexibly extended through the System Prompt without the need to redevelop programs.

> *Application Examples:*
>
> * Automatic Categorization: Upon seeing the "Water Corporation" logo, automatically categorize the account as "Water Fee."
> * Logic Completion: Upon seeing "Kaohsiung address," automatically infer and fill in department code "K."
> * Rule Extension: If new logic for "Taipei Branch" judgment is needed in the future, only prompt adjustment is required for it to take effect.

* **High Environmental Adaptability:** Equipped with interference-resistant visual recognition capabilities. Even if the user uploads mobile phone photos with shadows, wrinkles, reflections, or slight blurriness, the vLM can accurately restore values and text based on context, significantly reducing the need for manual retakes or supplementary entries.

#### **🛠️ Precise Tool Invocation & Logic Execution (Tool Use & Integration)**

* Automated Report Writing: Through the Google Sheets writing tool, the assistant can directly write parsed information into specified cloud spreadsheet fields.

> Replaces the traditional tedious process of "manually looking at receipts and manually keying in tables," truly achieving "one photo of receipt, report completed."

* **Structured Format & Seamless ERP Integration:** Enforces output format specifications to ensure data can directly correspond to enterprise internal system (ERP) requirements.

> *Application Examples:*
>
> * Date Unification: Whether the invoice shows `2024/01/01` or `113年1月1日` (Year 113 January 1st in ROC calendar), it is automatically converted to standard `YYYY-MM-DD` before writing.
> * System Integration: Supports direct output of standard JSON format for direct invocation by enterprise ERP APIs.

* **Logic Compliance Validation:** The assistant not only transfers data but can also invoke calculation tools for numerical and compliance checks.

> *Application Examples:* Automatically validates `Total - Tax = Pre-tax Amount`, or locks specific payment dates according to corporate regulations (such as the 30th of each month), ensuring that every piece of data entering the system complies with financial logic and security regulations.

{% file src="/files/A6bZSIx6FND0NtavnCwU" %}

Through the MaiAgent Intelligent Billing Assistant, finance teams can not only break free from tedious receipt entry work but also ensure 100% accuracy in the attribution and codes of every expense, truly achieving unmanned automated processing from "receipts" to "reports"!

**Experience the Billing Expense Assistant now and make your financial processes not just digitized, but intelligentized!**


---

# Agent Instructions: 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:

```
GET https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/application/km/zhang-dan-fei-yong-zhu-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
