Private/Classes.ps1

# Budget Entity Classes

class Biller {
    [string]$Name
    [datetime]$StartDate
    [string]$Frequency  # Daily, Weekly, BiWeekly, Monthly, Bimonthly, Quarterly, Yearly
    [decimal]$Amount
    [string]$Id

    Biller() {
        $this.Id = [guid]::NewGuid().ToString()
    }

    Biller([string]$name, [datetime]$startDate, [string]$frequency, [decimal]$amount) {
        $this.Id = [guid]::NewGuid().ToString()
        $this.Name = $name
        $this.StartDate = $startDate
        $this.Frequency = $frequency
        $this.Amount = $amount
    }

    [hashtable] ToHashtable() {
        return @{
            Id = $this.Id
            Name = $this.Name
            StartDate = $this.StartDate.ToString('yyyy-MM-dd')
            Frequency = $this.Frequency
            Amount = $this.Amount
        }
    }
}

class Earning {
    [string]$Name
    [datetime]$StartDate
    [string]$Frequency  # Daily, Weekly, BiWeekly, Monthly, Bimonthly, Quarterly, Yearly
    [decimal]$Amount
    [string]$Id

    Earning() {
        $this.Id = [guid]::NewGuid().ToString()
    }

    Earning([string]$name, [datetime]$startDate, [string]$frequency, [decimal]$amount) {
        $this.Id = [guid]::NewGuid().ToString()
        $this.Name = $name
        $this.StartDate = $startDate
        $this.Frequency = $frequency
        $this.Amount = $amount
    }

    [hashtable] ToHashtable() {
        return @{
            Id = $this.Id
            Name = $this.Name
            StartDate = $this.StartDate.ToString('yyyy-MM-dd')
            Frequency = $this.Frequency
            Amount = $this.Amount
        }
    }
}

class Account {
    [string]$Name
    [string]$Bank
    [string]$Last4Digits
    [string]$Id

    Account() {
        $this.Id = [guid]::NewGuid().ToString()
    }

    Account([string]$name, [string]$bank, [string]$last4Digits) {
        $this.Id = [guid]::NewGuid().ToString()
        $this.Name = $name
        $this.Bank = $bank
        $this.Last4Digits = $last4Digits
    }

    [hashtable] ToHashtable() {
        return @{
            Id = $this.Id
            Name = $this.Name
            Bank = $this.Bank
            Last4Digits = $this.Last4Digits
        }
    }
}

class Transaction {
    [datetime]$Date
    [string]$Name
    [decimal]$Amount
    [decimal]$Balance
    [string]$Type  # Earning or Biller
    [string]$AccountId

    Transaction() {}

    Transaction([datetime]$date, [string]$name, [decimal]$amount, [decimal]$balance) {
        $this.Date = $date
        $this.Name = $name
        $this.Amount = $amount
        $this.Balance = $balance
    }

    [hashtable] ToHashtable() {
        return @{
            Date = $this.Date
            Name = $this.Name
            Amount = $this.Amount
            Balance = $this.Balance
            Type = $this.Type
            AccountId = $this.AccountId
        }
    }
}