def save_manual_journal(manual_journal)
      request_xml = manual_journal.to_xml
      response_xml = nil
      create_or_save = nil

      if manual_journal.manual_journal_id.nil?
        # Create new manual journal record.
        response_xml = http_put(@client, "#{@xero_url}/ManualJournals", request_xml, {})
        create_or_save = :create
      else
        # Update existing manual journal record.
        response_xml = http_post(@client, "#{@xero_url}/ManualJournals", request_xml, {})
        create_or_save = :save
      end

      response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => "#{create_or_save == :create ? 'PUT' : 'POST'}/ManualJournals"})

      # Xero returns manual journals inside an <ManualJournals> tag, even though there's only ever
      # one for this request
      response.response_item = response.manual_journals.first

      manual_journal.manual_journal_id = response.manual_journal.manual_journal_id if response.success? && response.manual_journal && response.manual_journal.manual_journal_id

      response
    end
def save_manual_journal(manual_journal)
      request_xml = manual_journal.to_xml
      response_xml = nil
      create_or_save = nil

      if manual_journal.manual_journal_id.nil?
        # Create new manual journal record.
        response_xml = http_put(@client, "#{@xero_url}/ManualJournals", request_xml, {})
        create_or_save = :create
      else
        # Update existing manual journal record.
        response_xml = http_post(@client, "#{@xero_url}/ManualJournals", request_xml, {})
        create_or_save = :save
      end

      response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => "#{create_or_save == :create ? 'PUT' : 'POST'}/ManualJournals"})

      # Xero returns manual journals inside an <ManualJournals> tag, even though there's only ever
      # one for this request
      response.response_item = response.manual_journals.first

      manual_journal.manual_journal_id = response.manual_journal.manual_journal_id if response.success? && response.manual_journal && response.manual_journal.manual_journal_id

      response
    end
Create or update a manual journal record based on if it has an manual_journal_id.