Scripting

  • 1.  I've been working on an SO Invoice detail script,

    Posted 09-21-2016 08:41
    I've been working on an SO Invoice detail script, where I need to know if the invoice has a particular tax exemption. I started by looking for some kind of childhandle to bring up the invoice's tax tables, but found nothing. Then I tried SO_InvoiceTaxSummary_bus, which has the correct data after an invoice is accepted (or perhaps after pre-totals... I didn't check at that stage), but not while doing line entry for a new invoice. So, I settled with AR_CustomerShipToTaxExemptions_svc using a browse filter, looping through looking for the specific tax code in question, then checking for an exemption #. If the customer needs me to check for the exemption on the specific ShipToAddr (where applicable), then I'll also need to add script code for that. I'm wondering if there is an easier way to get tax exemption details when doing line entry on a new invoice?


  • 2.  RE: I've been working on an SO Invoice detail script,

    Posted 09-21-2016 10:55
    I'm very familiar with SO_InvoiceTaxSummary_bus. You're right the data is generated until you click Totals tab because that's when the SalesTaxCalculation() routine runs. Short or creating another datasource / child handle, other ways you could do it is an ODBC connection to AR_CustomerShipToTaxExemptions OR create your own UDT version of AR_CustomerShipToTaxExemptions table that you would separately maintain as a shadow table of sorts. The way you did it with AR_CustomerShipToTaxExemptions_svc seems fine but are you saying you had to loop thru the tax code even though you knew the specific tax code? If so it sounds like you're having trouble passing the TaxCode to SetBrowseFilter(). The trick is you have to null pad the CustomerNo (null pad all fields in a multi-part key except the last one). PaddedCust = strCust & STRING(20-LEN(strCust),Chr(0)) PartialKeyForSBF = strDiv & PaddedCust & strTaxCode retSBF = oCustShipToExemptions.SetBrowseFilter(PartialKeyForSBF) If retSBF = 1 Then retMove = oCustShipToExemptions.MoveNext() If retMove = 1 Then strEX = """" retVal = oCustShipToExemptions.GetValue(""TaxExemptionNo$"", strEX) If strEX <> """" Then 'woohoo End If End If End If


  • 3.  RE: I've been working on an SO Invoice detail script,

    Posted 09-21-2016 11:05
    Thanks Alnoor. I looked at the primary key on the table, saw it has the ShipToCode in the middle and decided it would be easier to just set the browse filter for the division / customer, then walk through the results. KPRIMARY: ARDivisionNo+CustomerNo+ShipToCode+TaxCode retVal = oHeaderObj.GetValue(""ARDivisionNo$"",sDivisionNo) retVal = oHeaderObj.GetValue(""CustomerNo$"",sCustomerNo) retVal = oCustomerTaxExemptions.SetBrowseFilter(sDivisionNo & sCustomerNo & string(20-len(sCustomerNo),chr(0))) retVal = oCustomerTaxExemptions.MoveFirst() do until oCustomerTaxExemptions.EoF retVal = oCustomerTaxExemptions.GetValue(""TaxCode$"",sTaxCode) 'retVal = oSession.AsObject(oSession.UI).MessageBox("""", sTaxCode) retVal = oCustomerTaxExemptions.GetValue(""TaxExemptionNo$"",sTaxExemptionNo) if sTaxCode = ""BCPST"" and len(sTaxExemptionNo) > 0 then sInvoiceIsBCPSTExempt = ""Y"" end if retVal = oCustomerTaxExemptions.MoveNext() loop This way I don't need to handle the ShipToCode specifically... unless the client says they need it. I was hoping there was something in the transaction, to avoid all this mess, but it seems not. Thanks again.