File size: 2,001 Bytes
f1441ea
 
01497d7
f1441ea
01497d7
 
f1441ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
01497d7
 
f1441ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import streamlit as st
import pandas as pd
from huggingface_hub import InferenceClient

# Initialize hosted inference client
client = InferenceClient(model="google/flan-t5-base")

# Simulated chart of accounts mapping
account_map = {
    "rent": "60001",
    "utilities": "60002",
    "cash": "10001",
    "bank": "10002"
}

# Simulated business segments
segment = {
    "company": "01",
    "business_type": "102",  # Grocery Store
    "location": "001",
    "cost_center": "001",
    "future": "000"
}

def parse_prompt(prompt):
    response = client.text_generation(prompt=f"Extract accounting entry: {prompt}", max_new_tokens=50)
    return response

def handle_gl_entry(prompt):
    # Simulate parsing response
    if "rent" in prompt.lower():
        account_name = "rent"
        amount = 500  # Normally extracted from LLM
    else:
        account_name = "utilities"
        amount = 300

    expense_account = account_map[account_name]
    cash_account = account_map["cash"]

    expense_account_code = f"{segment['company']}-{segment['business_type']}-{segment['location']}-{segment['cost_center']}-{expense_account}-{segment['future']}"
    cash_account_code = f"{segment['company']}-{segment['business_type']}-{segment['location']}-{segment['cost_center']}-{cash_account}-{segment['future']}"

    entry = pd.DataFrame([
        {
            "Date": "2025-04-01",
            "Description": f"{account_name.title()} Expense",
            "Account Code": expense_account_code,
            "Debit": amount,
            "Credit": 0
        },
        {
            "Date": "2025-04-01",
            "Description": f"Payment for {account_name}",
            "Account Code": cash_account_code,
            "Debit": 0,
            "Credit": amount
        }
    ])
    return entry

# Streamlit UI
st.title("AI ERP Chat - MVP")
prompt = st.text_input("Enter your accounting instruction:")

if prompt:
    result = handle_gl_entry(prompt)
    st.dataframe(result)  # Show result as a DataFrame