Sage / SData-2.0

Contains documents pertaining to the SData 2.0 developments
33 stars 10 forks source link

Mixed VAT on invoice line #71

Closed dankennedy closed 7 years ago

dankennedy commented 7 years ago

I'm trying to use the SData API to automate creation of invoices but regardless of the VAT amount I set on the feed entry, Sage automatically recalculates the amount based (presumably) on the commodity/product and tax code. My problems is a single invoice line may contain VAT which has already been calculated and applies to only a portion of net value.

Is it possible to create a single invoice line entry with predefined net, VAT and gross fields and prevent Sage from recalculating anything or do I have to create separate lines for each of the VAT and non VATable elements?

Any help, much appreciated.

Thanks

Dan

darroncockram commented 7 years ago

I'm guessing you are referring to the Sage 50 Accounts Sdata adapter here. Assuming that is the case then you can't have mixed tax on a single line item I'm afraid. The best approach would be as you suggest to create separate lines for each separate tax rate item.

Hope that helps.

dankennedy commented 7 years ago

Thanks for clarifying so quickly Darrin. Very much appreciated. I'll split them as suggested.

Thanks again.

dankennedy commented 7 years ago

Darron,

I made the changes discussed and split the invoice lines so it creates 2 per source entry i.e. VATable and non VATable, and while it creates the first two invoice lines as expected, it applies VAT across all remaining lines regardless of the product/commodity. Example attached. Any ideas?

screen shot 2016-11-21 at 15 24 11

darroncockram commented 7 years ago

What does your payload look like for that submission?

dankennedy commented 7 years ago

I've not traced the HTTP request but I've added a reference to the SData lib from C# and my code to construct each line looks like this: `var invoiceLine = new purchaseOrderLineFeedEntry {

            deliveryDate = transactionDate,
            netTotal = net,
            taxTotal = tax,
            grossTotal = gross,
            actualPrice = gross,
            status = Constants.WrittenSalesOrderLine,
            text = lineReference,
            quantity = 1
        };

        // Default to S1 product line if we have tax or set the commodity to a tax exempt product
        // for this line to ensure Tax isn't forced on the invoice line
        if (tax != 0)
            invoiceLine.type = Constants.FreeTextInvoiceLine;
        else
        {
            invoiceLine.type = Constants.StandardInvoiceLine;
            invoiceLine.commodity = taxExemptProduct;
        }

        return invoiceLine;`

Sorry can't seem to get code to format correctly :(

asterix187 commented 7 years ago

Have you tried setting to S2 for tax exempt?


From: Dan Kennedy notifications@github.com Sent: Monday, November 21, 2016 3:44:46 PM To: Sage/SData-2.0 Subject: Re: [Sage/SData-2.0] Mixed VAT on invoice line (#71)

I've not traced the HTTP request but I've added a reference to the SData lib from C# and my code to construct each line looks like this:

` var invoiceLine = new purchaseOrderLineFeedEntry {

        deliveryDate = transactionDate,
        netTotal = net,
        taxTotal = tax,
        grossTotal = gross,
        actualPrice = gross,
        status = Constants.WrittenSalesOrderLine,
        text = lineReference,
        quantity = 1
    };

    // Default to S1 product line if we have tax or set the commodity to a tax exempt product
    // for this line to ensure Tax isn't forced on the invoice line
    if (tax != 0)
        invoiceLine.type = Constants.FreeTextInvoiceLine;
    else
    {
        invoiceLine.type = Constants.StandardInvoiceLine;
        invoiceLine.commodity = taxExemptProduct;
    }

    return invoiceLine;

`

You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Sage/SData-2.0/issues/71#issuecomment-261974449, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHAXXegRf2F_0lUXAlosXE21jQWseQGCks5rAbxtgaJpZM4KxTK6.

dankennedy commented 7 years ago

No, so instead of retrieving the TAXEXEMPTPRODUCT, retrieve the S2 product and set it instead of taxExemptProduct after setting the line type?

darroncockram commented 7 years ago

Have you tried setting to S2 for tax exempt?

You won't find the S1, S2 or S3 products in the commodities feeds I'm afraid so you couldn't set the commodity to that for the line..

If the taxExemptProduct variable in your above code snippet represents a commodity that is a zero rated tax item in Accounts then I would expect the resulting invoice line to have zero tax set on it too.

dankennedy commented 7 years ago

So Darron, firstly thanks for your help in figuring this out. For info I think I've finally got something that works. Basically I now retrieve the 2 tax codes and only set the taxTotal when there is tax to apply i.e. retrieve taxcode T0 for zero rated lines and T1 for standard rate, and then set this on the invoice line itself and leave the taxTotal as null when it's zero rated. This seems to have cured the problem.

Thanks again.

Dan