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 [string]$AccountId # Associated account ID (null for legacy data) 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 } Biller([string]$name, [datetime]$startDate, [string]$frequency, [decimal]$amount, [string]$accountId) { $this.Id = [guid]::NewGuid().ToString() $this.Name = $name $this.StartDate = $startDate $this.Frequency = $frequency $this.Amount = $amount $this.AccountId = $accountId } [hashtable] ToHashtable() { return @{ Id = $this.Id Name = $this.Name StartDate = $this.StartDate.ToString('yyyy-MM-dd') Frequency = $this.Frequency Amount = $this.Amount AccountId = $this.AccountId } } } class Earning { [string]$Name [datetime]$StartDate [string]$Frequency # Daily, Weekly, BiWeekly, Monthly, Bimonthly, Quarterly, Yearly [decimal]$Amount [string]$Id [string]$AccountId # Associated account ID (null for legacy data) 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 } Earning([string]$name, [datetime]$startDate, [string]$frequency, [decimal]$amount, [string]$accountId) { $this.Id = [guid]::NewGuid().ToString() $this.Name = $name $this.StartDate = $startDate $this.Frequency = $frequency $this.Amount = $amount $this.AccountId = $accountId } [hashtable] ToHashtable() { return @{ Id = $this.Id Name = $this.Name StartDate = $this.StartDate.ToString('yyyy-MM-dd') Frequency = $this.Frequency Amount = $this.Amount AccountId = $this.AccountId } } } 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 } } } class Transfer { [string]$Name [datetime]$StartDate [string]$Frequency # Daily, Weekly, BiWeekly, Monthly, Bimonthly, Quarterly, Yearly [decimal]$Amount [string]$FromAccountId # Source account [string]$ToAccountId # Destination account [string]$Id Transfer() { $this.Id = [guid]::NewGuid().ToString() } Transfer([string]$name, [datetime]$startDate, [string]$frequency, [decimal]$amount, [string]$fromAccountId, [string]$toAccountId) { $this.Id = [guid]::NewGuid().ToString() $this.Name = $name $this.StartDate = $startDate $this.Frequency = $frequency $this.Amount = $amount $this.FromAccountId = $fromAccountId $this.ToAccountId = $toAccountId } [hashtable] ToHashtable() { return @{ Id = $this.Id Name = $this.Name StartDate = $this.StartDate.ToString('yyyy-MM-dd') Frequency = $this.Frequency Amount = $this.Amount FromAccountId = $this.FromAccountId ToAccountId = $this.ToAccountId } } } |