Method: Merge::Accounting::JournalEntryRequest.from_json

Defined in:
lib/merge_ruby_client/accounting/types/journal_entry_request.rb

.from_json(json_object:) ⇒ Merge::Accounting::JournalEntryRequest

Deserialize a JSON object to an instance of JournalEntryRequest

Parameters:

  • json_object (String)

Returns:



722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
# File 'lib/merge_ruby_client/accounting/types/journal_entry_request.rb', line 722

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  transaction_date = (DateTime.parse(parsed_json["transaction_date"]) unless parsed_json["transaction_date"].nil?)
  payments = parsed_json["payments"]&.map do |item|
    item = item.to_json
    Merge::Accounting::JournalEntryRequestPaymentsItem.from_json(json_object: item)
  end
  memo = parsed_json["memo"]
  currency = parsed_json["currency"]
  exchange_rate = parsed_json["exchange_rate"]
  if parsed_json["company"].nil?
    company = nil
  else
    company = parsed_json["company"].to_json
    company = Merge::Accounting::JournalEntryRequestCompany.from_json(json_object: company)
  end
  tracking_categories = parsed_json["tracking_categories"]&.map do |item|
    item = item.to_json
    Merge::Accounting::JournalEntryRequestTrackingCategoriesItem.from_json(json_object: item)
  end
  lines = parsed_json["lines"]&.map do |item|
    item = item.to_json
    Merge::Accounting::JournalLineRequest.from_json(json_object: item)
  end
  journal_number = parsed_json["journal_number"]
  posting_status = parsed_json["posting_status"]
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  new(
    transaction_date: transaction_date,
    payments: payments,
    memo: memo,
    currency: currency,
    exchange_rate: exchange_rate,
    company: company,
    tracking_categories: tracking_categories,
    lines: lines,
    journal_number: journal_number,
    posting_status: posting_status,
    integration_params: integration_params,
    linked_account_params: ,
    additional_properties: struct
  )
end