Module: InvoiceBar::Generators

Defined in:
lib/invoice_bar/engine.rb

Constant Summary collapse

@@issued_invoice_number =

Document numbers generators defaults

Proc.new do |n|
  "VF#{self.default_number(n)}"
end
@@received_invoice_number =
Proc.new do |n|
  "PF#{self.default_number(n)}"
end
@@expense_receipt_number =
Proc.new do |n|
  "VD#{self.default_number(n)}"
end
@@income_receipt_number =
Proc.new do |n|
  "PD#{self.default_number(n)}"
end

Class Method Summary collapse

Class Method Details

.default_number(n) ⇒ Object



62
63
64
65
# File 'lib/invoice_bar/engine.rb', line 62

def self.default_number(n)
  number = "#{Time.now.strftime("%Y%m")}#{self.with_zeros(n)}"
  number
end

.expense_receipt_number(n) ⇒ Object



58
59
60
# File 'lib/invoice_bar/engine.rb', line 58

def self.expense_receipt_number(n)
  @@expense_receipt_number.call(n)
end

.income_receipt_number(n) ⇒ Object



54
55
56
# File 'lib/invoice_bar/engine.rb', line 54

def self.income_receipt_number(n)
  @@income_receipt_number.call(n)
end

.issued_invoice_number(n) ⇒ Object



46
47
48
# File 'lib/invoice_bar/engine.rb', line 46

def self.issued_invoice_number(n)
  @@issued_invoice_number.call(n)
end

.received_invoice_number(n) ⇒ Object



50
51
52
# File 'lib/invoice_bar/engine.rb', line 50

def self.received_invoice_number(n)
  @@received_invoice_number.call(n)
end

.with_zeros(n) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/invoice_bar/engine.rb', line 67

def self.with_zeros(n)
  length = n.to_s.length
  number_of_zeros = Integer(4-length)
  zeros = ''

  number_of_zeros.times do
    zeros += '0'
  end

  "#{zeros}#{n}"
end