Skip to content

Commit

Permalink
convert more types to number
Browse files Browse the repository at this point in the history
  • Loading branch information
mmenanno committed Jan 31, 2024
1 parent 6864bee commit 37ceb60
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/lunchmoney.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Module
include T::Sig
end

# Add type alias for when Integer and Float can both be used
Number = T.type_alias { T.any(Integer, Float) }

require_relative "lunchmoney/version"
Expand Down
9 changes: 6 additions & 3 deletions lib/lunchmoney/budget/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ class Config < LunchMoney::DataObject
# API object reference documentation: https://lunchmoney.dev/#config-object

sig { returns(Integer) }
attr_accessor :config_id, :amount, :to_base
attr_accessor :config_id

sig { returns(Number) }
attr_accessor :amount, :to_base

sig { returns(String) }
attr_accessor :cadence, :currency, :auto_suggest
Expand All @@ -16,9 +19,9 @@ class Config < LunchMoney::DataObject
params(
config_id: Integer,
cadence: String,
amount: Integer,
amount: Number,
currency: String,
to_base: Integer,
to_base: Number,
auto_suggest: String,
).void
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RecurringExpense < RecurringExpenseBase
plaid_account_id: T.nilable(Integer),
asset_id: T.nilable(Integer),
transaction_id: T.nilable(Integer),
to_base: T.nilable(Integer),
to_base: T.nilable(Number),
).void
end
def initialize(cadence:, payee:, amount:, currency:, billing_date:, type:, source:, id:, created_at:,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class RecurringExpenseBase < LunchMoney::DataObject
sig { returns(String) }
attr_accessor :payee, :currency, :amount

sig { returns(T.nilable(Integer)) }
sig { returns(T.nilable(Number)) }
attr_accessor :to_base

sig do
params(
payee: String,
amount: String,
currency: String,
to_base: T.nilable(Integer),
to_base: T.nilable(Number),
).void
end
def initialize(payee:, amount:, currency:, to_base:)
Expand Down
4 changes: 2 additions & 2 deletions lib/lunchmoney/transactions/transaction/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
module LunchMoney
# Object used to split a transaction when updating https://lunchmoney.dev/#update-transaction
class Split < TransactionModificationBase
sig { returns(T.any(Integer, String)) }
sig { returns(T.any(Number, String)) }
attr_accessor :amount

sig do
params(
amount: T.any(Integer, String),
amount: T.any(Number, String),
payee: T.nilable(String),
date: T.nilable(String),
category_id: T.nilable(Integer),
Expand Down

0 comments on commit 37ceb60

Please sign in to comment.