Create Credit Card Refund

Top  Previous  Next

[Visual Basic] The following example demonstrates how to create and save a new Credit Card Refund document. (This example uses the CreditCardWebService.)

 

' ----------------------------------------

' Step 1: Create an instance of the web service.

' ----------------------------------------

Dim creditCardRefundWs As New WebServices.CreditCardWebService("http://localhost/objacctwebservices/")

 

' ----------------------------------------

' Step 2: Set the LoginKey. (Use Login.GetLoginKey to

' login to a specific company and generate a LoginKey.)

' For this example, the LoginKey is being stored in a 

' public variable called PublicLoginKey.

' ----------------------------------------

StdLib.PopulateObjAcctSoapHeader(creditCardRefundWs, PublicLoginKey)

 

' ----------------------------------------

' Step 3: Create and populate a DataSet with the new document.

' For this example, we're creating a new Credit Card Refund document,

' so we will use the ObjAcct.WebServices.DataSets.CreditCardDataSet.

' ----------------------------------------

Dim creditCardRefundDs As DataSet = New WebServices.DataSets.CreditCardDataSet()

 

' -------------------

' Document Header.

' -------------------

Dim headerDr As DataRow = creditCardRefundDs.Tables("Header").NewRow

 

headerDr("RowID") = ""

headerDr("AccountRowID") = "892.0"

headerDr("ClassRowID") = "7.0"

headerDr("DocDate") = Today.ToShortDateString

headerDr("DocID") = "CR5000"

headerDr("DocAmount") = 1225

headerDr("EnteredDate") = Today.ToShortDateString

headerDr("EntityRowID") = "5.0"

headerDr("EntityType") = "Vendor"

headerDr("JournalDocTypeRowID") = StdLib.DOCUMENT_Type_CREDITCARD_REFUND

 

' Add the row to the Header table.

creditCardRefundDs.Tables("Header").Rows.Add(headerDr)

 

' -------------------

' Transaction.

' -------------------

Dim transDr As DataRow

 

transDr = creditCardRefundDs.Tables("Transaction").NewRow

 

transDr("RowID") = ""

transDr("AccountRowID") = "27.0"

transDr("ClassRowID") = "20.0"

transDr("Description") = "Uncategorized Expenses"

transDr("DisplayOrder") = 1

transDr("TransactionAmount") = 1125

 

' Add the row to the Transaction table.

creditCardRefundDs.Tables("Transaction").Rows.Add(transDr)

 

transDr = creditCardRefundDs.Tables("Transaction").NewRow

 

transDr("RowID") = ""

transDr("AccountRowID") = "11.0"

transDr("ClassRowID") = "20.0"

transDr("Description") = "Food and Beverage (Refund)"

transDr("DisplayOrder") = 2

transDr("TransactionAmount") = 100

 

' Add the row to the Transaction table.

creditCardRefundDs.Tables("Transaction").Rows.Add(transDr)

 

' ----------------------------------------

' Step 4: Save the document.

' ----------------------------------------

Dim returnDs As DataSet = creditCardRefundWs.SaveDocument(creditCardRefundDs)

 

' Check for errors.

If StdLib.GetErrorNumber(returnDs) < 0 Then

       MsgBox(StdLib.GetErrorAsString(returnDs))

End If