I have already done that but it generates the following errors;
1. You must apply this receipt to at least one document when the applied amount is zero.
2. The net balance is Zero for this document.
What am looking for is anyone who might have a macro that has been cleaned.
Private Function AddReceipts() As Boolean
Dim iErrors As Integer
Dim iWarnings As Integer
Dim iOrderCount As Long
Dim iTotalCount As Long
Dim bErrorHere As Boolean
Dim iLineCount As Long
Dim iReceiptCount As Long
Dim nFileTotal As Double
Dim sCust As String
Dim sInvoice As String
Dim sCredit As String
Dim sSQL As String
Dim sLine As String
Dim recOrder As New Recordset
On Error GoTo badstuff
'Dim tsin As TextStream
'Dim tsLine As String
'Dim tsRec() As String
'Rec_Num Transaction_ID AVS_Street_Match AVS_Zip_Match USD Amount Authcode Billing_Address Billing_City Billing_Company_Name Billing_Country Billing_First_Name Billing_Last_Name Billing_State Billing_Zip Customer_Code Expires Invoice_Number PayPal_Fees Purchase_Order Response_Msg Result_Code Settled_Date Tax_Amount Tender_Type Time Transaction_State Type User
'1 VLFA9FCEE4E6 Y Y USD 1,052.00 188780 77 Thomas Johnson Drive, Suite Frederick Capitol Vein and Laser US Paul McNeil, MD MD 21702 MDSU 14-Jan IN00059450 0 CHA09122013 Approved 0 9/13/13 23:47 0 American Express 9/13/13 10:26 8 Sale tglenn
'2 VLCA9FF1CEBC Y Y USD 27.47 28926 5500 Armstrong Road Battle Creek VAMC Battle Creek US MI 49037 VABC 13-Nov IN00059670 0 515-P45187AM Approved 0 9/16/13 23:32 0 Visa 9/16/13 7:54 8 Sale tglenn
'3 VLCA9FF596B6 Y Y USD 102.8 159183 PO Box 12027 Jackson US Dwight Reppa WY 83002 PLOW 15-Sep IN00059946 0 REPPA Approved 0 9/16/13 23:32 0 American Express 9/16/13 12:46 8 Sale tglenn
Dim sSchemaFile As String
Dim sTempFile As String
Dim tsSchema As TextStream
Dim tsTemp As TextStream
Dim tsIn As TextStream
ArReceiptdetail1.Insert
ArReceiptheader.Insert
If recOrder.Fields(Amount) <> ArInvoiceRead.Fields("amtduehc") Then
LogWrite "Transaction ID " & recOrder.Fields(Transaction_ID) & ", customer " & sCust & ", invoice " & sInvoice & ", amount " & Format(recOrder.Fields(Amount), "0.00") & " paid on balance of " & ArInvoiceRead.Fields("amtduehc")
End If
End If
End If
Else
sCust = recOrder.Fields(Customer_Code)
ArCustomerRead.Browse "IDCUST = """ & sCust & """", True
If ArCustomerRead.Fetch Then
ArReceiptheader.RecordGenerate False
ArReceiptheader.Fields("IDCUST").Value = sCust
ArReceiptheader.Fields("IDRMIT").Value = recOrder.Fields(Transaction_ID)
ArReceiptdetail1.Cancel
ArReceiptheader.Process
ArReceiptheader.Fields("AMTRMIT").Value = recOrder.Fields(Amount)
ArReceiptdetail4.Fields("IDCUST").Value = sCust
ArReceiptdetail4.Fields("AMTRMIT").Value = recOrder.Fields(Amount)
ArReceiptdetail4.Fields("PROTYPE").PutWithoutVerification ("2") ' Process Type
ArReceiptdetail4.Process
ArReceiptheader.Insert
LogWrite "Warning: Transaction ID " & recOrder.Fields(Transaction_ID) & ", customer " & sCust & ", invoice " & sInvoice & " was not found, amount " & Format(recOrder.Fields(Amount), "0.00") & " applied to open invoices"
iWarnings = iWarnings + 1
Else
LogWrite "Error: Transaction ID " & recOrder.Fields(Transaction_ID) & ", unable to determine customer or invoice from customer code " & sCust & ", invoice " & recOrder.Fields(Invoice_Number) & ", amount " & Format(recOrder.Fields(Amount), "0.00")
iErrors = iErrors + 1
End If
End If ' Found an invoice
End If ' Is a Payment
End If 'Not null records
recOrder.MoveNext
Loop
LogWrite "", True
LogWrite iReceiptCount & " transactions in the file", True
LogWrite Format(nFileTotal, "0.00") & " total amount in the file", True
LogWrite ArReceiptbatch.Fields("CNTENTER") & " receipts added", True
LogWrite Format(ArReceiptbatch.Fields("AMTENTER"), "0.00") & " total receipt amount", True
LogWrite ArRefundbatch.Fields("ENTRYCNT") & " refunds added", True
LogWrite Format(ArRefundbatch.Fields("ENTRYTOT"), "0.00") & " total refund amount", True
LogWrite iWarnings & " warnings ", True
LogWrite iErrors & " errors", True
Exit Function
badstuff:
iErrors = iErrors + 1
Dim lCount As Long
Dim lIndex As Long
lCount = Errors.Count
LogWrite "Error input line number " & iLineCount, True
If lCount = 0 Then
LogWrite Err.Description, True
Else
For lIndex = 0 To lCount - 1
LogWrite Errors.Item(lIndex), True
Next
Errors.Clear
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.