JournalLine model missing required field, LineAmount
HashNotAdam opened this issue · 1 comments
HashNotAdam commented
XeroRuby::Accounting::JournalLine does not have a line_amount
attribute but this is an API required field.
Extending the class like this solved the issue for me:
# frozen_string_literal: true
module EA
module Xero
module Models
class JournalLine < XeroRuby::Accounting::JournalLine
def self.attribute_map
super.merge(line_amount: :LineAmount)
end
def self.openapi_types
super.merge(line_amount: :BigDecimal)
end
attr_accessor :line_amount
def initialize(attributes = {})
super(attributes)
self.line_amount ||= attributes[:line_amount]
end
def ==(other)
return true if equal?(other)
return false if self.class != other.class
self.class.attribute_map.all? do |attr, _|
public_send(attr).eql?(other.public_send(attr))
end
end
def hash
self.class.attribute_map.map { |attr, _| public_send(attr) }.hash
end
end
end
end
end
pumpkinball commented
Hi @HashNotAdam thanks for raising this query.
Can you confirm if you are looking at 'Journal' or 'Manual Journal'.
For Manual Journal, LineAmount is required see https://developer.xero.com/documentation/api/accounting/manualjournals/
For Journals, it uses NetAmount, GrossAmount, TaxAmount instead. Please see https://developer.xero.com/documentation/api/accounting/journals.
Reopen if that doesn't answer your question. Thanks