File size: 1,111 Bytes
c09f67c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
export type AccountType =
  | "depository"
  | "credit"
  | "other_asset"
  | "loan"
  | "other_liability";

/**
 * Account types that represent liquid cash or cash-equivalents.
 * Used for: Runway, Net Position (cash side), Balance Sheet (assets)
 */
export const CASH_ACCOUNT_TYPES = ["depository", "other_asset"] as const;

/**
 * Account types that represent debt/liabilities.
 * Used for: Net Position (debt side), Balance Sheet (liabilities)
 */
export const DEBT_ACCOUNT_TYPES = ["credit", "loan"] as const;

/**
 * Credit card account type.
 * Balances may be positive (Plaid, Teller) or negative (GoCardless, EnableBanking).
 * Always use Math.abs() when calculating debt totals.
 */
export const CREDIT_ACCOUNT_TYPE = "credit" as const;

/**
 * Loan account type (business loans, lines of credit).
 */
export const LOAN_ACCOUNT_TYPE = "loan" as const;

export function getType(type: string): AccountType {
  switch (type) {
    case "depository":
      return "depository";
    case "credit":
      return "credit";
    case "loan":
      return "loan";
    default:
      return "other_asset";
  }
}