Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to manually input taxes in AP

Status
Not open for further replies.

Shacktar

Programmer
Sep 13, 2005
10
CA
Hello all,

I'm writing a VB.Net application using the COMAPI to import AP invoices into Accpac. I am trying to manually input GST amounts but Accpac seems to over-write whatever it is I'm putting in. I need to calculate the taxes seperately since not all of the invoice amount is taxable. So, is there a way (some switch in AP0021 or AP0022) that turns off Accpac's tax calculation? Any advice would be good.

thanks,
Shacktar
 
Change SWCALCTX to 0 in AP0021.
0 = Enter, 1 = Calculate, 2 = Distribute.
Record a macro while you enter taxes manually to see how it distributes the taxes.
 
Thanks for your reply. I have already recorded a Macro when I inputted taxes manually and for some reason, the taxes I put in are still over-written.

Here is my code if that helps:
Dim importScreen As New Importing
Dim import_number As String = NumbersComboBox.Text
Dim Session As New AccpacSession
Session.Init("", "AS", "AS1000", "52A")
Session.Open("USER", "PASSWORD", "DATABASE", System.DateTime.Today, 0, "")

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
mDBLinkCmpRW = Session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
mDBLinkSysRW = Session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_SYSTEM, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

Dim APINVOICE1batch As AccpacCOMAPI.AccpacView
Dim APINVOICE1batchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0020", APINVOICE1batch)
APINVOICE1batchFields = APINVOICE1batch.Fields

Dim APINVOICE1header As AccpacCOMAPI.AccpacView
Dim APINVOICE1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0021", APINVOICE1header)
APINVOICE1headerFields = APINVOICE1header.Fields

Dim APINVOICE1detail1 As AccpacCOMAPI.AccpacView
Dim APINVOICE1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0022", APINVOICE1detail1)
APINVOICE1detail1Fields = APINVOICE1detail1.Fields

Dim APINVOICE1detail2 As AccpacCOMAPI.AccpacView
Dim APINVOICE1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0023", APINVOICE1detail2)
APINVOICE1detail2Fields = APINVOICE1detail2.Fields

Dim batchArray(0) As AccpacView
batchArray(0) = APINVOICE1header
APINVOICE1batch.Compose(batchArray)

Dim headerArray(2) As AccpacView
headerArray(0) = APINVOICE1batch
headerArray(1) = APINVOICE1detail1
headerArray(2) = APINVOICE1detail2
APINVOICE1header.Compose(headerArray)

Dim detail1Array(1) As AccpacView
detail1Array(0) = APINVOICE1header
detail1Array(1) = APINVOICE1batch
APINVOICE1detail1.Compose(detail1Array)

Dim detail2Array(0) As AccpacView
detail2Array(0) = APINVOICE1header
APINVOICE1detail2.Compose(detail2Array)

APINVOICE1batch.Browse("((BTCHSTTS = 1) OR (BTCHSTTS = 7))", 1)
APINVOICE1detail2.Init()
APINVOICE1batchFields.FieldByName("CNTBTCH").PutWithoutVerification("0") ' Batch Number
APINVOICE1batch.Init()
APINVOICE1headerFields.FieldByName("CNTITEM").PutWithoutVerification("0") ' Entry Number
APINVOICE1header.Init()
APINVOICE1detail1.Init()
APINVOICE1detail2.Init()
If (StrComp(database, "Gas", CompareMethod.Text) = 0) Then
APINVOICE1batchFields.FieldByName("BTCHDESC").PutWithoutVerification("Enbridge IPR") ' Description
Else
APINVOICE1batchFields.FieldByName("BTCHDESC").PutWithoutVerification("Hydro Ottawa IPR") ' Description
End If
APINVOICE1batchFields.FieldByName("BTCHTYPE").PutWithoutVerification(2)
APINVOICE1batchFields.FieldByName("SRCEAPPL").PutWithoutVerification("UP")
APINVOICE1batch.Update()
If (StrComp(database, "Gas", CompareMethod.Text) = 0) Then
APINVOICE1headerFields.FieldByName("IDVEND").Value = "029" ' Vendor Number
Else
APINVOICE1headerFields.FieldByName("IDVEND").Value = "098"
End If

Dim reImportNumber As Integer = 1
tryAgain:
Try
APINVOICE1headerFields.FieldByName("IDINVC").Value = database & " " & getInvId() & "-" & import_number & "-" & reImportNumber ' Document Number
Catch ex As Exception
'document number is not unique, try a new re-import number
reImportNumber = reImportNumber + 1
GoTo tryAgain
End Try

APINVOICE1headerFields.FieldByName("SWCALCTX").PutWithoutVerification("0")
APINVOICE1headerFields.FieldByName("AMTGROSTOT").Value = getTotal() & "" ' Document Total Including Tax

APINVOICE1detail1.Init()
Dim data_set As New DataSet("To Import")
Dim adapter As New SqlDataAdapter("Select Distinct Site From " & database & "Invoice Where DateStamp = '" & switch(DateTextBox.Text.TrimEnd) & "' and Imported=" & Val(NumbersComboBox.Text) & " Order By Site Asc", connection)
adapter.Fill(data_set)

importScreen.Show()
importScreen.ImportProgressBar.Minimum = 0
importScreen.ImportProgressBar.Maximum = data_set.Tables(0).Rows.Count
importScreen.Refresh()

Dim row As DataRow
Dim first As Boolean = True
Dim loops As Integer = 0
For Each row In data_set.Tables(0).Rows
loops = loops + 1
If Not first Then
APINVOICE1detail1.Read()
Else
APINVOICE1detail1.Init()
End If

If Not first Then
APINVOICE1detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("-" & (loops - 1))
End If

If (StrComp(database, "Gas", CompareMethod.Text) = 0) Then
APINVOICE1detail1Fields.FieldByName("IDDIST").Value = "HF" & row(0) ' Distribution Code
Else
APINVOICE1detail1Fields.FieldByName("IDDIST").Value = "EL" & row(0) ' Distribution Code
End If
APINVOICE1detail1Fields.FieldByName("AMTDIST").Value = getTotal(row(0)) & "" ' Distributed Amount

APINVOICE1detail1Fields.FieldByName("BASETAX1").Value = "" & get_tax_base(row(0)) ' Base Tax 1
'MsgBox(get_tax_base(row(0)))
APINVOICE1detail1Fields.FieldByName("AMTTAX1").Value = "" & (get_total_tax(row(0)))

APINVOICE1detail1.Insert()

set_accpac_values(switch(DateTextBox.Text.TrimEnd), database, row(0), APINVOICE1batchFields.FieldByName("CNTBTCH").Value, APINVOICE1detail1Fields.FieldByName("CNTLINE").Value * (-1), import_number)
APINVOICE1detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("-" & loops)
first = False

importScreen.ImportProgressBar.Value = importScreen.ImportProgressBar.Value + 1
importScreen.Refresh()
Next

APINVOICE1detail1.Read()

APINVOICE1headerFields.FieldByName("BASETAX1").Value = get_tax_base() ' Tax Base 1
APINVOICE1headerFields.FieldByName("AMTTAX1").Value = get_total_tax() ' Tax Amount 1
APINVOICE1headerFields.FieldByName("INVCDESC").PutWithoutVerification("#" & APINVOICE1batchFields.FieldByName("CNTBTCH").Value) ' Invoice Description ' Invoice Description
APINVOICE1headerFields.FieldByName("AMTDISTSET").PutWithoutVerification("" & getTotal()) ' Distribution Set Amount

APINVOICE1batchFields.FieldByName("CNTBTCH").Value) ' Invoice Description

APINVOICE1header.Process()
Try
APINVOICE1header.Insert()
Catch ex As Exception
MsgBox(Session.Errors.Item(0).ToString)
Exit Sub
End Try


Session.Close()
importScreen.Dispose()
MessageBox.Show("Data Re-Imported", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top