Class: Vfwcash::Controller
- Inherits:
-
Object
- Object
- Vfwcash::Controller
- Defined in:
- lib/vfwcash/controller.rb
Instance Attribute Summary collapse
-
#cash ⇒ Object
Returns the value of attribute cash.
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #audit ⇒ Object
- #balance ⇒ Object
- #between(from, to) ⇒ Object
- #cb_register ⇒ Object
-
#initialize(date) ⇒ Controller
constructor
A new instance of Controller.
- #ledger ⇒ Object
- #open_pdf(filename) ⇒ Object
- #profit_loss(options) ⇒ Object
- #split ⇒ Object
- #summary ⇒ Object
Constructor Details
#initialize(date) ⇒ Controller
Returns a new instance of Controller.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vfwcash/controller.rb', line 10 def initialize(date) @config = Vfwcash.config require_relative './sqlite_base' @date = date Dir.glob(File.join(LibPath,'models/*')).each do |file| require file end @cash = Gcash.new(@config) unless @cash.dates.include?(@date) puts "No transactions exist for #{@date.beginning_of_month}" exit(0) end end |
Instance Attribute Details
#cash ⇒ Object
Returns the value of attribute cash.
9 10 11 |
# File 'lib/vfwcash/controller.rb', line 9 def cash @cash end |
#config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/vfwcash/controller.rb', line 9 def config @config end |
Instance Method Details
#audit ⇒ Object
68 69 70 71 72 73 |
# File 'lib/vfwcash/controller.rb', line 68 def audit pdf = Audit.new(@date,@cash) filename = "#{PWD}/pdf/audit_#{Vfwcash.yyyymm(@date.beginning_of_quarter)}.pdf" pdf.render_file(filename) open_pdf(filename) end |
#balance ⇒ Object
75 76 77 78 79 80 |
# File 'lib/vfwcash/controller.rb', line 75 def balance pdf = Balance.new(@date,@cash) filename = "#{PWD}/pdf/balance_#{Vfwcash.yyyymm(@date)}.pdf" pdf.render_file(filename) open_pdf(filename) end |
#between(from, to) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/vfwcash/controller.rb', line 32 def between(from,to) pdf = Between.new(@date,@cash,from,to) filename = "#{PWD}/pdf/between_#{from}_#{to}.pdf" pdf.render_file(filename) open_pdf(filename) end |
#cb_register ⇒ Object
54 55 56 57 58 59 |
# File 'lib/vfwcash/controller.rb', line 54 def cb_register pdf = RegisterPdf.new(@date,@cash) filename = "#{PWD}/pdf/register_#{Vfwcash.yyyymm(@date)}.pdf" pdf.render_file(filename) open_pdf(filename) end |
#ledger ⇒ Object
39 40 41 42 43 44 |
# File 'lib/vfwcash/controller.rb', line 39 def ledger pdf = Ledger.new(@date,@cash) filename = "#{PWD}/pdf/ledger_#{Vfwcash.yyyymm(@date)}.pdf" pdf.render_file(filename) open_pdf(filename) end |
#open_pdf(filename) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/vfwcash/controller.rb', line 82 def open_pdf(filename) if Gem::Platform.local.os == 'darwin' `open #{filename}` else `start #{filename}` end end |
#profit_loss(options) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/vfwcash/controller.rb', line 24 def profit_loss() report = @cash.profit_loss() pdf = ProfitLoss.new(report) filename = "#{PWD}/pdf/pl_#{report['options'][:from]}_#{report['options'][:to]}.pdf" pdf.render_file(filename) open_pdf(filename) end |
#split ⇒ Object
61 62 63 64 65 66 |
# File 'lib/vfwcash/controller.rb', line 61 def split pdf = SplitLedger.new(@date,@cash) filename = "#{PWD}/pdf/split_#{Vfwcash.yyyymm(@date)}.pdf" pdf.render_file(filename) open_pdf(filename) end |