Class: YDIM::AutoInvoicer
- Inherits:
-
Object
- Object
- YDIM::AutoInvoicer
- Defined in:
- lib/ydim/autoinvoicer.rb
Instance Method Summary collapse
- #autoinvoice(debitor) ⇒ Object
- #generate(autoinvoice) ⇒ Object
-
#initialize(serv) ⇒ AutoInvoicer
constructor
A new instance of AutoInvoicer.
- #run ⇒ Object
Constructor Details
#initialize(serv) ⇒ AutoInvoicer
Returns a new instance of AutoInvoicer.
13 14 15 |
# File 'lib/ydim/autoinvoicer.rb', line 13 def initialize(serv) @serv = serv end |
Instance Method Details
#autoinvoice(debitor) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
35 36 37 38 39 |
# File 'lib/ydim/autoinvoicer.rb', line 35 def generate(autoinvoice) ODBA.transaction { @serv.factory.generate_invoice(autoinvoice) } end |
#run ⇒ Object
16 17 18 19 20 |
# File 'lib/ydim/autoinvoicer.rb', line 16 def run Debitor.odba_extent { |debitor| autoinvoice(debitor) } end |