cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with document total

Former Member
0 Kudos

Dear All,

I have problem adding an invoice through DI API with the total amount of 50,000 including VAT. The system is SBO 2005B, PL42; Document Setting is as following:

- Rounding Method = By Document

- Rounding Rule for Tax = Round Down

- Round Tax Amount in Rows = False

The following VBA code is used to add an invoice:

'----


Dim boInv As SAPbobsCOM.Documents

Dim boCom As SAPbobsCOM.Company

Set boCom = GetSboCompany() 'this function returns SBO company

Set boInv = boCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

boInv.CardCode = "Customer1"

boInv.DocDate = #9/1/2008#

boInv.DocType = dDocument_Items

boInv.DocCurrency = "JPY"

'Now add a invoice line

'boInv.Lines.Add - No need for the first line

boInv.Lines.ItemCode = "item1"

boInv.Lines.VatGroup = "S01" 'VAT rate for Japan is 5%

boInv.Lines.PriceAfterVAT = 50000

boInv.Add 'add the invoice

'----


What I get is an invoice with:

Gross Price = 50000 (in a line)

Total (LC) = 47619 (in a line)

Tax Amount = 2380.952381 (in a line)

and

Total Before Discount = 47619 (in a header)

Tax = 2380 (in a header; fractional part was round down because of the Document Setting)

Total = 49999 (in a header; which is different from Gross Price by 1 yen)

However, if I enter this invoice directly from the screen, then there will be no difference between Gross Price (Price after VAT) and Total, so, the invoice will be created correctly.

My question is how to add an invoice with the total amount of 50000? (Of course, 50000 is not the only "difficult" number, for example, 40000 also poses the same problem). I tried to use boInv.Lines.NetTaxAmount property to directly assign the tax amount (which is possible from the SBO screen), but in PL42 there's an error saying that this property is not yet implemented.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

To Gupta: I am creating invoices in bulk through DI API.

Edited by: Jandos Khalik on Sep 2, 2008 10:22 AM

Former Member
0 Kudos

Verner, thank you for advice. I also tried that way, but wasn't helpful. OK, I found a solution that is I think acceptible. I will describe it in short, for those who face such problem. Basic idea is to use XML to create an invoice. Here's the code:

'----


Dim boInv As SAPbobsCOM.Documents

Dim boCom As SAPbobsCOM.Company

Dim strXML As String

Set boCom = GetSboCompany() 'this function returns SBO company

'XML data will be supplied as string variable, not an external file

gboCom.XMLAsString = True

'Here you will create your XML stream. Important tags are <DocTotal> for the invoice header, and

'<Quantity>, <PriceAfVAT> tags for invoice lines. If <DocTotal> is specified then you will get invoice with

'this exact total amount. If sum of <Quantity> x <PriceAfVAT> is equal to '<DocTotal>, then

'document level discount will be zero.

strXML = "<BOM> ... </BOM>" 'building XML here

Set boInv = gboCom.GetBusinessObjectFromXML(strXML, 0) 'Create an invoice object from XML

boInv.Add 'add the invoice

'----


Edited by: Jandos Khalik on Sep 2, 2008 10:17 AM

Edited by: Jandos Khalik on Sep 2, 2008 10:18 AM

Edited by: Jandos Khalik on Sep 2, 2008 10:20 AM

Former Member
0 Kudos

Try to set .UnitPrice as 50000 / VAT

I had a problems in the past when I set price after vat and unit price was calculated with object.

Former Member
0 Kudos

Hi,

Why u using DI-API same we can add from sab b1 application.