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.



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

def autoinvoice_infos
  @autoinvoice_infos
end

#invoice_infosObject (readonly)

Returns the value of attribute invoice_infos.



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

def invoice_infos
  @invoice_infos
end

#modelObject (readonly)

Returns the value of attribute model.



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

def model
  @model
end

Instance Method Details

#ajax_collect_garbageObject



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

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

#ajax_delete_autoinvoiceObject



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

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

#ajax_invoicesObject



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

def ajax_invoices
	super(@invoice_infos)
end

#generate_invoiceObject



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

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

#initObject



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

def init
	super
	load_autoinvoices
	load_invoices
end

#updateObject



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

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