Class: YDIM::Html::State::Global

Inherits:
SBSM::State
  • Object
show all
Defined in:
lib/ydim/html/state/global.rb,
lib/ydim/html/state/global_predefine.rb

Direct Known Subclasses

Confirm, CreateInvoice, Debitor, Debitors, Invoice, Invoices

Defined Under Namespace

Classes: Stub

Constant Summary collapse

EVENT_MAP =
{
	:debitors	=>	Debitors,
	:invoices	=>	Invoices,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sort_reverseObject

Returns the value of attribute sort_reverse.



17
18
19
# File 'lib/ydim/html/state/global.rb', line 17

def sort_reverse
  @sort_reverse
end

#sortbyObject

Returns the value of attribute sortby.



17
18
19
# File 'lib/ydim/html/state/global.rb', line 17

def sortby
  @sortby
end

Instance Method Details

#_create_invoice(nextclass, date = Date.today) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ydim/html/state/global.rb', line 54

def _create_invoice(nextclass, date=Date.today)
if((id = @session.user_input(:unique_id)) \
	 && (debitor = @session.debitor(id.to_i)))
	invoice = Stub.new
	invoice.carry(:debitor, debitor)
	invoice.carry(:date, date)
    invoice.carry(:precision, 2)
    if debitor.foreign?
      invoice.carry(:suppress_vat, true)
    end
	nextclass.new(@session, invoice)
end
end

#autoinvoiceObject



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

def autoinvoice
  if(id = @session.user_input(:unique_id))
    AutoInvoice.new(@session, @session.autoinvoice(id))
  end
end

#create_autoinvoiceObject



45
46
47
# File 'lib/ydim/html/state/global.rb', line 45

def create_autoinvoice
  _create_invoice(CreateAutoInvoice, nil)
end

#create_debitorObject



48
49
50
# File 'lib/ydim/html/state/global.rb', line 48

def create_debitor
	Debitor.new(@session, YDIM::Debitor.new(nil))
end

#create_invoiceObject



51
52
53
# File 'lib/ydim/html/state/global.rb', line 51

def create_invoice
   _create_invoice(CreateInvoice)
end

#debitorObject



67
68
69
70
71
# File 'lib/ydim/html/state/global.rb', line 67

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

#invoiceObject



76
77
78
79
80
# File 'lib/ydim/html/state/global.rb', line 76

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

#logoutObject



72
73
74
75
# File 'lib/ydim/html/state/global.rb', line 72

def logout
	@session.logout
	State::Init.new(@session, nil)
end

#pdfObject



81
82
83
84
85
# File 'lib/ydim/html/state/global.rb', line 81

def pdf
	if(id = @session.user_input(:unique_id))
		Pdf.new(@session, @session.invoice(id.to_i))
	end
end

#send_invoiceObject



86
87
88
89
90
91
92
93
94
95
# File 'lib/ydim/html/state/global.rb', line 86

def send_invoice
	if(id = @session.user_input(:unique_id))
     sort_args = { :sortby => (@sortby || []).first,
                   :sort_reverse => @sort_reverse }
		recipients = @session.send_invoice(id.to_i, sort_args)
		message = @session.lookandfeel.lookup(:confirm_send_invoice, 
																					recipients.join(', '))
		Html::State::Confirm.new(@session, message)
	end
end