Updating SalesOrder Tax Records

SOLVED

Hello -

I'm trying to override the tax amount on a Sales Order and I'm getting the following error (Record in use by another task):

Interestingly enough, the tax amount still seems to save. Any ideas what I'm missing? Here's my code (on table SO_SalesOrderHeader Pre-Write):

set TaxSummary = oSession.AsObject(oSession.GetObject("SO_SalesOrderTaxSummary_bus"))
orderNo = ""

retVal = oBusObj.GetValue("SalesOrderNo$", orderNo)

retval = TaxSummary.SetKeyValue("SalesOrderNo$", orderNo)
retval = TaxSummary.SetKeyValue("ScheduleSeqNo$", "000001")
retval = TaxSummary.SetKeyValue("TaxCode$", "SOVOS")
retval = TaxSummary.SetKey()
retVal = TaxSummary.SetValue("SalesTaxAmt", 12.20)
retval = TaxSummary.Write()

Parents
  • 0
    SUGGESTED

    My advice would be to not override tax values and let the published software handle it (either Sage 100 or another third party, like Avalara) but if you insist, better be sure your calculations are correct so you don't risk receiving a tax audit.

    For your specific issue, you need to use the object handle that is already in memory for the current tax record, not get a new handle.

    oBusObj should have an object handle called SalesTaxCalcObj that you can use. Try that and double check that you are on the tax record you need to edit before setting values and writing it. SalesTaxCalcObj points to the SY_SalesTaxCalculation_bus class.

    https://help-sage100.na.sage.com/2019/FLOR/#Object_Reference/SY/SY_SalesTaxCalculation_bus.html

  • 0 in reply to David Speck

    Thanks so much for the response David. Is this code way off-base?

    set TaxSummary = oSession.AsObject(oBusObj.SalesTaxCalcObj)
    retval = TaxSummary.CalculateTax(12.12, 1000, 0)

  • 0 in reply to MattAtGravoc

    The CalculateTax() method is overloaded with two different sets of arguments.  The one that you are trying to use that accepts three arguments is only valid for A/P and P/O tasks.  For S/O you would use the method call that has five arguments, (1) Tax Amount, (2) Taxable Total, (3) Nontaxable Total, (4) Taxable Sales Subject to Discount, (5) Nontaxable Sales Subject to Discount.

    Note the CalculateTax() method ignores input values, it calculates all of the values l have listed above and returns those values when the method is successful.  Your input of 12.12, 1000 and 0 would be ignored.

Reply
  • 0 in reply to MattAtGravoc

    The CalculateTax() method is overloaded with two different sets of arguments.  The one that you are trying to use that accepts three arguments is only valid for A/P and P/O tasks.  For S/O you would use the method call that has five arguments, (1) Tax Amount, (2) Taxable Total, (3) Nontaxable Total, (4) Taxable Sales Subject to Discount, (5) Nontaxable Sales Subject to Discount.

    Note the CalculateTax() method ignores input values, it calculates all of the values l have listed above and returns those values when the method is successful.  Your input of 12.12, 1000 and 0 would be ignored.

Children
No Data