Class: YDIM::Html::State::Debitor

Inherits:
Global
  • Object
show all
Includes:
AjaxInvoiceMethods
Defined in:
lib/ydim/html/state/debitor.rb

Constant Summary collapse

VIEW =
Html::View::Debitor

Constants inherited from Global

Global::EVENT_MAP

Instance Attribute Summary collapse

Attributes inherited from Global

#sort_reverse, #sortby

Instance Method Summary collapse

Methods included from AjaxInvoiceMethods

#ajax_status, #currency_convert, #sort_invoices

Methods inherited from Global

#_create_invoice, #autoinvoice, #create_autoinvoice, #create_debitor, #create_invoice, #debitor, #invoice, #logout, #pdf, #send_invoice

Instance Attribute Details

#autoinvoice_infosObject (readonly)

Returns the value of attribute autoinvoice_infos.



19
20
21
# File 'lib/ydim/html/state/debitor.rb', line 19

def autoinvoice_infos
  @autoinvoice_infos
end

#invoice_infosObject (readonly)

Returns the value of attribute invoice_infos.



19
20
21
# File 'lib/ydim/html/state/debitor.rb', line 19

def invoice_infos
  @invoice_infos
end

#modelObject (readonly)

Returns the value of attribute model.



19
20
21
# File 'lib/ydim/html/state/debitor.rb', line 19

def model
  @model
end

Instance Method Details

#ajax_collect_garbageObject



26
27
28
29
# File 'lib/ydim/html/state/debitor.rb', line 26

def ajax_collect_garbage
  @session.collect_garbage(@model.unique_id)
  AjaxInvoices.new(@session, [])
end

#ajax_delete_autoinvoiceObject



30
31
32
33
34
35
# File 'lib/ydim/html/state/debitor.rb', line 30

def ajax_delete_autoinvoice
  if(id = @session.user_input(:unique_id))
    @session.delete_autoinvoice(id)
  end
AjaxAutoInvoices.new(@session, load_autoinvoices)
end

#ajax_invoicesObject



36
37
38
# File 'lib/ydim/html/state/debitor.rb', line 36

def ajax_invoices
	super(@invoice_infos)
end

#generate_invoiceObject



39
40
41
42
43
# File 'lib/ydim/html/state/debitor.rb', line 39

def generate_invoice
	if(id = @session.user_input(:unique_id))
		Invoice.new(@session, @session.generate_invoice(id.to_i))
	end
end

#initObject



21
22
23
24
25
# File 'lib/ydim/html/state/debitor.rb', line 21

def init
	super
	load_autoinvoices
	load_invoices
end

#updateObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ydim/html/state/debitor.rb', line 44

def update
	mandatory = [ :contact, :debitor_type, :emails,
		:location, :name, ]
	defaults = {}
	keys = mandatory.dup.push(:address_lines, :contact_firstname,
                             :contact_title, :country, :salutation, :phone)
	input = defaults.update(user_input(keys, mandatory))
   mails = input[:emails]
   if mails && mails.size > 3
     @errors.store :emails, create_error('e_too_many_emails',
                                         :emails, mails.join(', '))
     input[:emails] = mails[0,3]
   end
	unless(error? || @model.unique_id)
		@model = @session.create_debitor
	end
	update_model(input)
	self
end