Reply
 
LinkBack Thread Tools Display Modes
Old 03-26-2009, 12:35 AM   #1 (permalink)
chrisK
Guest
 
Posts: n/a
Default Scripting access to Tax

I am trying to get access to the Item tax amount through scripting. It shows up under dtr:Items -> dtr:Item -> dtp:ItemTaxes -> dtp:ItemTax -> dtp:amount.

Although ItemTaxes is a member of Item, ItemTax generates an error when i try to access it as a member of ItemTaxes.

How can i reference this value?

Thanks
ck
  Reply With Quote
Old 03-26-2009, 06:28 PM   #2 (permalink)
RickC
Guest
 
Posts: n/a
Default

Originally Posted by chrisK View Post
I am trying to get access to the Item tax amount through scripting. It shows up under dtr:Items -> dtr:Item -> dtp:ItemTaxes -> dtp:ItemTax -> dtp:amount.

Although ItemTaxes is a member of Item, ItemTax generates an error when i try to access it as a member of ItemTaxes.

How can i reference this value?

Thanks
ck
Well, I'm not sure of the greater context, but here's a go.

A couple of things here that are probably tripping you up. The first is that that there may be one or more ItemTax nodes in the XML. This allows us to support Canadian taxes where there are multiple tax codes for each item.


The easiest thing to do is create a calculated field and set the value in script.

Here's a link for the basic steps (there's a word doc in the zip file):
http://downloads.d-tools.com/si5/rep...o_A_Report.zip

For your specific question, you would do this in the FetchData event:

Code:
 
' Add the custom field
Sub ActiveReport_DataInitialize
  ' Add the calculated field to the data
   rpt.Fields.Add("ItmTax")
End Sub
 
Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean
   ' return the current item that is being iterated over. (this works for all proposals and most reports
 ' the report must be iterating over the Item or ProposalItem nodes in the data
  Dim itm As DTools.SystemIntegrator.Reporting.Item =   ReportUtilities.ReturnItem(rpt)
 
 ' Create a variable for an ItemTax object
  Dim it as DTools.SystemIntegrator.Common.ItemTax = Nothing
 
 ' If the item is not null, set value of the calculated field 
  If itm IsNot Nothing Then
 
     ' Loop the ItemTaxes collection and add up the total amounts of the item tax
      For Each it in itm.ItemTaxes
          ' set the value of the calculated field.   
          rpt.Fields("ItmTax").Value += it.Amount
      Next
 
   End If
 
 ' Must return EOF
  Return EOF
 
End Function
If you follow the rest of the info in the word doc, you should be able to bind a textbox to the ItmTax data field.

-R
  Reply With Quote
Old 03-26-2009, 11:52 PM   #3 (permalink)
chrisK
Guest
 
Posts: n/a
Default

Worked perfectly Rick! Thanks. I was indeed getting hung up on not understanding the hierarchy of the ItemTaxes object.

Next question; can you retrieve the Project Tax percentage so to display it on a report?

Thanks.
-CK
  Reply With Quote
Old 03-27-2009, 01:47 PM   #4 (permalink)
RickC
Guest
 
Posts: n/a
Default

Originally Posted by chrisK View Post
Next question; can you retrieve the Project Tax percentage so to display it on a report?
It is not directly available in the schema, but you could calculate it.

In the example above, you could check if an item is taxable and get the percentage of the tax on the item.

Here's the minor hitch, labor and equipment have separate tax rates, so you can't use the Amount property on the ItemTax object, you have to use the EquipmentAmount or the LaborAmount against. Also, tax is calculated against the extended cost of an item (Price + EquipmentAdjustment + MiscPartsAdjustment).

-R
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add sales tax to the Installed Price on an item basis Francisco Felix Reports and Reporting Center 6 04-01-2011 08:50 PM
Use Tax Suggestion Ahtinc Suggestions and Feature Requests 0 09-17-2008 12:11 PM
NZ Tax (GST) calculation not correct gmknz01 Bugs Section 2 05-27-2008 07:35 PM
New Canadian PST? James McDowell General Section 9 05-22-2008 12:18 AM
Tax on - Tax off ASoundintheDesert 'How Do I' Questions 1 11-15-2007 11:48 AM


All times are GMT. The time now is 08:33 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
D-Tools, Inc.