I have this csharp application where some items have 3 tax classes defined in accpac 5.5 and some items in IC 2 tax classes have been defined.
So far the integration is working FINE , but for items that have been set up 2 tax classes some issue is happening as when AP invoice have undistibuted amount appear , while there are unnessary tax is calculated.
This is because when AP invoice item has 3 detail level tax classes the assigned value will not get cleared when another AP Invoice having an item with 2 tax classes is posted, result is unnecessary tax is calculated.
I want to set APINVOICE11detail1Fields.FieldByName("TAXCLASS2").Value to zero as if it is not set in the IC item section
can't do this even APINVOICE11detail1Fields.FieldByName("TAXCLASS2").PutWithoutVerification("0")
(see the bold section in the code also )
ANY POSSIBLE SOLUTION TO SET APINVOICE11detail1Fields.FieldByName("TAXCLASS2").VALUE TO ZERO OR DEFAULT VALUE WITHOUT ADDING ANOTHER TAX CLASS?
code
Public Function OpenAndPostEntry(ByVal APHeaderDetails As InvoiceHeaderData, ByVal APDetailsData As IList(Of InvoiceDetailsData), ByVal APOptianalFldData As IList(Of POOptionalData), ByVal TaxClass() As Int32) As Boolean
'Dim i As Int16 = 0
Dim temp As Boolean
Dim isPostingSuccess As Boolean
isPostingSuccess = False
Dim APINVOICE11batch As AccpacCOMAPI.AccpacView
Dim APINVOICE11batchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0020", APINVOICE11batch)
APINVOICE11batchFields = APINVOICE11batch.Fields
Dim APINVOICE11header As AccpacCOMAPI.AccpacView
Dim APINVOICE11headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0021", APINVOICE11header)
APINVOICE11headerFields = APINVOICE11header.Fields
Dim APINVOICE11detail1 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0022", APINVOICE11detail1)
APINVOICE11detail1Fields = APINVOICE11detail1.Fields
Dim APINVOICE11detail2 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0023", APINVOICE11detail2)
APINVOICE11detail2Fields = APINVOICE11detail2.Fields
Dim APINVOICE11detail3 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0402", APINVOICE11detail3)
APINVOICE11detail3Fields = APINVOICE11detail3.Fields
Dim APINVOICE11detail4 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0401", APINVOICE11detail4)
APINVOICE11detail4Fields = APINVOICE11detail4.Fields
APINVOICE11batch.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header})
APINVOICE11header.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11batch, APINVOICE11detail1, APINVOICE11detail2, APINVOICE11detail3})
APINVOICE11detail1.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header, APINVOICE11batch, APINVOICE11detail4})
APINVOICE11detail2.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header})
APINVOICE11detail3.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header})
APINVOICE11detail4.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11detail1})
Try
APINVOICE11detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("20") ' Line Number
APINVOICE11detail1.Read()
temp = APINVOICE11batch.Exists
APINVOICE11batch.RecordCreate(1)
APINVOICE11batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("1") ' Process Command Code
APINVOICE11batch.Process()
APINVOICE11batch.Read()
temp = APINVOICE11header.Exists
APINVOICE11header.RecordCreate(2)
APINVOICE11detail1.Cancel()
APINVOICE11headerFields.FieldByName("IDVEND").Value = APHeaderDetails.IDVEND ' Vendor Number
APINVOICE11headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("7") ' Process Command Code
APINVOICE11header.Process()
APINVOICE11headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("4") ' Process Command Code
APINVOICE11header.Process()
APINVOICE11headerFields.FieldByName("IDRMITTO").Value = APHeaderDetails.IDRMITTO ' Remit-To Location
APINVOICE11headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("4") ' Process Command Code
APINVOICE11header.Process()
APINVOICE11batch.Process()
APINVOICE11batch.Read()
APINVOICE11batchFields.FieldByName("BTCHDESC").PutWithoutVerification(APHeaderDetails.IDINVC) ' Refernce perpose
APINVOICE11batch.Update()
APINVOICE11headerFields.FieldByName("IDINVC").Value = APHeaderDetails.IDINVC ' Document Number
APINVOICE11headerFields.FieldByName("AMTGROSTOT").Value = APHeaderDetails.AMTGROSTOT ' Document Total Including Tax
APINVOICE11headerFields.FieldByName("DATEINVC").Value = APHeaderDetails.DATEINVC ' Document Date
APINVOICE11headerFields.FieldByName("DATEBUS").Value = APHeaderDetails.DATEBUS ' Posting Date
APINVOICE11headerFields.FieldByName("ORDRNBR").PutWithoutVerification(APHeaderDetails.ORDRNBR) ' Order Number
APINVOICE11headerFields.FieldByName("PONBR").PutWithoutVerification(APHeaderDetails.PONBR) ' PO Number
APINVOICE11headerFields.FieldByName("CODETAXGRP").Value = APHeaderDetails.CODETAXGRP
APINVOICE11headerFields.FieldByName("DATERATE").Value = APHeaderDetails.RATEDATE ' Rate Date
APINVOICE11headerFields.FieldByName("RATETYPE").Value = APHeaderDetails.RATETYPE ' Rate Type
APINVOICE11detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("-1") ' Line Number
APINVOICE11detail1.Read()
''loop via details lines for pickup gl account/payble clearing account
Dim i = APDetailsData.Count - 1
While (i >= 0)
If APDetailsData(i).IDGLACCT <> String.Empty Then
temp = APINVOICE11detail1.Exists
APINVOICE11detail1.RecordClear()
temp = APINVOICE11detail1.Exists
APINVOICE11detail1.RecordCreate(0)
APINVOICE11detail1.Process()
APINVOICE11detail1Fields.FieldByName("IDGLACCT").Value = APDetailsData(i).IDGLACCT.Trim() ' G/L Account
APINVOICE11detail1Fields.FieldByName("AMTDIST").Value = APDetailsData(i).AMTDIST 'APHeaderDetails.AMTGROSTOT - APHeaderDetails.AMTTAXTOT
APINVOICE11detail1Fields.FieldByName("TEXTDESC").Value = APDetailsData(i).TEXTDESC
APINVOICE11detail1.Insert()
If (APDetailsData(i).DETAILTAXCLASS1 > 0 And APDetailsData(i).DETAILTAXCLASS1 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS1").Value = APDetailsData(i).DETAILTAXCLASS1
End If
If (APDetailsData(i).DETAILTAXCLASS2 > 0 And APDetailsData(i).DETAILTAXCLASS2 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS2").Value = APDetailsData(i).DETAILTAXCLASS2
End If
If (APDetailsData(i).DETAILTAXCLASS3 > 0 And APDetailsData(i).DETAILTAXCLASS3 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS3").Value = APDetailsData(i).DETAILTAXCLASS3
End If
If (APDetailsData(i).DETAILTAXCLASS4 > 0 And APDetailsData(i).DETAILTAXCLASS4 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS4").Value = APDetailsData(i).DETAILTAXCLASS4
End If
If (APDetailsData(i).DETAILTAXCLASS5 > 0 And APDetailsData(i).DETAILTAXCLASS5 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS5").Value = APDetailsData(i).DETAILTAXCLASS5
End If
APINVOICE11detail1.Update()
End If
i -= 1
End While
If TaxClass(0) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS1").Value = TaxClass(0)
End If
If TaxClass(1) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS2").Value = TaxClass(1)
End If
If TaxClass(2) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS3").Value = TaxClass(2)
End If
If TaxClass(3) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS4").Value = TaxClass(3)
End If
If TaxClass(4) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS5").Value = TaxClass(4)
End If
APINVOICE11detail1.Read()
APINVOICE11headerFields.FieldByName("AMTGROSTOT").Value = APHeaderDetails.AMTGROSTOT '- APHeaderDetails.AMTTAXTOT ' PO Number
APINVOICE11header.Insert()
APINVOICE11batch.Read()
temp = APINVOICE11header.Exists
APINVOICE11header.RecordCreate(2)
APINVOICE11detail1.Cancel()
isPostingSuccess = True
CloseConn()
Return isPostingSuccess
Catch ex As Exception
MyErrorHandler()
CloseConn()
Return False
End Try
End Function
So far the integration is working FINE , but for items that have been set up 2 tax classes some issue is happening as when AP invoice have undistibuted amount appear , while there are unnessary tax is calculated.
This is because when AP invoice item has 3 detail level tax classes the assigned value will not get cleared when another AP Invoice having an item with 2 tax classes is posted, result is unnecessary tax is calculated.
I want to set APINVOICE11detail1Fields.FieldByName("TAXCLASS2").Value to zero as if it is not set in the IC item section
can't do this even APINVOICE11detail1Fields.FieldByName("TAXCLASS2").PutWithoutVerification("0")
(see the bold section in the code also )
ANY POSSIBLE SOLUTION TO SET APINVOICE11detail1Fields.FieldByName("TAXCLASS2").VALUE TO ZERO OR DEFAULT VALUE WITHOUT ADDING ANOTHER TAX CLASS?
code
Public Function OpenAndPostEntry(ByVal APHeaderDetails As InvoiceHeaderData, ByVal APDetailsData As IList(Of InvoiceDetailsData), ByVal APOptianalFldData As IList(Of POOptionalData), ByVal TaxClass() As Int32) As Boolean
'Dim i As Int16 = 0
Dim temp As Boolean
Dim isPostingSuccess As Boolean
isPostingSuccess = False
Dim APINVOICE11batch As AccpacCOMAPI.AccpacView
Dim APINVOICE11batchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0020", APINVOICE11batch)
APINVOICE11batchFields = APINVOICE11batch.Fields
Dim APINVOICE11header As AccpacCOMAPI.AccpacView
Dim APINVOICE11headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0021", APINVOICE11header)
APINVOICE11headerFields = APINVOICE11header.Fields
Dim APINVOICE11detail1 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0022", APINVOICE11detail1)
APINVOICE11detail1Fields = APINVOICE11detail1.Fields
Dim APINVOICE11detail2 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0023", APINVOICE11detail2)
APINVOICE11detail2Fields = APINVOICE11detail2.Fields
Dim APINVOICE11detail3 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0402", APINVOICE11detail3)
APINVOICE11detail3Fields = APINVOICE11detail3.Fields
Dim APINVOICE11detail4 As AccpacCOMAPI.AccpacView
Dim APINVOICE11detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView("AP0401", APINVOICE11detail4)
APINVOICE11detail4Fields = APINVOICE11detail4.Fields
APINVOICE11batch.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header})
APINVOICE11header.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11batch, APINVOICE11detail1, APINVOICE11detail2, APINVOICE11detail3})
APINVOICE11detail1.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header, APINVOICE11batch, APINVOICE11detail4})
APINVOICE11detail2.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header})
APINVOICE11detail3.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11header})
APINVOICE11detail4.Compose(New AccpacCOMAPI.AccpacView() {APINVOICE11detail1})
Try
APINVOICE11detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("20") ' Line Number
APINVOICE11detail1.Read()
temp = APINVOICE11batch.Exists
APINVOICE11batch.RecordCreate(1)
APINVOICE11batchFields.FieldByName("PROCESSCMD").PutWithoutVerification("1") ' Process Command Code
APINVOICE11batch.Process()
APINVOICE11batch.Read()
temp = APINVOICE11header.Exists
APINVOICE11header.RecordCreate(2)
APINVOICE11detail1.Cancel()
APINVOICE11headerFields.FieldByName("IDVEND").Value = APHeaderDetails.IDVEND ' Vendor Number
APINVOICE11headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("7") ' Process Command Code
APINVOICE11header.Process()
APINVOICE11headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("4") ' Process Command Code
APINVOICE11header.Process()
APINVOICE11headerFields.FieldByName("IDRMITTO").Value = APHeaderDetails.IDRMITTO ' Remit-To Location
APINVOICE11headerFields.FieldByName("PROCESSCMD").PutWithoutVerification("4") ' Process Command Code
APINVOICE11header.Process()
APINVOICE11batch.Process()
APINVOICE11batch.Read()
APINVOICE11batchFields.FieldByName("BTCHDESC").PutWithoutVerification(APHeaderDetails.IDINVC) ' Refernce perpose
APINVOICE11batch.Update()
APINVOICE11headerFields.FieldByName("IDINVC").Value = APHeaderDetails.IDINVC ' Document Number
APINVOICE11headerFields.FieldByName("AMTGROSTOT").Value = APHeaderDetails.AMTGROSTOT ' Document Total Including Tax
APINVOICE11headerFields.FieldByName("DATEINVC").Value = APHeaderDetails.DATEINVC ' Document Date
APINVOICE11headerFields.FieldByName("DATEBUS").Value = APHeaderDetails.DATEBUS ' Posting Date
APINVOICE11headerFields.FieldByName("ORDRNBR").PutWithoutVerification(APHeaderDetails.ORDRNBR) ' Order Number
APINVOICE11headerFields.FieldByName("PONBR").PutWithoutVerification(APHeaderDetails.PONBR) ' PO Number
APINVOICE11headerFields.FieldByName("CODETAXGRP").Value = APHeaderDetails.CODETAXGRP
APINVOICE11headerFields.FieldByName("DATERATE").Value = APHeaderDetails.RATEDATE ' Rate Date
APINVOICE11headerFields.FieldByName("RATETYPE").Value = APHeaderDetails.RATETYPE ' Rate Type
APINVOICE11detail1Fields.FieldByName("CNTLINE").PutWithoutVerification("-1") ' Line Number
APINVOICE11detail1.Read()
''loop via details lines for pickup gl account/payble clearing account
Dim i = APDetailsData.Count - 1
While (i >= 0)
If APDetailsData(i).IDGLACCT <> String.Empty Then
temp = APINVOICE11detail1.Exists
APINVOICE11detail1.RecordClear()
temp = APINVOICE11detail1.Exists
APINVOICE11detail1.RecordCreate(0)
APINVOICE11detail1.Process()
APINVOICE11detail1Fields.FieldByName("IDGLACCT").Value = APDetailsData(i).IDGLACCT.Trim() ' G/L Account
APINVOICE11detail1Fields.FieldByName("AMTDIST").Value = APDetailsData(i).AMTDIST 'APHeaderDetails.AMTGROSTOT - APHeaderDetails.AMTTAXTOT
APINVOICE11detail1Fields.FieldByName("TEXTDESC").Value = APDetailsData(i).TEXTDESC
APINVOICE11detail1.Insert()
If (APDetailsData(i).DETAILTAXCLASS1 > 0 And APDetailsData(i).DETAILTAXCLASS1 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS1").Value = APDetailsData(i).DETAILTAXCLASS1
End If
If (APDetailsData(i).DETAILTAXCLASS2 > 0 And APDetailsData(i).DETAILTAXCLASS2 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS2").Value = APDetailsData(i).DETAILTAXCLASS2
End If
If (APDetailsData(i).DETAILTAXCLASS3 > 0 And APDetailsData(i).DETAILTAXCLASS3 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS3").Value = APDetailsData(i).DETAILTAXCLASS3
End If
If (APDetailsData(i).DETAILTAXCLASS4 > 0 And APDetailsData(i).DETAILTAXCLASS4 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS4").Value = APDetailsData(i).DETAILTAXCLASS4
End If
If (APDetailsData(i).DETAILTAXCLASS5 > 0 And APDetailsData(i).DETAILTAXCLASS5 < 6) Then
APINVOICE11detail1Fields.FieldByName("TAXCLASS5").Value = APDetailsData(i).DETAILTAXCLASS5
End If
APINVOICE11detail1.Update()
End If
i -= 1
End While
If TaxClass(0) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS1").Value = TaxClass(0)
End If
If TaxClass(1) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS2").Value = TaxClass(1)
End If
If TaxClass(2) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS3").Value = TaxClass(2)
End If
If TaxClass(3) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS4").Value = TaxClass(3)
End If
If TaxClass(4) <> 0 Then
APINVOICE11headerFields.FieldByName("TAXCLASS5").Value = TaxClass(4)
End If
APINVOICE11detail1.Read()
APINVOICE11headerFields.FieldByName("AMTGROSTOT").Value = APHeaderDetails.AMTGROSTOT '- APHeaderDetails.AMTTAXTOT ' PO Number
APINVOICE11header.Insert()
APINVOICE11batch.Read()
temp = APINVOICE11header.Exists
APINVOICE11header.RecordCreate(2)
APINVOICE11detail1.Cancel()
isPostingSuccess = True
CloseConn()
Return isPostingSuccess
Catch ex As Exception
MyErrorHandler()
CloseConn()
Return False
End Try
End Function