class Vfwcash::Checkbook

Public Instance Methods

__print_date_help() click to toggle source
# File lib/vfwcash/cli.rb, line 15
    def __print_date_help
      puts <<-DATE_HELP
        The DATE parameter is optional on all reports requiring a date and will default to the current date if not present.

        Most dates will be converted to the first of the month requardless of the date entered.

        Entered dates are parsed using Chronic (https://github.com/mojombo/chronic).
        Chronic provide a wide range options.

        Probably the easiest option is the yyyy-mm format (again day is optional) but you can do stuff like:
          last-may
          last-October
          'oct 2014'
        DATE_HELP
    end
__print_version() click to toggle source
# File lib/vfwcash/cli.rb, line 50
def __print_version
  puts "Version: #{Vfwcash::VERSION}"
end
audit( date=nil ) click to toggle source
# File lib/vfwcash/cli.rb, line 183
def audit( date=nil )
  bom = get_date(date)
  Controller.new(bom).audit
end
balance( date=nil ) click to toggle source
# File lib/vfwcash/cli.rb, line 195
def balance( date=nil )
  bom = get_date(date)
  Controller.new(bom).balance
end
between(first, last) click to toggle source
# File lib/vfwcash/cli.rb, line 38
def between(first, last)
  sdate = get_date(first)
  edate = get_date(last)
  bom = sdate - sdate.day + 1
  Controller.new(bom).between(sdate,edate)
end
install() click to toggle source
# File lib/vfwcash/cli.rb, line 99
def install
  Vfwcash.install(options)
end
ledger( date=nil ) click to toggle source
# File lib/vfwcash/cli.rb, line 153
def ledger( date=nil )
  bom = get_date(date)
  Controller.new(bom).ledger
end
profit_loss() click to toggle source
# File lib/vfwcash/cli.rb, line 67
def profit_loss
  # puts "Generate profit_loss report with options  #{options.inspect}"
  Controller.new(Date.today).profit_loss(options)

  # api = Api.new(Date.today.beginning_of_month)
  # pl = api.cash.profit_loss(options)
  # puts api.cash.profit_loss(options).inspect
end
register( date=nil ) click to toggle source
# File lib/vfwcash/cli.rb, line 117
def register( date=nil )
  bom = get_date(date)
  Controller.new(bom).cb_register
end
split( date=nil ) click to toggle source
# File lib/vfwcash/cli.rb, line 136
def split( date=nil )
  bom = get_date(date)
  Controller.new(bom).split
end
summary( date=nil ) click to toggle source
# File lib/vfwcash/cli.rb, line 169
def summary( date=nil )
  bom = get_date(date)
  Controller.new(bom).summary
end

Private Instance Methods

get_date(date) click to toggle source
# File lib/vfwcash/cli.rb, line 202
def get_date(date)
  if  date.nil?
    bom = Date.today
  else
    bom = Chronic.parse(date)
    if bom.nil?
      puts "Invalid date #{date}"
      exit(0)
    else
      bom = bom.to_date
    end
  end
  bom
end