Class: StorecoveApi::Invoice
- Inherits:
-
Object
- Object
- StorecoveApi::Invoice
- Defined in:
- lib/storecove/models/invoice.rb
Overview
The invoice to send
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#accounting_cost_code ⇒ Object
Returns the value of attribute accounting_cost_code.
-
#accounting_customer_party ⇒ Object
The receiving party.
-
#amount_including_vat ⇒ Object
amountIncludingVat is important because of rounding differences.
-
#billing_reference ⇒ Object
A reference to a commercial invoice or corrective invoice of which the current invoice is a correction.
-
#buyer_reference ⇒ Object
A reference provided by the buyer used for internal routing of the document.
-
#contract_document_reference ⇒ Object
A reference to a contract or framework agreement that this invoice relates to.
-
#document_currency_code ⇒ Object
The documentCurrencyCode is the currency for the entire invoice.
-
#due_date ⇒ Object
Format: yyyy-mm-dd.
-
#invoice_lines ⇒ Object
An array of invoice lines.
-
#invoice_number ⇒ Object
The invoice number you assigned to the invoice.
-
#invoice_period ⇒ Object
The period (or specific date) to which the invoice applies.
-
#invoice_type ⇒ Object
Use 380 for a regular invoice, 384 for a Corrective invoice.
-
#issue_date ⇒ Object
Format: yyyy-mm-dd.
-
#order_reference ⇒ Object
A reference to an order for this invoice.
-
#payment_means_code ⇒ Object
Leave empty.
-
#payment_means_iban ⇒ Object
The IBAN the amount payable should be transferred to.
-
#payment_means_payment_id ⇒ Object
The payment id that you will use to match the payment against the invoice.
-
#project_reference ⇒ Object
Information about the project this invoice relates to.
-
#tax_point_date ⇒ Object
The tax date is the date on which the supply of goods or of services was made or completed or the date on which the payment on account was made insofar as that date can be determined and differs from the date of the issue of the invoice.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Invoice
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Invoice
Initializes the object
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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/storecove/models/invoice.rb', line 147 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'documentCurrencyCode') self.document_currency_code = attributes[:'documentCurrencyCode'] end if attributes.has_key?(:'invoiceNumber') self.invoice_number = attributes[:'invoiceNumber'] end if attributes.has_key?(:'issueDate') self.issue_date = attributes[:'issueDate'] end if attributes.has_key?(:'accountingCustomerParty') self.accounting_customer_party = attributes[:'accountingCustomerParty'] end if attributes.has_key?(:'invoiceLines') if (value = attributes[:'invoiceLines']).is_a?(Array) self.invoice_lines = value end end if attributes.has_key?(:'accountingCostCode') self.accounting_cost_code = attributes[:'accountingCostCode'] end if attributes.has_key?(:'dueDate') self.due_date = attributes[:'dueDate'] end if attributes.has_key?(:'invoiceType') self.invoice_type = attributes[:'invoiceType'] else self.invoice_type = "380" end if attributes.has_key?(:'taxPointDate') self.tax_point_date = attributes[:'taxPointDate'] end if attributes.has_key?(:'buyerReference') self.buyer_reference = attributes[:'buyerReference'] end if attributes.has_key?(:'invoicePeriod') self.invoice_period = attributes[:'invoicePeriod'] end if attributes.has_key?(:'orderReference') self.order_reference = attributes[:'orderReference'] end if attributes.has_key?(:'billingReference') self.billing_reference = attributes[:'billingReference'] end if attributes.has_key?(:'contractDocumentReference') self.contract_document_reference = attributes[:'contractDocumentReference'] end if attributes.has_key?(:'projectReference') self.project_reference = attributes[:'projectReference'] end if attributes.has_key?(:'paymentMeansIban') self.payment_means_iban = attributes[:'paymentMeansIban'] end if attributes.has_key?(:'paymentMeansCode') self.payment_means_code = attributes[:'paymentMeansCode'] end if attributes.has_key?(:'paymentMeansPaymentId') self.payment_means_payment_id = attributes[:'paymentMeansPaymentId'] end if attributes.has_key?(:'amountIncludingVat') self.amount_including_vat = attributes[:'amountIncludingVat'] end end |
Instance Attribute Details
#accounting_cost_code ⇒ Object
Returns the value of attribute accounting_cost_code.
32 33 34 |
# File 'lib/storecove/models/invoice.rb', line 32 def accounting_cost_code @accounting_cost_code end |
#accounting_customer_party ⇒ Object
The receiving party
27 28 29 |
# File 'lib/storecove/models/invoice.rb', line 27 def accounting_customer_party @accounting_customer_party end |
#amount_including_vat ⇒ Object
amountIncludingVat is important because of rounding differences. In many invoices, the sum of the line item amounts excluding VAT and the VAT amounts is not equal to first summing the line items without VAT, and then applying VAT. The difference is automatically calculated and included in the electronic invoice, so the receiving accounting package can process the electronic invoice without problems.
71 72 73 |
# File 'lib/storecove/models/invoice.rb', line 71 def amount_including_vat @amount_including_vat end |
#billing_reference ⇒ Object
A reference to a commercial invoice or corrective invoice of which the current invoice is a correction.
53 54 55 |
# File 'lib/storecove/models/invoice.rb', line 53 def billing_reference @billing_reference end |
#buyer_reference ⇒ Object
A reference provided by the buyer used for internal routing of the document.
44 45 46 |
# File 'lib/storecove/models/invoice.rb', line 44 def buyer_reference @buyer_reference end |
#contract_document_reference ⇒ Object
A reference to a contract or framework agreement that this invoice relates to.
56 57 58 |
# File 'lib/storecove/models/invoice.rb', line 56 def contract_document_reference @contract_document_reference end |
#document_currency_code ⇒ Object
The documentCurrencyCode is the currency for the entire invoice. We currently do not support invoices in multiple currencies.
18 19 20 |
# File 'lib/storecove/models/invoice.rb', line 18 def document_currency_code @document_currency_code end |
#due_date ⇒ Object
Format: yyyy-mm-dd.
35 36 37 |
# File 'lib/storecove/models/invoice.rb', line 35 def due_date @due_date end |
#invoice_lines ⇒ Object
An array of invoice lines.
30 31 32 |
# File 'lib/storecove/models/invoice.rb', line 30 def invoice_lines @invoice_lines end |
#invoice_number ⇒ Object
The invoice number you assigned to the invoice. The invoiceNumber should be unique for the supplierId and year of the issueDate. This means invoice numbers can be reused in different years, as is customary in some countries.
21 22 23 |
# File 'lib/storecove/models/invoice.rb', line 21 def invoice_number @invoice_number end |
#invoice_period ⇒ Object
The period (or specific date) to which the invoice applies. Format: yyyy-mm-dd - yyyy-mm-dd.
47 48 49 |
# File 'lib/storecove/models/invoice.rb', line 47 def invoice_period @invoice_period end |
#invoice_type ⇒ Object
Use 380 for a regular invoice, 384 for a Corrective invoice.
38 39 40 |
# File 'lib/storecove/models/invoice.rb', line 38 def invoice_type @invoice_type end |
#issue_date ⇒ Object
Format: yyyy-mm-dd.
24 25 26 |
# File 'lib/storecove/models/invoice.rb', line 24 def issue_date @issue_date end |
#order_reference ⇒ Object
A reference to an order for this invoice.
50 51 52 |
# File 'lib/storecove/models/invoice.rb', line 50 def order_reference @order_reference end |
#payment_means_code ⇒ Object
Leave empty. Defaults to 31 if an IBAN is provided, otherwise defaults to 1. But leave empty.
65 66 67 |
# File 'lib/storecove/models/invoice.rb', line 65 def payment_means_code @payment_means_code end |
#payment_means_iban ⇒ Object
The IBAN the amount payable should be transferred to
62 63 64 |
# File 'lib/storecove/models/invoice.rb', line 62 def payment_means_iban @payment_means_iban end |
#payment_means_payment_id ⇒ Object
The payment id that you will use to match the payment against the invoice.
68 69 70 |
# File 'lib/storecove/models/invoice.rb', line 68 def payment_means_payment_id @payment_means_payment_id end |
#project_reference ⇒ Object
Information about the project this invoice relates to.
59 60 61 |
# File 'lib/storecove/models/invoice.rb', line 59 def project_reference @project_reference end |
#tax_point_date ⇒ Object
The tax date is the date on which the supply of goods or of services was made or completed or the date on which the payment on account was made insofar as that date can be determined and differs from the date of the issue of the invoice. EU 2006-112 Article 226 Point 7. Note: For the Dutch TAX authorities the tac date should be the same as the issue date.
41 42 43 |
# File 'lib/storecove/models/invoice.rb', line 41 def tax_point_date @tax_point_date end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/storecove/models/invoice.rb', line 96 def self.attribute_map { :'document_currency_code' => :'documentCurrencyCode', :'invoice_number' => :'invoiceNumber', :'issue_date' => :'issueDate', :'accounting_customer_party' => :'accountingCustomerParty', :'invoice_lines' => :'invoiceLines', :'accounting_cost_code' => :'accountingCostCode', :'due_date' => :'dueDate', :'invoice_type' => :'invoiceType', :'tax_point_date' => :'taxPointDate', :'buyer_reference' => :'buyerReference', :'invoice_period' => :'invoicePeriod', :'order_reference' => :'orderReference', :'billing_reference' => :'billingReference', :'contract_document_reference' => :'contractDocumentReference', :'project_reference' => :'projectReference', :'payment_means_iban' => :'paymentMeansIban', :'payment_means_code' => :'paymentMeansCode', :'payment_means_payment_id' => :'paymentMeansPaymentId', :'amount_including_vat' => :'amountIncludingVat' } end |
.swagger_types ⇒ Object
Attribute type mapping.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/storecove/models/invoice.rb', line 121 def self.swagger_types { :'document_currency_code' => :'CurrencyCode', :'invoice_number' => :'String', :'issue_date' => :'String', :'accounting_customer_party' => :'AccountingCustomerParty', :'invoice_lines' => :'Array<InvoiceLine>', :'accounting_cost_code' => :'AccountingCostCode', :'due_date' => :'String', :'invoice_type' => :'String', :'tax_point_date' => :'String', :'buyer_reference' => :'String', :'invoice_period' => :'String', :'order_reference' => :'String', :'billing_reference' => :'String', :'contract_document_reference' => :'String', :'project_reference' => :'String', :'payment_means_iban' => :'String', :'payment_means_code' => :'String', :'payment_means_payment_id' => :'String', :'amount_including_vat' => :'Float' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/storecove/models/invoice.rb', line 378 def ==(o) return true if self.equal?(o) self.class == o.class && document_currency_code == o.document_currency_code && invoice_number == o.invoice_number && issue_date == o.issue_date && accounting_customer_party == o.accounting_customer_party && invoice_lines == o.invoice_lines && accounting_cost_code == o.accounting_cost_code && due_date == o.due_date && invoice_type == o.invoice_type && tax_point_date == o.tax_point_date && buyer_reference == o.buyer_reference && invoice_period == o.invoice_period && order_reference == o.order_reference && billing_reference == o.billing_reference && contract_document_reference == o.contract_document_reference && project_reference == o.project_reference && payment_means_iban == o.payment_means_iban && payment_means_code == o.payment_means_code && payment_means_payment_id == o.payment_means_payment_id && amount_including_vat == o.amount_including_vat end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/storecove/models/invoice.rb', line 438 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = StorecoveApi.const_get(type).new temp_model.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/storecove/models/invoice.rb', line 504 def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/storecove/models/invoice.rb', line 417 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
404 405 406 |
# File 'lib/storecove/models/invoice.rb', line 404 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
410 411 412 |
# File 'lib/storecove/models/invoice.rb', line 410 def hash [document_currency_code, invoice_number, issue_date, accounting_customer_party, invoice_lines, accounting_cost_code, due_date, invoice_type, tax_point_date, buyer_reference, invoice_period, order_reference, billing_reference, contract_document_reference, project_reference, payment_means_iban, payment_means_code, payment_means_payment_id, amount_including_vat].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/storecove/models/invoice.rb', line 237 def list_invalid_properties invalid_properties = Array.new if @document_currency_code.nil? invalid_properties.push("invalid value for 'document_currency_code', document_currency_code cannot be nil.") end if @invoice_number.nil? invalid_properties.push("invalid value for 'invoice_number', invoice_number cannot be nil.") end if @invoice_number.to_s.length < 1 invalid_properties.push("invalid value for 'invoice_number', the character length must be great than or equal to 1.") end if @issue_date.nil? invalid_properties.push("invalid value for 'issue_date', issue_date cannot be nil.") end if @issue_date !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) invalid_properties.push("invalid value for 'issue_date', must conform to the pattern /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.") end if @accounting_customer_party.nil? invalid_properties.push("invalid value for 'accounting_customer_party', accounting_customer_party cannot be nil.") end if @invoice_lines.nil? invalid_properties.push("invalid value for 'invoice_lines', invoice_lines cannot be nil.") end if !@due_date.nil? && @due_date !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) invalid_properties.push("invalid value for 'due_date', must conform to the pattern /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.") end if !@tax_point_date.nil? && @tax_point_date !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) invalid_properties.push("invalid value for 'tax_point_date', must conform to the pattern /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.") end if !@invoice_period.nil? && @invoice_period !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2} - [0-9]{4}-[0-9]{2}-[0-9]{2}$/) invalid_properties.push("invalid value for 'invoice_period', must conform to the pattern /^[0-9]{4}-[0-9]{2}-[0-9]{2} - [0-9]{4}-[0-9]{2}-[0-9]{2}$/.") end if @amount_including_vat.nil? invalid_properties.push("invalid value for 'amount_including_vat', amount_including_vat cannot be nil.") end return invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
484 485 486 |
# File 'lib/storecove/models/invoice.rb', line 484 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
490 491 492 493 494 495 496 497 498 |
# File 'lib/storecove/models/invoice.rb', line 490 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
478 479 480 |
# File 'lib/storecove/models/invoice.rb', line 478 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/storecove/models/invoice.rb', line 288 def valid? return false if @document_currency_code.nil? return false if @invoice_number.nil? return false if @invoice_number.to_s.length < 1 return false if @issue_date.nil? return false if @issue_date !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) return false if @accounting_customer_party.nil? return false if @invoice_lines.nil? return false if !@due_date.nil? && @due_date !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) invoice_type_validator = EnumAttributeValidator.new('String', ["380", "384"]) return false unless invoice_type_validator.valid?(@invoice_type) return false if !@tax_point_date.nil? && @tax_point_date !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/) return false if !@invoice_period.nil? && @invoice_period !~ Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2} - [0-9]{4}-[0-9]{2}-[0-9]{2}$/) return false if @amount_including_vat.nil? return true end |