def create_credit_note(credit_note)
      request_xml = credit_note.to_xml
      response_xml = http_put(@client, "#{@xero_url}/CreditNotes", request_xml)
      response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => 'PUT/credit_note'})

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

      if response.success? && response.credit_note && response.credit_note.credit_note_id
        credit_note.credit_note_id = response.credit_note.credit_note_id
      end

      response
    end
def create_credit_note(credit_note)
      request_xml = credit_note.to_xml
      response_xml = http_put(@client, "#{@xero_url}/CreditNotes", request_xml)
      response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => 'PUT/credit_note'})

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

      if response.success? && response.credit_note && response.credit_note.credit_note_id
        credit_note.credit_note_id = response.credit_note.credit_note_id
      end

      response
    end
Creates an credit_note in Xero based on an credit_note object.

 CreditNote and line item totals are calculated automatically.

 Usage :

    credit_note = XeroGateway::CreditNote.new({
      :credit_note_type => "ACCREC",
      :due_date => 1.month.from_now,
      :credit_note_number => "YOUR CREDIT_NOTE NUMBER",
      :reference => "YOUR REFERENCE (NOT NECESSARILY UNIQUE!)",
      :line_amount_types => "Inclusive"
    })
    credit_note.contact = XeroGateway::Contact.new(:name => "THE NAME OF THE CONTACT")
    credit_note.contact.phone.number = "12345"
    credit_note.contact.address.line_1 = "LINE 1 OF THE ADDRESS"
    credit_note.line_items << XeroGateway::LineItem.new(
      :description => "THE DESCRIPTION OF THE LINE ITEM",
      :unit_amount => 100,
      :tax_amount => 12.5,
      :tracking_category => "THE TRACKING CATEGORY FOR THE LINE ITEM",
      :tracking_option => "THE TRACKING OPTION FOR THE LINE ITEM"
    )

    create_credit_note(credit_note)