AR_InvoiceTaxSummary_bus is updated only Taxable Amount in A/R Invoice Data Entry Totals

Hello everyone!

I have script that should be updating the value of TaxAmount field in Account Receivable ->Invoice Data Entry...

strInvoiceNumerAndSchedule = strInvoiceNumber & "IN" & "000001EX"

Set oTS = oSession.AsObject(oSession.GetObject("AR_InvoiceTaxSummary_bus"))
retVal = oTS.SetKey(strInvoiceNumerAndSchedule)
retVal = oTS.SetValue("SalesTaxAmt", CDbl(TotalTaxAmount.text))
retVal = oTS.Write()

He is updating the value only at A/R Invoice Data Entry Totals(Taxable Amount field) tab but not in ->TaxDetail ->Tax Amount.

Is it a Sage bug or i have to modify my script?

Parents
  • 0
    The total is calculated from the tax table, not the other way around. Beware, there are events that will cause the taxes to be recalculated, so any value you set is not safe from being automatically changed by the system.
  • 0 in reply to Kevin M
    Tnx from reply,
    My script which is changing the value is on Accept (Postwrite event of the table).So when i check again the same AR Invoice number the value is only changed in (Taxable Amount field) tab but not in ->TaxDetail ->Tax Amount.
  • 0 in reply to ndym1
    And I explained why that happens. You need to create an object for the tax table and update the value there, not the total on the header.
    But really, the system should calculate taxes correctly. Fix that properly not via script.
  • 0 in reply to Kevin M
    Excuse me for the stupid question but when you says you need to create an object for the tax table and update the value there which Bus or table do you mean to use to achieve it ?
  • 0 in reply to ndym1
    Look in the help files for File Layouts. The table names (and associated business objects) are listed in there.
  • 0 in reply to Kevin M
    C:\Sage\Sage 100 Standard\MAS90\Home\Lib\_repository\mas5.30.01.00\env\any\CommonProgramFiles\Sage\Common Components\Help\5.30\FileLayouts.chm
  • 0 in reply to Kent Rhodes
    Tnx for the replays Kevin and Kent u are helping me alot and i`m rly appreciate your help!

    A little more info- we have custom tax schedule in which i`m trying to make a change on SalesTaxAmt
    As documentation says AR_InvoceTaxSummery to get access you need :
    KPRIMARY:InvoiceNo+InvoiceType+ScheduleSeqNo+TaxCode
    KTAXCODE:TaxCode+InvoiceNo+InvoiceType+ScheduleSeqNo

    Set oInvoiceTaxSummary = oSession.AsObject(oSession.GetObject("AR_InvoiceTaxSummary_bus"))
    retVal = oInvoiceTaxSummary.SetKeyValue("InvoiceNo", strInvoiceNumber)
    retVal = oInvoiceTaxSummary.SetKeyValue("InvoiceType$", strInvoiceType)
    retVal = oInvoiceTaxSummary.SetKeyValue("ScheduleSeqNo", strScheduleSeqNo)
    retVal = oInvoiceTaxSummary.SetKeyValue("TaxCode$", strTaxCode)
    retVal = oInvoiceTaxSummary.SetKey()

    retVal = oInvoiceTaxSummary.SetValue("SalesTaxAmt", 1234.02)

    'I tried with or without .Write() method
    retVal = oInvoiceTaxSummary.Write()

    I know this functionality is working because Sage has default Tax schedule and it work fine.I think Sage get little confuse because there are 2 fields SalesTaxAmt - AR_InvoiceHeader which is my default bus in this example and AR_InvoiceTaxSummary which also has SalesTaxAmt field and the value i`m trying to change.
  • 0 in reply to Kent Rhodes
    Txn for the replays Kevin and Kent u are helping me alot guys and Im rly appreciate your help!

    A little more info - we have custom tax schedule in which im trying to make a change on SalesTaxAmt
    As documentation says AR_InvoiceTaxSummary to get access you need :
    KPRIMARY: InvoiceNo+InvoiceType+ScheduleSeqNo+TaxCode
    KTAXCODE: TaxCode+InvoiceNo+InvoiceType+ScheduleSeqNo

    Set oInvoiceTaxSummary = oSession.AsObject(oSession.GetObject("AR_InvoiceTaxSummary_bus"))
    retVal = oInvoiceTaxSummary.SetKeyValue("InvoiceNo$", "0100084")
    retVal = oInvoiceTaxSummary.SetKeyValue("InvoiceType$", "IN")
    retVal = oInvoiceTaxSummary.SetKeyValue("ScheduleSeqNo$", "000001")
    retVal = oInvoiceTaxSummary.SetKeyValue("TaxCode$", "EX")
    retVal = oInvoiceTaxSummary.SetKey()

    retVal = oInvoiceTaxSummary.SetValue("SalesTaxAmt", 1234.02)
    retVal = oInvoiceTaxSummary.Write()
    I know that this functionality is working because Sage has default Tax schedule and it work fine.I think Sage get little confuse because there is 2 fields SalesTaxAmt - AR_InvoiceHeader which is my default bus and AR_InvoiceTaxSummary which also has SalesTaxAmt field and the value im trying to change
  • 0 in reply to Kevin M
    You are totally right about the part that system override the value of the field after me. I accidentally saw that code is work when i was added a last line of code which rise Sage exception...Does anyone knows a way to tell Sage not to do this..I tried with SetToReadOnly(SalesTaxAmt) after Write() method but no luck.My code start with entering fields in edit mode -

    If oBusObj.EditState>0 Then

    'code over here

    End If
Reply
  • 0 in reply to Kevin M
    You are totally right about the part that system override the value of the field after me. I accidentally saw that code is work when i was added a last line of code which rise Sage exception...Does anyone knows a way to tell Sage not to do this..I tried with SetToReadOnly(SalesTaxAmt) after Write() method but no luck.My code start with entering fields in edit mode -

    If oBusObj.EditState>0 Then

    'code over here

    End If
Children
  • 0 in reply to ndym1
    Why are you trying to override the tax amount?
  • 0 in reply to Kevin M
    I`m calling a service... and response from this service has a value that I should write back in tax amount. I had even tried to changed the value from Sage Database.. the value has been changed successfully but still only at Tax Details -> Tax Amount they are zero overthere.
  • 0 in reply to ndym1
    An alternate way to do this is to ignore the tax fields. Create a miscellaneous item for /TAX, then add a line with your amount.
  • 0 in reply to ndym1
    I would recommend that you let Sage calculate the taxes. Perhaps you are looking at the wrong problem to solve? I have done integrations with shopping carts and Sage, and the issue has always been to get the Shopping cart to respect the Sage taxes (well not really an issue, but a "problem" in the list to solve).

    I would say that if taxes are set up properly in Sage for an invoice, and your service is sending data that has different taxes - there is a disconnect there. Either adjust the sage tax settings so they mirror the data from your service, or adjust the source of the service so that they mirror Sage. Taxes are kind of a known quantity, and you should be able to get a harmonization without putting in the "wrong" taxes into Sage (which it sounds like you are trying to do - at least "wrong" in the sense that Sage isn't set up to calculate in the way you want to do it so it overwrites your changes).

    Please be aware, that even if you got your changes and "wrong" taxes set in Sage, someone else could just look at the invoice, and it would revert back to it's "correct" setting, overwriting what you have done. This is a danger sign and you need to stop and think about this.

    There is only one tax reality. Probably Sage is set up correctly as it was probably done by accountants. And an external service was probably done by computer scientists. I would guess that the tax reality lies in Sage with the accountants and you have to get your external service to match that reality.