diff --git a/lib/lunchmoney.rb b/lib/lunchmoney.rb index f1d76a7..d75b2e0 100644 --- a/lib/lunchmoney.rb +++ b/lib/lunchmoney.rb @@ -12,6 +12,9 @@ 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" require_relative "lunchmoney/validators" require_relative "lunchmoney/api" diff --git a/lib/lunchmoney/budget/budget_calls.rb b/lib/lunchmoney/budget/budget_calls.rb index 156b144..7bc832c 100644 --- a/lib/lunchmoney/budget/budget_calls.rb +++ b/lib/lunchmoney/budget/budget_calls.rb @@ -47,10 +47,10 @@ def budgets(start_date:, end_date:, currency: nil) params( start_date: String, category_id: Integer, - amount: T.any(Integer, Float), + amount: Number, currency: T.nilable(String), ).returns(T.any( - T::Hash[Symbol, { category_id: Integer, amount: T.any(Integer, Float), currency: String, start_date: String }], + T::Hash[Symbol, { category_id: Integer, amount: Number, currency: String, start_date: String }], LunchMoney::Errors, )) end diff --git a/lib/lunchmoney/budget/config.rb b/lib/lunchmoney/budget/config.rb index 3bdbd5c..2bd3169 100644 --- a/lib/lunchmoney/budget/config.rb +++ b/lib/lunchmoney/budget/config.rb @@ -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 @@ -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 diff --git a/lib/lunchmoney/budget/data.rb b/lib/lunchmoney/budget/data.rb index 719f0f9..91cad10 100644 --- a/lib/lunchmoney/budget/data.rb +++ b/lib/lunchmoney/budget/data.rb @@ -9,7 +9,7 @@ class Data < LunchMoney::DataObject sig { returns(T.nilable(Integer)) } attr_accessor :num_transactions - sig { returns(T.nilable(T.any(Integer, Float))) } + sig { returns(T.nilable(Number)) } attr_accessor :budget_amount, :budget_to_base, :spending_to_base sig { returns(T.nilable(String)) } @@ -20,11 +20,11 @@ class Data < LunchMoney::DataObject sig do params( - spending_to_base: T.nilable(T.any(Integer, Float)), + spending_to_base: T.nilable(Number), num_transactions: T.nilable(Integer), - budget_amount: T.nilable(T.any(Integer, Float)), + budget_amount: T.nilable(Number), budget_currency: T.nilable(String), - budget_to_base: T.nilable(T.any(Integer, Float)), + budget_to_base: T.nilable(Number), is_automated: T.nilable(T::Boolean), ).void end diff --git a/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb b/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb index ad1f34f..7c8a84b 100644 --- a/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb +++ b/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb @@ -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:, diff --git a/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb b/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb index 6ca1ac8..1de1752 100644 --- a/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb +++ b/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb @@ -7,7 +7,7 @@ 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 @@ -15,7 +15,7 @@ class RecurringExpenseBase < LunchMoney::DataObject 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:) diff --git a/lib/lunchmoney/transactions/transaction/child_transaction.rb b/lib/lunchmoney/transactions/transaction/child_transaction.rb index 180c25a..4cbfefe 100644 --- a/lib/lunchmoney/transactions/transaction/child_transaction.rb +++ b/lib/lunchmoney/transactions/transaction/child_transaction.rb @@ -14,7 +14,7 @@ class ChildTransaction < TransactionBase date: String, amount: String, currency: String, - to_base: T.any(Integer, Float), + to_base: Number, payee: String, formatted_date: String, notes: T.nilable(String), diff --git a/lib/lunchmoney/transactions/transaction/split.rb b/lib/lunchmoney/transactions/transaction/split.rb index 64a6b05..337f95d 100644 --- a/lib/lunchmoney/transactions/transaction/split.rb +++ b/lib/lunchmoney/transactions/transaction/split.rb @@ -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), diff --git a/lib/lunchmoney/transactions/transaction/transaction.rb b/lib/lunchmoney/transactions/transaction/transaction.rb index 5b8790f..8570d0d 100644 --- a/lib/lunchmoney/transactions/transaction/transaction.rb +++ b/lib/lunchmoney/transactions/transaction/transaction.rb @@ -56,7 +56,7 @@ class Transaction < TransactionBase date: String, amount: String, currency: String, - to_base: T.any(Integer, Float), + to_base: Number, payee: String, is_income: T::Boolean, exclude_from_budget: T::Boolean, diff --git a/lib/lunchmoney/transactions/transaction/transaction_base.rb b/lib/lunchmoney/transactions/transaction/transaction_base.rb index 08f6fc2..dbac1b9 100644 --- a/lib/lunchmoney/transactions/transaction/transaction_base.rb +++ b/lib/lunchmoney/transactions/transaction/transaction_base.rb @@ -7,7 +7,7 @@ class TransactionBase < LunchMoney::DataObject sig { returns(Integer) } attr_accessor :id - sig { returns(T.any(Integer, Float)) } + sig { returns(Number) } attr_accessor :to_base sig { returns(T.nilable(Integer)) } @@ -28,7 +28,7 @@ class TransactionBase < LunchMoney::DataObject date: String, amount: String, currency: String, - to_base: T.any(Integer, Float), + to_base: Number, payee: String, notes: T.nilable(String), asset_id: T.nilable(Integer),