Class: Liquid::InvoiceDrop

Inherits:
Drop
  • Object
show all
Includes:
Memery
Defined in:
app/models/liquid/invoice_drop.rb

Overview

Helper class scoped to Liquid.

Instance Attribute Summary collapse

Delegated Instance Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(invoice) ⇒ InvoiceDrop

Returns a new instance of InvoiceDrop.

Parameters:

  • invoice (Invoice)

    invoice to wrap



37
38
39
# File 'app/models/liquid/invoice_drop.rb', line 37

def initialize(invoice)
  @invoice = invoice
end

Instance Attribute Details

#invoiceInvoice (readonly)

Returns:



8
9
10
# File 'app/models/liquid/invoice_drop.rb', line 8

def invoice
  @invoice
end

Instance Method Details

#balance_formattedObject

Methods that are only used in Liquid templates - implemented directly in drop



42
43
44
45
46
# File 'app/models/liquid/invoice_drop.rb', line 42

def balance_formatted
  return '0.00' unless invoice.respond_to?(:balance) && invoice.balance

  ActionController::Base.helpers.number_to_currency(invoice.balance).to_s
end

#customerObject

Alias for Invoice#customer

Returns:

  • (Object)

    Invoice#customer

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

#fully_funded_by_rma?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'app/models/liquid/invoice_drop.rb', line 30

def fully_funded_by_rma?
  invoice.fully_funded_by_rma?
rescue StandardError
  false
end

#funded_by_cod?Object

Alias for Invoice#funded_by_cod?

Returns:

  • (Object)

    Invoice#funded_by_cod?

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

#funded_by_rma?Object

Alias for Invoice#funded_by_rma?

Returns:

  • (Object)

    Invoice#funded_by_rma?

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

#has_return_instructions?Boolean

Alias methods for template compatibility

Returns:

  • (Boolean)


63
64
65
# File 'app/models/liquid/invoice_drop.rb', line 63

def has_return_instructions?
  return_instructions?
end

#has_return_labels?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'app/models/liquid/invoice_drop.rb', line 68

def has_return_labels?
  return_labels?
end

#not_rma?Object

Alias for Invoice#not_rma?

Returns:

  • (Object)

    Invoice#not_rma?

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

Alias for Invoice#public_pay_link

Returns:

  • (Object)

    Invoice#public_pay_link

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

Returns:

  • (String, nil)


73
74
75
76
77
# File 'app/models/liquid/invoice_drop.rb', line 73

def 
  return nil unless invoice.order&.customer && invoice.order.customer..present?

  invoice.order.customer..email
end

Alias for Invoice#public_pay_link_has_auth_token?

Returns:

  • (Object)

    Invoice#public_pay_link_has_auth_token?

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

#reference_numberObject

Alias for Invoice#reference_number

Returns:

  • (Object)

    Invoice#reference_number

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

#return_instructions?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'app/models/liquid/invoice_drop.rb', line 49

def return_instructions?
  return false unless invoice.order&.rma

  invoice.order.rma.return_instructions.present?
end

#return_labels?Boolean

Returns:

  • (Boolean)


56
57
58
59
60
# File 'app/models/liquid/invoice_drop.rb', line 56

def return_labels?
  return false unless invoice.order&.rma

  invoice.order.rma.return_label_required?
end

#rma_awaiting_return?Object

Alias for Invoice#rma_awaiting_return?

Returns:

  • (Object)

    Invoice#rma_awaiting_return?

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice

#rma_numberObject

Safe wrapper methods for potentially problematic calls



23
24
25
26
27
# File 'app/models/liquid/invoice_drop.rb', line 23

def rma_number
  invoice.rma_number
rescue StandardError
  nil
end

#stateObject

Alias for Invoice#state

Returns:

  • (Object)

    Invoice#state

See Also:



11
12
13
14
15
16
17
18
19
20
# File 'app/models/liquid/invoice_drop.rb', line 11

delegate :reference_number,
:customer,
:state,
:public_pay_link,
:public_pay_link_has_auth_token?,
:not_rma?,
:funded_by_rma?,
:funded_by_cod?,
:rma_awaiting_return?,
to: :invoice