Class: Mindee::Product::Invoice::InvoiceV4Document

Inherits:
Mindee::Parsing::Common::Prediction show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/invoice/invoice_v4_document.rb

Overview

Invoice API version 4.9 document data.

Direct Known Subclasses

InvoiceV4PagePrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ InvoiceV4Document

Returns a new instance of InvoiceV4Document.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 93

def initialize(prediction, page_id)
  super()
  @billing_address = StringField.new(prediction['billing_address'], page_id)
  @customer_address = StringField.new(prediction['customer_address'], page_id)
  @customer_company_registrations = []
  prediction['customer_company_registrations'].each do |item|
    @customer_company_registrations.push(CompanyRegistrationField.new(item, page_id))
  end
  @customer_id = StringField.new(prediction['customer_id'], page_id)
  @customer_name = StringField.new(prediction['customer_name'], page_id)
  @date = DateField.new(prediction['date'], page_id)
  @document_type = ClassificationField.new(prediction['document_type'], page_id)
  @due_date = DateField.new(prediction['due_date'], page_id)
  @invoice_number = StringField.new(prediction['invoice_number'], page_id)
  @line_items = []
  prediction['line_items'].each do |item|
    @line_items.push(InvoiceV4LineItem.new(item, page_id))
  end
  @locale = LocaleField.new(prediction['locale'], page_id)
  @payment_date = DateField.new(prediction['payment_date'], page_id)
  @po_number = StringField.new(prediction['po_number'], page_id)
  @reference_numbers = []
  prediction['reference_numbers'].each do |item|
    @reference_numbers.push(StringField.new(item, page_id))
  end
  @shipping_address = StringField.new(prediction['shipping_address'], page_id)
  @supplier_address = StringField.new(prediction['supplier_address'], page_id)
  @supplier_company_registrations = []
  prediction['supplier_company_registrations'].each do |item|
    @supplier_company_registrations.push(CompanyRegistrationField.new(item, page_id))
  end
  @supplier_email = StringField.new(prediction['supplier_email'], page_id)
  @supplier_name = StringField.new(prediction['supplier_name'], page_id)
  @supplier_payment_details = []
  prediction['supplier_payment_details'].each do |item|
    @supplier_payment_details.push(PaymentDetailsField.new(item, page_id))
  end
  @supplier_phone_number = StringField.new(prediction['supplier_phone_number'], page_id)
  @supplier_website = StringField.new(prediction['supplier_website'], page_id)
  @taxes = Taxes.new(prediction['taxes'], page_id)
  @total_amount = AmountField.new(prediction['total_amount'], page_id)
  @total_net = AmountField.new(prediction['total_net'], page_id)
  @total_tax = AmountField.new(prediction['total_tax'], page_id)
end

Instance Attribute Details

#billing_addressMindee::Parsing::Standard::StringField (readonly)

The customer’s address used for billing.



14
15
16
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 14

def billing_address
  @billing_address
end

#customer_addressMindee::Parsing::Standard::StringField (readonly)

The address of the customer.



17
18
19
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 17

def customer_address
  @customer_address
end

#customer_company_registrationsArray<Mindee::Parsing::Standard::CompanyRegistrationField> (readonly)

List of company registrations associated to the customer.



20
21
22
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 20

def customer_company_registrations
  @customer_company_registrations
end

#customer_idMindee::Parsing::Standard::StringField (readonly)

The customer account number or identifier from the supplier.



23
24
25
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 23

def customer_id
  @customer_id
end

#customer_nameMindee::Parsing::Standard::StringField (readonly)

The name of the customer or client.



26
27
28
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 26

def customer_name
  @customer_name
end

#dateMindee::Parsing::Standard::DateField (readonly)

The date the purchase was made.



29
30
31
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 29

def date
  @date
end

#document_typeMindee::Parsing::Standard::ClassificationField (readonly)

One of: ‘INVOICE’, ‘CREDIT NOTE’.



32
33
34
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 32

def document_type
  @document_type
end

#due_dateMindee::Parsing::Standard::DateField (readonly)

The date on which the payment is due.



35
36
37
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 35

def due_date
  @due_date
end

#invoice_numberMindee::Parsing::Standard::StringField (readonly)

The invoice number or identifier.



38
39
40
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 38

def invoice_number
  @invoice_number
end

#line_itemsArray<Mindee::Product::Invoice::InvoiceV4LineItem> (readonly)

List of line item details.



41
42
43
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 41

def line_items
  @line_items
end

#localeMindee::Parsing::Standard::LocaleField (readonly)

The locale detected on the document.



44
45
46
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 44

def locale
  @locale
end

#payment_dateMindee::Parsing::Standard::DateField (readonly)

The date on which the payment is due/ was full-filled.



47
48
49
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 47

def payment_date
  @payment_date
end

#po_numberMindee::Parsing::Standard::StringField (readonly)

The purchase order number.



50
51
52
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 50

def po_number
  @po_number
end

#reference_numbersArray<Mindee::Parsing::Standard::StringField> (readonly)

List of Reference numbers, including PO number.



53
54
55
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 53

def reference_numbers
  @reference_numbers
end

#shipping_addressMindee::Parsing::Standard::StringField (readonly)

Customer’s delivery address.



56
57
58
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 56

def shipping_address
  @shipping_address
end

#supplier_addressMindee::Parsing::Standard::StringField (readonly)

The address of the supplier or merchant.



59
60
61
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 59

def supplier_address
  @supplier_address
end

#supplier_company_registrationsArray<Mindee::Parsing::Standard::CompanyRegistrationField> (readonly)

List of company registrations associated to the supplier.



62
63
64
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 62

def supplier_company_registrations
  @supplier_company_registrations
end

#supplier_emailMindee::Parsing::Standard::StringField (readonly)

The email of the supplier or merchant.



65
66
67
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 65

def supplier_email
  @supplier_email
end

#supplier_nameMindee::Parsing::Standard::StringField (readonly)

The name of the supplier or merchant.



68
69
70
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 68

def supplier_name
  @supplier_name
end

#supplier_payment_detailsArray<Mindee::Parsing::Standard::PaymentDetailsField> (readonly)

List of payment details associated to the supplier.



71
72
73
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 71

def supplier_payment_details
  @supplier_payment_details
end

#supplier_phone_numberMindee::Parsing::Standard::StringField (readonly)

The phone number of the supplier or merchant.



74
75
76
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 74

def supplier_phone_number
  @supplier_phone_number
end

#supplier_websiteMindee::Parsing::Standard::StringField (readonly)

The website URL of the supplier or merchant.



77
78
79
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 77

def supplier_website
  @supplier_website
end

#taxesMindee::Parsing::Standard::Taxes (readonly)

List of tax line details.



80
81
82
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 80

def taxes
  @taxes
end

#total_amountMindee::Parsing::Standard::AmountField (readonly)

The total amount paid: includes taxes, tips, fees, and other charges.



83
84
85
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 83

def total_amount
  @total_amount
end

#total_netMindee::Parsing::Standard::AmountField (readonly)

The net amount paid: does not include taxes, fees, and discounts.



86
87
88
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 86

def total_net
  @total_net
end

#total_taxMindee::Parsing::Standard::AmountField (readonly)

The total tax: includes all the taxes paid for this invoice.



89
90
91
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 89

def total_tax
  @total_tax
end

Instance Method Details

#to_sString

Returns:

  • (String)


139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/mindee/product/invoice/invoice_v4_document.rb', line 139

def to_s
  reference_numbers = @reference_numbers.join("\n #{' ' * 19}")
  supplier_payment_details = @supplier_payment_details.join("\n #{' ' * 26}")
  supplier_company_registrations = @supplier_company_registrations.join("\n #{' ' * 32}")
  customer_company_registrations = @customer_company_registrations.join("\n #{' ' * 32}")
  line_items = line_items_to_s
  out_str = String.new
  out_str << "\n:Locale: #{@locale}".rstrip
  out_str << "\n:Invoice Number: #{@invoice_number}".rstrip
  out_str << "\n:Purchase Order Number: #{@po_number}".rstrip
  out_str << "\n:Reference Numbers: #{reference_numbers}".rstrip
  out_str << "\n:Purchase Date: #{@date}".rstrip
  out_str << "\n:Due Date: #{@due_date}".rstrip
  out_str << "\n:Payment Date: #{@payment_date}".rstrip
  out_str << "\n:Total Net: #{@total_net}".rstrip
  out_str << "\n:Total Amount: #{@total_amount}".rstrip
  out_str << "\n:Total Tax: #{@total_tax}".rstrip
  out_str << "\n:Taxes:#{@taxes}".rstrip
  out_str << "\n:Supplier Payment Details: #{supplier_payment_details}".rstrip
  out_str << "\n:Supplier Name: #{@supplier_name}".rstrip
  out_str << "\n:Supplier Company Registrations: #{supplier_company_registrations}".rstrip
  out_str << "\n:Supplier Address: #{@supplier_address}".rstrip
  out_str << "\n:Supplier Phone Number: #{@supplier_phone_number}".rstrip
  out_str << "\n:Supplier Website: #{@supplier_website}".rstrip
  out_str << "\n:Supplier Email: #{@supplier_email}".rstrip
  out_str << "\n:Customer Name: #{@customer_name}".rstrip
  out_str << "\n:Customer Company Registrations: #{customer_company_registrations}".rstrip
  out_str << "\n:Customer Address: #{@customer_address}".rstrip
  out_str << "\n:Customer ID: #{@customer_id}".rstrip
  out_str << "\n:Shipping Address: #{@shipping_address}".rstrip
  out_str << "\n:Billing Address: #{@billing_address}".rstrip
  out_str << "\n:Document Type: #{@document_type}".rstrip
  out_str << "\n:Line Items:"
  out_str << line_items
  out_str[1..].to_s
end