Skip to Content
author's profile photo Former Member
Former Member

Tax amount double

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

AR Invoice.jpg (130.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 25, 2012 at 06:15 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.