class YDIM::AutoInvoicer

Public Class Methods

new(serv) click to toggle source
# File lib/ydim/autoinvoicer.rb, line 13
def initialize(serv)
        @serv = serv
end

Public Instance Methods

autoinvoice(debitor) click to toggle source
# File lib/ydim/autoinvoicer.rb, line 21
          def autoinvoice(debitor)
today = Date.today
next_month = today >> 1
debitor.autoinvoices.each { |auto|
  if(auto.total_netto > 0)
    case auto.date
    when today
      Mail.send_invoice(@serv.config, generate(auto)) 
    when next_month
      Mail.send_reminder(@serv.config, auto)
    end
  end
}
          end
generate(autoinvoice) click to toggle source
# File lib/ydim/autoinvoicer.rb, line 35
          def generate(autoinvoice)
ODBA.transaction {
  @serv.factory.generate_invoice(autoinvoice)
}
          end
run() click to toggle source
# File lib/ydim/autoinvoicer.rb, line 16
def run
        Debitor.odba_extent { |debitor| 
                autoinvoice(debitor)
        }
end