Friday, 12 July 2013

Tax and VAT in xTuple

Understanding the tax system in xTuple is not simple!  Here are the main sections:

Setup


Tax Zone

Tax Zones normally describe an area where tax is applied in a particular way.  Vendors and Suppliers have a 'Tax Zone' setting in their master record.  This is used by default to chose which tax to apply when you buy or sell something

A Tax Zone record is just a name and a description

Tax Type

Tax Types are used in the Item master record.  Each item has a list of Tax Zones, and the Tax Type to apply for that zone.  When you buy the item from a vendor, the vendor Tax Zone is used to select the correct Tax Type.

A Tax Type record is just a name and a description

Tax Code

Tax Codes describe how much tax to actually charge.  A simple tax code would for instance to tax at 20% of the base price.  Tax codes can be complex as well, a tax code can calculate on the output of another tax code (a tax on top of a taxed value) as well as just taxing the base price.  A tax code can also be a fixed amount as well as a percentage.

Tax Code records have a name and description and details of the tax calculation.  They also link to a general ledger account that will record the tax transactions.  They can also link to a Tax Class and a Tax Authority. Finally, a tax code can be set to start or expire on a certain date.

Tax Assignment

For a tax to be applied, we need to create a link between the Tax Zone, Tax Code and Tax Type.  This is done here.

To create a new assignment, we select a Tax Zone and a Tax Type. For instance, in the UK tax zone, we need to charge VAT on freight when we ship products out.

To do this, we select the UK tax zone and the system supplied Freight tax type.  We then add the tax codes that can apply.  In the UK, all freight is charged at 20% VAT, so we add only the VAT-STD tax code.

You can add multiple tax codes to the zone/type assignment, but in that case ALL the tax codes in the assignment are summed on the invoice.  You can't just select the one tax code you want.  You might want 2 codes in the assignment if you know that the tax rate will be changing.  Use the start/end dates on the tax code to ensure that only one of them is active at a time and the change over will be automatic.

We also need to charge the same VAT on regular goods, as well as just freight.  We create another assignment that links our UK tax zone with our VAT tax type. Again we add VAT-STD as the tax code.

Now all Items records that have a UK tax zone and VAT tax type specified will automatically account for VAT at 20% when they are purchased from a vendor that is also in the UK tax zone!

Tax Class

This appears to be some form of reporting category.  I do not see anything much that it actually does....

Tax Authority

A Tax authority is the organisation responsible for collecting/refunding tax (HMRC in the UK).  The authority can be setup so it has a CRM record and effectively acts as a 'vendor' so you can pay them.

The tax authority record has a related general ledger account, currency, tax reference number and a related CRM account that holds address etc.


Example

We sell and buy from US/UK/EU and more so we need a number of tax settings

Tax Types:
VAT-STD     - Standard VAT rate (almost everything)
VAT-LOW   - Reduced VAT rate (fuel oil and a few other things)
VAT-0

Tax Zones:
UK     - Buying and selling in the UK
EU-REG  - Buying and selling in the EU where VAT is NOT charged on the receipt as the company is EU VAT registered
EU-UNREG - For selling to EU companies that do not have a valid EU VAT number (charged at UK STD rate)
IRL     - Ireland (google and similar) charge VAT at a different rate
ROW  - Default Zone for other countries, no tax is charged

Tax Authorities:
HMRC    - All VAT taxes are reported to HMRC, including EU sales

Tax Codes:
EU 0%     - 0%
IRL STD  - 19%
UK STD   -  5%
UK LOW -  20%

2 accounts were created in the general ledger.  UK VAT liability and EU VAT liability to track the tax figures required for the HMRC VAT return form.

Tax Assignments:
UK Tax Zone has assignments for VAT-STD, VAT-LOW and Freight
IRL Tax Zone has VAT-STD
EU-0 Tax Zone has an 'Any' assignment

The Tax history report correctly shows both the total tax generated under each tax code, and also the total invoice value that created those figures.  That gives you all the info you need to fill in the EU VAT return.

Tuesday, 2 July 2013

xTuple Import Order

The dependencies between tables mean that you have to import data in a certain order in many cases.  When setting up a new system, here is the order that I am using:

General system setup - I set most of these manually in the setup menus:

- Characteristics
- Class Codes
- Currencies
- Planner Codes
- Product Categories
- Site Types
- Site List
- Terms
- Units of Measure
- Vendor Types
- Shipping Zones
- Tax mappings (horrible and complex!)
- Cost Categories
- Expense Categories
- Sales Categories
- Customer Types

CSV Imports

1) Locations - Locations that items can be stored
2) Item - Main list of items
3) ItemTax - Tax zones for itemn
4) ItemFile - Files that are attached to item records (schematics, data sheet etc for example)
5) ItemCharacteristics - Characteristics of Items (additional custom info)
6) ItemSite - Describes how an item is used within site(s) of the company
7) Vendor - Describes places you buy things from
8) ItemSource - Describes where an item is bought from.  An item must have a source before you can create buy it!
9) BOM - Describes the BOM and its revision level
10)BomItem - Describes each part that exists on a BOM (from step 9)
11)MiscTagCount - Allows import of initial stock levels by posting simple count tags for items.

Importing CSV data to xTuple

CSVImp can be installed as on option with the xTuple client (As a separate application).  It also seems to be 'built in' to our version 4.0 demo.

In both cases it works the same way though I don't think you can use the stand-alone version to import data into a hosted demo.

There are 2 sections

1 - A CSV file containing the columns of exported data from your system.

2 - An XML format 'Map' that tells the importer what to do with the data

- First open the importer app (or find it in System->Setup->Import Data).  When using the built in version, I had to add some default paths to the data import setup options to let me start it.

- Create a new map click 'add' and give it a sensible name (Item_Import) select 'api' for the Schema option. The API is a set of standard views that let you import data easily without worrying too much about the underlying structure of the DB.  If you use direct access to the 'public' tables there is a far higher chance of corrupting the data!  There are a LOT of dependencies between tables that the API will sort out for you.

- You will now see a list of the columns that are used by this view.  Its a good idea to rum Excel and link to the API table, you will then be able to view the existing records and see easily how they relate to the required columns.

- In the CSV Tool window, 'open' your CSV file and you will see the first 100 rows of data.  You now need to set up the map to link the required data to your CSV columns.  You can also set the map to use a fixed value (or null) for any column if you need.

- When done, save the map and run Import->Start

- This can take a minute (or many minutes if using a hosted demo!).  When done a log window will show how many rows were processed and how many had errors.

HINT: The importer is buggy.  It will ONLY show the log if there is 1 or more errors BUT it will sometimes hit an error that will cause it to end the import without logging an error.  In this case you will never know how many rows were imported and how many failed!

Use a header row in your CSV data but DO NOT select the 'Treat first row as header' option.  This will ensure there is at least 1 simple error in every import and the log will show.  Check the record count matches the number of rows in your CSV!

Setup to import item data

We are just starting out with xTuple, having practiced on Postbooks, we are now setting up a hosted demo of the commercial version.

This blog is part reminder to myself on how to do this later, and part to help anyone with the same problems...hope you find it useful!

Setting up master information:

Products->Setup->Master Information

Characteristics

Add characteristics that are required to describe your stock items in the system.  As an electronics company, I have several that will help users understand, find and report on the stock we have.

ComponentSubType - Lists sub-types of off the shelf components
MechanicalSubType - Lists sub-types of mechanical items
Package - Package type of a component part used on a PCBA
SoftwareSubType - Lists sub-types of software items
StockLabelText - Short text description to be used on auto-printed stock labels.
Tolerance - Tolerance of a component in relation to its 'Value' characteristic
Value - Value of the main measurement(s) of a the component (such as MHz, Farads, volts etc)
Voltage - Voltage value for the component.  This is often listed separately from the main component value
RefManf - Manufacturer of the reference part
RefMPN - MPN of the reference part

For example, ComponentSubType includes:
Resistor, Capacitor, Inductor, connector and more.  The list values you chose will depend very much on the types of parts that you use.  Make sure you check the 'Item' option under 'Used On'.  This will make the characteristic available for use on the items table.

Class Codes

Class codes are used to group stock items into categories for reporting etc.  I use COMPONENT for off the shelf parts, PCBA for manufactured boards, ASSEMBLY as a generic class for multiple items that are attached and PRODUCT for the finished goods.

Product Categories

These apply to items that are actually sold.  Each of our different product lines has its own category

Schedule->Setup->Master Information

Planner Codes

Each 'Item' record requires an 'Item Site' record that describes how the item is used within a particular company site.  If you only have 1 site, you will only have one ItemSite for each item.

Planner codes are set on the Item Site and tell the manufacturing/planning system what to do by default for the item when it is used (You can chose to explode the BOM on a single or multiple level for example).

You should create these based on how you manufacture within your site(s)

Inventory->Site->List

Here you can set up your multiple sites IF you are using the commercial version that supports it!  We have our main site and 2 extra sites that relate to where we hold consigned stock for at a contract manufacturer.


Importing Item Data!

At this point, we import the Item data

When you import data to the Items API, Item Class Codes etc need to be set up correctly or the import will fail.  Import can be slow (or VERY slow if you are using a hosted demo).  See the separate port on general import tips!