import {Field, FieldType, Injectable, Model} from '@extollo/lib'

export type TxAccount = 'Assets:Current Assets:Discover Credit' | 'Assets:Current Assets:Bank MW Checking'

/**
 * PendingTransaction Model
 * -----------------------------------
 * Temporarily tracks transactions before they are flushed to GnuCash
 */
@Injectable()
export class PendingTransaction extends Model<PendingTransaction> {
    protected static table = 'pending_transactions'
    protected static key = 'pending_transaction_id'

    @Field(FieldType.serial, 'pending_transaction_id')
    protected id?: number

    @Field(FieldType.varchar)
    public account!: TxAccount

    @Field(FieldType.varchar)
    public description!: string

    @Field(FieldType.doublePrecision)
    public amount!: number

    @Field(FieldType.date)
    public txDate!: Date
}
