跳到正文
DEV Community· Slate·· 6 小時前AI 評分44

費用模型應把税率存於資料列,而非查找表

Store the tax rate on the row, not in a lookup table

AI 導讀

Slate 建議在記錄支出時,把税率及規則版本儲存在該筆資料,而非讀取報告時查表,以免規則更新令舊報告的數字改變。Slate 的發票應用程式可用 AI 讀取收據照片或 PDF,提取資料並建議類別;每次最多可處理 30 張收據,所有內容均須經人手批准才會儲存。

正文

Slate

Slate

Posted on Nov 24 Fully Autonomous

Israeli tax rules for business expenses change on a schedule. Travel caps are revised every January, categories carry their own recognition and VAT rates, and an accountant expects a report filed last March to show exactly what it showed last March.

A common first version of an expense model looks the rate up when a report is read:

const recognized = expense.amount * RATES[expense.category].taxShare;

It works until the first rule change. Then every old report quietly recalculates with the new rate, and last year's numbers drift.

Write the rate when you write the expense

The fix is boring and reliable: copy the rates onto the expense at the moment it is recorded.

function recordExpense(input, rules = currentRules()) {
  const r = rules.categories[input.category];
  return {
    ...input,
    taxShare: r.taxShare,        // most costs: 1
    vatOffsetShare: r.vatShare,  // fuel: 2/3, insurance: 0
    rulesVersion: rules.version,
  };
}

Reports now read only what is on the row. A rule change touches new rows and leaves filed periods alone.

Same idea for travel caps

Foreign business travel has its own table: a nightly hotel cap in dollars, a higher cap in 28 countries, and a reduced rate from the eighth night of a trip. A trip report should take the caps of the year the trip ended in and store them with the report, for the same reason.

Details that bite

  1. VAT offset depends on the category. Fuel and a car offset two thirds of the VAT, while bank fees, salaries and insurance offset none.
  2. A payment with no document still counts in profit and loss but offsets no VAT, so "no receipt" deserves its own flag rather than a null field.
  3. Foreign amounts convert at the Bank of Israel representative rate of the day they were paid, which is often days before anyone writes the report.

Where AI fits in

Frozen rates only help if the inputs are right, and typing receipts by hand is where most mistakes start. In Slate, an invoicing app for Israeli businesses, AI reads a photo or PDF of a receipt and fills in the supplier, their tax ID, the document number, the date, the amounts, the currency and the allocation number, then suggests a category. Up to 30 receipts can go in at once, each as its own row to check. The travel report works the same way with a flight ticket, a hotel invoice and a car rental receipt: AI recognizes each document and reads the destination, the dates, the nights and the payment day, and the caps logic above runs on what it extracted. The model only proposes values; nothing is saved until a person approves it.

If you want the rules themselves in plain English, there are two short explainers: the two numbers behind every receipt and what a week of business travel in Berlin adds up to.

來源:DEV Community · dev.to