cancel
Showing results for 
Search instead for 
Did you mean: 

Tax amount double

Former Member
0 Kudos

Hi All,

         Check my Attached Image file. A/R invoice Tax amount getting double automatically(not for all) when positing thru DI API.

DI API Code:

            oInvoice.CardCode = ucTxtCdCode.BindingText;
            oInvoice.ControlAccount = TxtControlAccount.Text;
            oInvoice.NumAtCard = TxtQuotNos.Text;
            oInvoice.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;
            oInvoice.DocDate = Convert.ToDateTime(dtpPosting.Text);
            oInvoice.DocDueDate = Convert.ToDateTime(dtpDelivery.Text);
            oInvoice.DocCurrency = SAPDefault.Currency.Trim();
            oInvoice.Comments = TxtRemarks.Text;
            oUserField.Fields.Item("U_TAmt").Value = double.Parse(TxtAmt.Text);
          
            oUserField.Fields.Item("U_PFor").Value = "SALES INVOICE";
            oInvoice.DiscountPercent = double.Parse(TxtDiscPer.Text);
            oInvoice.Project = PrjCode;
           
          
                oInvoice.DocTotal = double.Parse(IActTotAmt.ToString());
                oInvoice.Rounding = SAPbobsCOM.BoYesNoEnum.tYES;
                oInvoice.RoundingDiffAmount = double.Parse(TxtRounding.Text);


            oUserField.Fields.Item("U_SCode").Value = UCTxtSCode.BindingText;
        

            int j;
            for (j = 0; j <= Spread.ActiveSheet.RowCount - 1; j++)
            {
                if (Convert.ToString(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ItemCode)) != "")
                {
                    SAPbobsCOM.UserFields objUserField;
                    objUserField = oInvoice.Lines.UserFields;

                    oInvoice.Lines.ItemCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ItemCode).ToString();
                    oInvoice.Lines.ItemDescription = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ItemDesc).ToString();
                    oInvoice.Lines.Quantity = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Quantity));
                    oInvoice.Lines.DiscountPercent = 0;

                 
                    oInvoice.Lines.UnitPrice = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.UnitPrice));
                  
                    oInvoice.Lines.TaxCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.TaxCode).ToString();
                    oInvoice.Lines.LineTotal = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Total));
                    oInvoice.Lines.WarehouseCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Whse).ToString();
                    oInvoice.Lines.ProjectCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ProjectCode).ToString();


                    oInvoice.Lines.Add();

                }


            }
            ErrCode = oInvoice.Add();
            string errmsg = "";

            if (ErrCode != 0)
            {
                AppCom.oCompany.GetLastError(out ErrCode, out errmsg);
                MessageBox.Show("Location : InvPosting(),oInvoice.Add(),ErrCode : " + ErrCode + " and ErrMsg : " + errmsg + "");
                return false;
            }


            System.Runtime.InteropServices.Marshal.ReleaseComObject(oInvoice);
            oInvoice = null;

With regards,

Venki .A

Accepted Solutions (1)

Accepted Solutions (1)

Johan_H
Active Contributor
0 Kudos

Hi Venki,

Would you please test the adapted code below ?

If always Quantity x UnitPrice = LineTotal then please comment out lines 27 and/or 29

           oInvoice.CardCode = ucTxtCdCode.BindingText;
            oInvoice.ControlAccount = TxtControlAccount.Text;
            oInvoice.NumAtCard = TxtQuotNos.Text;

            oInvoice.DocDate = Convert.ToDateTime(dtpPosting.Text);
            oInvoice.DocDueDate = Convert.ToDateTime(dtpDelivery.Text);
            oInvoice.DocCurrency = SAPDefault.Currency.Trim();
            oInvoice.Comments = TxtRemarks.Text;
            oUserField.Fields.Item("U_TAmt").Value = double.Parse(TxtAmt.Text);

            oUserField.Fields.Item("U_PFor").Value = "SALES INVOICE";
            oInvoice.DiscountPercent = double.Parse(TxtDiscPer.Text);
            oInvoice.Project = PrjCode;
           
                oInvoice.Rounding = SAPbobsCOM.BoYesNoEnum.tYES;

            oUserField.Fields.Item("U_SCode").Value = UCTxtSCode.BindingText;
       
            int j;
            for (j = 0; j <= Spread.ActiveSheet.RowCount - 1; j++)
            {
                if (Convert.ToString(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ItemCode)) != "")
                {
                    SAPbobsCOM.UserFields objUserField;
                    objUserField = oInvoice.Lines.UserFields;

                    oInvoice.Lines.ItemCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ItemCode).ToString();
     
                    oInvoice.Lines.Quantity = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Quantity));
                    oInvoice.Lines.UnitPrice = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.UnitPrice));
                    oInvoice.Lines.TaxCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.TaxCode).ToString();
                    oInvoice.Lines.LineTotal = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Total));
                    oInvoice.Lines.WarehouseCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Whse).ToString();
                    oInvoice.Lines.ProjectCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ProjectCode).ToString();


                    oInvoice.Lines.Add();

                }


            }
            ErrCode = oInvoice.Add();
            string errmsg = "";

            if (ErrCode != 0)
            {
                AppCom.oCompany.GetLastError(out ErrCode, out errmsg);
                MessageBox.Show("Location : InvPosting(),oInvoice.Add(),ErrCode : " + ErrCode + " and ErrMsg : " + errmsg + "");
                return false;
            }


            System.Runtime.InteropServices.Marshal.ReleaseComObject(oInvoice);
            oInvoice = null;

Regards,

Johan

Former Member
0 Kudos

Hi Johan Hakkesteegt,

      Thanks for your reply. But, we faced same problem after changed based on your comments.

With regards,

Venki .A

Johan_H
Active Contributor
0 Kudos

Hi Venki,

Could you please post a new screen shot of that same invoice, but this time with the Tax % and Tax amount (LC) columns visible ?

Regards,

Johan

Former Member
0 Kudos

Hi Johan Hakkesteegt,

     Refer attached image file for Tax Amount.

With regards,

Venki .A

Johan_H
Active Contributor
0 Kudos

Hi Venki,

Would you please test the following adaptation of your code (several lines properties in different order):

oInvoice.Lines.WarehouseCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Whse).ToString(); 

oInvoice.Lines.ProjectCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.ProjectCode).ToString(); 

oInvoice.Lines.Quantity = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Quantity)); 

oInvoice.Lines.UnitPrice = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.UnitPrice)); 

oInvoice.Lines.LineTotal = double.Parse(Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.Total)); 

oInvoice.Lines.TaxCode = Spread.ActiveSheet.GetText(j, (int)SpdEnumItem.TaxCode).ToString();

Regards,

Johan

Former Member
0 Kudos

Hi Johan Hakkesteegt,

    Thanks for your replay.

    I have not find any difference using this change, samething occuring.For this problem we shifting 882 PL0 to 882 PL4 today.

With regards,

Venki .A

Johan_H
Active Contributor
0 Kudos

Hi,

I was going to suggest reinstalling the DI API, but it does sound like a bug.

The upgrade should solve the problem.

Regards,

Johan

Former Member
0 Kudos

HI Johan Hakkesteegt,

     Thanks for your reply. Yesterday we moved to PL04. Right now we didnt find this problem with same DI API code.

With regards,

Venki .A

Answers (0)