Files
accounting-frontend/src/types/index.ts
Shayan Azadi f6b6e27294 Add FunZone sync for sales and purchases, voucher filters, and event-name support.
Manual sync buttons pull customer payments and owner payouts into treasury, invoices, and accounting vouchers; voucher page gains category, date, status, and search filters; supplier vouchers dedupe against treasury-backed entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 22:09:08 +03:30

213 lines
4.6 KiB
TypeScript

export type ID = string
export type AccountType = 'asset' | 'liability' | 'equity' | 'income' | 'expense'
export interface Account {
id: ID
code: string
name: string
type: AccountType
parentId: ID | null
isGroup: boolean
openingBalance: number
}
export interface VoucherLine {
id: ID
accountId: ID
description: string
debit: number
credit: number
}
export type VoucherStatus = 'draft' | 'posted'
export interface Voucher {
id: ID
number: number
date: string
description: string
/** Event or subject the voucher relates to (بابت). */
regarding?: string
status: VoucherStatus
lines: VoucherLine[]
/** Set when the voucher was generated automatically by another module. */
source?: string
}
export type PartyKind = 'customer' | 'supplier'
export type PartyExternalSource = '' | 'funzone_customer' | 'funzone_owner'
export interface Party {
id: ID
kind: PartyKind
name: string
phone: string
economicCode: string
address: string
openingBalance: number
/** FunZone user id when synced from the platform. */
externalId?: ID
externalSource?: PartyExternalSource
firstName?: string
lastName?: string
username?: string
email?: string
nationalCode?: string
iban?: string
walletBalance?: number
isActive?: boolean
isVerified?: boolean
birthday?: string | null
/** Venue names for owner/supplier records. */
venues?: string[]
}
export interface Product {
id: ID
code: string
name: string
unit: string
salePrice: number
purchasePrice: number
stock: number
reorderLevel: number
}
export type SalesDocumentType = 'proforma' | 'invoice' | 'return'
export interface SalesType {
id: ID
code: string
name: string
description: string
active: boolean
}
export type AdjustmentKind = 'debit' | 'credit'
/** Debit/credit notice adjusting customer receivable (اعلامیه بدهکار/بستانکار). */
export interface PartyAdjustment {
id: ID
number: number
partyId: ID
kind: AdjustmentKind
date: string
amount: number
description: string
}
export interface InvoiceLine {
id: ID
productId: ID
quantity: number
unitPrice: number
discount: number
taxRate: number
/** FunZone event the customer paid for (shown in کالا / بابت). */
eventName?: string
}
export type InvoiceKind = 'sale' | 'purchase'
export type InvoiceStatus = 'draft' | 'confirmed' | 'paid'
export interface Invoice {
id: ID
kind: InvoiceKind
documentType: SalesDocumentType
number: number
partyId: ID
salesTypeId?: ID
relatedInvoiceId?: ID
date: string
status: InvoiceStatus
note: string
lines: InvoiceLine[]
}
export type TreasuryKind = 'receipt' | 'payment'
export type TreasuryMethod = 'cash' | 'bank' | 'cheque'
export interface TreasuryTxn {
id: ID
number: number
kind: TreasuryKind
method: TreasuryMethod
date: string
partyId: ID | null
amount: number
/** Event ticket fee split (FunZone): tax 10%, platform profit 14%, owner net 76%. */
taxAmount?: number
platformProfitAmount?: number
ownerNetAmount?: number
reference: string
description: string
/** FunZone event name when imported from customer payments. */
eventName?: string
/** Set when imported from FunZone platform (dedup key). */
source?: string
}
export interface Employee {
id: ID
code: string
name: string
position: string
baseSalary: number
insuranceNo: string
hireDate: string
active: boolean
}
export interface Payslip {
id: ID
employeeId: ID
period: string
baseSalary: number
overtime: number
bonus: number
deductions: number
insurance: number
tax: number
}
/** Account mapping used to auto-generate journal vouchers from live FunZone data. */
export interface VoucherAccountMap {
/** Cash/bank settlement account (debit on inflow, credit on outflow). */
bankAccountId: ID
/** Liability owed to venue owners (their wallet balance). */
ownerPayableAccountId: ID
/** Liability owed to customers (their wallet balance). */
customerPayableAccountId: ID
/** Expense recognising the owner's share of a booking. */
ownerShareAccountId: ID
/** Income account for reservation/ticket sales. */
salesIncomeAccountId: ID
}
export interface CompanySettings {
name: string
economicCode: string
fiscalYear: string
baseCurrency: string
taxRate: number
address: string
phone: string
voucherAccounts: VoucherAccountMap
}
export interface AppData {
accounts: Account[]
vouchers: Voucher[]
parties: Party[]
products: Product[]
invoices: Invoice[]
salesTypes: SalesType[]
partyAdjustments: PartyAdjustment[]
treasury: TreasuryTxn[]
employees: Employee[]
payslips: Payslip[]
settings: CompanySettings
}