0
votes

In Microsoft Dynamics GP I need to set the tax on individual orders as taxable/non-taxable (cannot be done on customer record).

For some reason no matter what I pass into the CreateSalesOrder call for the web services, it will not save the tax information.

I've tried:

  • Using the CreateSalesInvoice policy which has had "Create Taxes Behavior" set to "Taxes will be provided"
  • Overrode policies using "Use Header Level Taxes Behavior" and "Create Taxes Behavior" all 4 modes have been tried.
  • Provided taxes as a total on the Sales Order
  • Provided taxes as a tax detail on the sales order
  • Provided taxes as a total on the line item
  • Provided taxes as a tax detail on the sales order
  • Set the TaxScheduleKey on the order
  • Set the TaxScheduleKey on the line items

Taxes just get blanked out in GP, it's infuriating... Any ideas? I do have access to the Dynamics database but I'd really rather not go that route if possible.

My research has led me to believe that this is broken (every thread on this subject ends with no answers) and Microsoft isn't going to fix it, but that really hurts automation something awful.

1

1 Answers

1
votes

Ran into this issue today. A little background:

After trying everything outlined above, modifying policies - particularly, Sales Document - Create Sales Document policies, and becoming frustrated at there being no policies for Create Sales Order to allow taxes to be specified, I came across this MSDN article about how the GP Services could be designed or extended: https://msdn.microsoft.com/en-us/library/dd996499.aspx

Not interested in going quite that far, I found - "Program Files\Microsoft Dynamics\GPWebServices\XSLT", in particular, the "Microsoft.Dynamics.GP.SalesOrderCreate.xslt" file.

As it comes installed with GreatPlains, there are no transforms in place to utilize incoming tax data at all (no surprise, given what had been tried). USINGHEADERLEVELTAXES is set to 0.

Combining the Tax lines from the "Microsoft.Dynamics.GP.SalesInvoiceCreate.xslt" file into the SalesOrderCreate.xslt file, you can modify the XML sent into eConnect for SalesOrderCreate to properly create the Taxes.

The below example uses/was tested for header level tax behavior.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:mbs="http://schemas.microsoft.com/dynamics/2006/01"
    xmlns:gputil="urn:Microsoft.Dynamics.GP.TransformUtilities"
    version="1.0">

  <xsl:import href="Microsoft.Dynamics.GP.SalesCreateUpdateLibrary.xslt"/>
  <xsl:import href="Microsoft.Dynamics.GP.StandardLibrary.xslt"/>

  <xsl:variable name="CompanyId">
    <xsl:value-of select="/SalesOrder/mbs:Context/mbs:OrganizationKey/mbs:Id"/>
  </xsl:variable>

  <xsl:template match ="/">
    <eConnect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsl:apply-templates />
    </eConnect>
  </xsl:template>

  <xsl:template match="SalesOrder">
    <SOPTransactionType>
      <xsl:apply-templates select="Lines/SalesOrderLine/Serials/SalesLineSerial">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:apply-templates>
      <xsl:apply-templates select="Lines/SalesOrderLine/Components/SalesOrderComponent/Serials/SalesComponentSerial">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:apply-templates>
      <xsl:apply-templates select="Lines/SalesOrderLine/Lots/SalesLineLot">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:apply-templates>
      <xsl:apply-templates select="Lines/SalesOrderLine/Components/SalesOrderComponent/Lots/SalesComponentLot">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:apply-templates>
      <xsl:apply-templates select="Lines/SalesOrderLine" />
      <xsl:apply-templates select="Lines/SalesOrderLine/Components/SalesOrderComponent" />
      <xsl:apply-templates select="TrackingNumbers/SalesTrackingNumber" />
      <xsl:apply-templates select="Taxes/SalesDocumentTax" />
      <xsl:apply-templates select="Commissions/SalesCommission" />
      <xsl:apply-templates select="Payments/SalesPayment">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:apply-templates>
      <xsl:apply-templates select="UserDefined" />
      <xsl:apply-templates select="Lines/SalesOrderLine/Bins/SalesLineBin" />
      <xsl:apply-templates select="Lines/SalesOrderLine/Components/SalesOrderComponent/Bins/SalesComponentBin" />
      <xsl:call-template name="SalesHeader" />
      <xsl:apply-templates select="ProcessHolds/SalesProcessHold">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:apply-templates>
    </SOPTransactionType>
  </xsl:template>

  <xsl:template match="SalesOrderLine">
    <taSopLineIvcInsert>
      <xsl:call-template name="CreateUpdateLine">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
        <xsl:with-param name="CompanyId">
          <xsl:value-of select="$CompanyId" />
        </xsl:with-param>
      </xsl:call-template>
      <xsl:if test="QuantityToBackorder/Value != ''">
        <QTYTBAOR>
          <xsl:value-of select="QuantityToBackorder/Value" />
        </QTYTBAOR>
      </xsl:if>
      <xsl:if test="QuantityToInvoice/Value != ''">
        <QUANTITY>
          <xsl:value-of select="QuantityToInvoice/Value" />
        </QUANTITY>
      </xsl:if>
      <xsl:if test="QuantityCanceled/Value != ''">
        <QTYCANCE>
          <xsl:value-of select="QuantityCanceled/Value" />
        </QTYCANCE>
      </xsl:if>
      <xsl:if test="QuantityFulfilled/Value != ''">
        <QTYFULFI>
          <xsl:value-of select="QuantityFulfilled/Value" />
        </QTYFULFI>
      </xsl:if>
      <xsl:if test="TaxAmount/Value != ''">
        <TAXAMNT>
          <xsl:value-of select="TaxAmount/Value" />
        </TAXAMNT>
      </xsl:if>
      <RecreateDist>0</RecreateDist>
    </taSopLineIvcInsert>
  </xsl:template>
  <xsl:template match="SalesOrderComponent">
    <taSopLineIvcInsertComponent>
      <xsl:call-template name="CreateUpdateComponent">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
      </xsl:call-template>
      <xsl:if test="QuantityToBackorder/Value != ''">
        <QTYTBAOR>
          <xsl:value-of select="QuantityToBackorder/Value" />
        </QTYTBAOR>
      </xsl:if>
      <xsl:if test="QuantityToInvoice/Value != ''">
        <QUANTITY>
          <xsl:value-of select="QuantityToInvoice/Value" />
        </QUANTITY>
      </xsl:if>
      <xsl:if test="QuantityCanceled/Value != ''">
        <QTYCANCE>
          <xsl:value-of select="QuantityCanceled/Value" />
        </QTYCANCE>
      </xsl:if>
      <xsl:if test="QuantityFulfilled/Value != ''">
        <QTYFULFI>
          <xsl:value-of select="QuantityFulfilled/Value" />
        </QTYFULFI>
      </xsl:if>
    </taSopLineIvcInsertComponent>
  </xsl:template>
  <xsl:template name="SalesHeader">
    <taSopHdrIvcInsert>
      <xsl:call-template name="CreateUpdateDocument">
        <xsl:with-param name="UpdateIfExists">0</xsl:with-param>
        <xsl:with-param name="CompanyId">
          <xsl:value-of select="$CompanyId" />
        </xsl:with-param>
      </xsl:call-template>
      <xsl:if test="PaymentAmount/Value != ''">
        <PYMTRCVD>
          <xsl:value-of select="PaymentAmount/Value" />
        </PYMTRCVD>
      </xsl:if>
      <xsl:if test="TaxAmount/Value != ''">
        <TAXAMNT>
          <xsl:value-of select="TaxAmount/Value" />
        </TAXAMNT>
      </xsl:if>
      <USINGHEADERLEVELTAXES>1</USINGHEADERLEVELTAXES>
      <CREATEDIST>0</CREATEDIST>
      <CREATETAXES>0</CREATETAXES>
    </taSopHdrIvcInsert>
  </xsl:template>
</xsl:stylesheet>