Sha256: 168f5119af1bce611997525c38f36494101f4c633dc647f3b9180a8ceba5a651

Contents?: true

Size: 647 Bytes

Versions: 11

Compression:

Stored size: 647 Bytes

Contents

module LogCabin
  module Modules
    ##
    # Provide a helper to create simple Ledger objects
    module Ledger
      def simple_ledger(date, name, amount)
        ::Ledger::Entry.new(
          name: name,
          state: date > Date.today ? :pending : :cleared,
          date: date.strftime('%Y/%m/%d'),
          actions: [
            { name: guess_action(name), amount: amount },
            { name: account_name }
          ]
        )
      end

      def guess_action(name)
        guess = `ledger xact '#{name.delete("'")}' 2>/dev/null`.split("\n")[1]
        guess ? guess.split.first : 'Expenses:generic'
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
burglar-0.3.2 lib/burglar/helpers/ledger.rb
burglar-0.3.1 lib/burglar/helpers/ledger.rb
burglar-0.3.0 lib/burglar/helpers/ledger.rb
burglar-0.2.0 lib/burglar/helpers/ledger.rb
burglar-0.1.4 lib/burglar/helpers/ledger.rb
burglar-0.1.3 lib/burglar/helpers/ledger.rb
burglar-0.1.2 lib/burglar/helpers/ledger.rb
burglar-0.1.1 lib/burglar/helpers/ledger.rb
burglar-0.1.0 lib/burglar/helpers/ledger.rb
burglar-0.0.3 lib/burglar/helpers/ledger.rb
burglar-0.0.2 lib/burglar/helpers/ledger.rb