Sunday, April 28, 2013

Australian Tax

Two type sof income tax Assessment acts are used:
1. Tax Assessment Act 1936
2. Tax Assessment Act 1997

No.1 is gradually being replaced with No.2 as it is more user friendly.

CGT: Captial gains tax introduced in 1985

FBT: Fringe Benefit Tax introduced in 1986

GST: Goods and Services Tax introduced in 2000

Federal Taxes:

1. CGT
2. Customs Duty
3. Excise duty
4. Fringe Benefits Tax
5. Fuel Tax
6. GST
7. Income tax
8. Medicare Levy
9. Withholding tax

State Taxes:
1. Gambling Tax
2. Land tax
3. Payroll Tax
4. Stamp Duty

Tax Formula:
Taxable Income of an Australian = Assessable Income – allowable deductions

Assessable Income: is the income that your are liable to pay income tax on. It is of two types:

  1. Ordinary Income
  2. Statutory income

Ordinary Income :

  1. Income from personal exertion: Salary and wages, bonus, commissions, allowances earned as an employee. Income from these sources is taxed at Marginal tax rates. If you are a resident of Aus, you may quality certain tax offsets (rebates)
  2. Income from property: interests, dividends, annuities, royalty payments. dividend received may qualify for a dividend franking credit tax offset (rebate).
  3. Proceeds from carrying on (running) a business: Profits you earn running your business.

Exempt Income:

  1. Defence force allowance
  2. Family assistance allowance
  3. Educational assistance allowance
  4. Compensation allowance
Notice of assessment
Is a statement you receive from the tax office after you lodge your tax return. It summarises the details of lodged tax return.

PAYG payment summary
At the end of a financial year, if you are  a salary and wage earner your employer gives you a PAYG payment summary individual non-business  statement. This statement has
1. Gross income
2. Allowances you received between 1July to 30 June.
3. Total PAYG withholding tax deducted from your salary. (TDS in India)
 
PAYG statement is just like Form16 in India.
 
Receiving an Allowance:
When you receive an allowance, you can claim a tax deduction for expenditure. But there are some tests to be carried on to identify which allowances are claimable.
 
SG (Superannuation Guarantee)
Under the SG legislation, in addition to paying salary or wage, your employer is obligated to make a superannuation contribution on your behalf to a complying Superannuation Fund (SF). It is currently 9% of of your basic salary. It is purposed to be 12% by 2019-20.
 

INCOME

1 Income from partnerships and trusts
2 Personal services income
3 Net income or loss from business
4 Deferred non-commercial business losses
17 Net farm management deposits or repayments
18 Capital gains (from all sources including shares, real estate and other property)
19 Foreign entities
20 Foreign source income and foreign assets or property, including foreign source pension or annuity
21 Rent
22 Bonuses from life insurance companies and friendly societies
23 Forestry managed investment scheme income
24 Other income (income not listed elsewhere)

DEDUCTIONS
D11 Deductible amount of undeducted purchase price of a foreign pension or annuity
D12 Personal superannuation contributions (generally for the self-employed)
D13 Deduction for project pool
D14 Forestry managed investment scheme deduction
D15 Other deductions – that is, deductions not claimable at items D1 to D14 or elsewhere on your tax return

TAX OFFSETS
T1 Spouse (without dependent child or student), child‑housekeeper or housekeeper
T2 Senior Australians (includes age pensioners, service pensioners and self-funded retirees)
T3 Pensioner
T4 Australian superannuation income stream
T5 Private health insurance
T6 Education tax refund
Tax offsets from the supplementary section of the tax return
Total tax offsets
Adjustments from the supplementary section of the tax return
Private health insurance policy details

FLOOD LEVY
The Government has introduced a flood levy for the 2011–12 year only, to assist flood affected communities to rebuild essential infrastructure.
The flood levy applies if your taxable income is greater than $50,000 and you do not fit into one of the exemption categories

Pay As You Go (PAYG)

YOUR TAX FILE NUMBER (TFN)
Your TFN is shown on your payment summary, as well as on your last notice of assessment. You do not have to quote your TFN on your tax return, but your assessment may be delayed if you do not. If you are new to the tax system and don’t have a TFN, phone 13 28 61.

 

WHERE TO SEND YOUR TAX RETURN Within Australia
If you decide to lodge a paper tax return, you can use the pre-addressed envelope provided to send it to us, or send it to:

Australian Taxation Office
GPO Box 9845
IN YOUR CAPITAL CITY

Do not replace the words IN YOUR CAPITAL CITY with the name of your capital city and its postcode – they are not needed because of a special agreement with Australia Post.

YOUR RIGHT TO COMPLAIN
If you are dissatisfied with a particular decision we have made, or with one of our services or actions, you have the right to complain.
We recommend that you first try to resolve the issue with the tax officer you have been dealing with, or phone the number you have been given.
If you are not satisfied, talk to the tax officer’s manager.
If you are still not satisfied, phone our complaints line on 1800 199 010.
Other ways to make a complaint:
n go to ‘Contact us’ at ato.gov.au
n write to:
Complaints
Australian Taxation Office
PO Box 1271
Albury NSW 2640
n send a fax to 1800 060 063.

 

Salary or wages
Did you earn income from any of the following where tax was withheld:
- salary and wages
- commissions
-  bonuses
-  income from part-time or casual work
-  parental leave pay
-  foreign employment
-  amounts for lost salary or wages paid under
           – an income protection policy
           – a sickness or accident insurance policy, or
           – a workers compensation scheme?

image

You need your PAYG payment summary – individual non-business and PAYG payment summary – foreign employment.

Completing your tax return
1 Print the type of occupation from which you earned most of your income at item 1.
2 For each payment summary, write at item 1:
- the payer’s Australian business number (ABN) or withholding payer number
-  write the ‘Total Australian tax withheld’ amounts under Tax withheld
- write the gross payment amounts under Income.
- If you have five payment summaries or less, you have finished this question. Otherwise, repeat this step for your first four payment summaries, then go to step 3.
3 For your remaining payment summaries:
- add up the total tax withheld (including total Australian tax withheld for PAYG payment summaries – foreign employment) and write the total under Tax withheld to the left of G
- add up the gross payment amounts (including total gross payment amounts for PAYG payment summaries – foreign employment) and write the total under Income at G
- leave the ABN entry for that line blank.

image

This question is about payments from working such as:
employment allowances
tips, gratuities
consultation fees
payments for voluntary and other services
all payments from which tax was not withheld, such as
– commissions, bonuses
– casual job income
– insurance payments (income protection, sickness and accident policies).
Employment allowances include:
car and travel allowances, and reimbursements of car expenses
award transport payments (paid under an industrial law or award that was in force on 29 October 1986)
tool, clothing and laundry allowances
dirt, height, site, first aid and risk allowances
meal and entertainment allowances.
If you received a travel or overtime meal allowance paid under an industrial agreement, do not show it on your tax return if:
you spent the whole amount on deductible expenses
it was not shown on your payment summary, and
it does not exceed the Commissioner’s reasonable allowance amount.
You cannot claim deductions for the expenses that you paid for with that allowance.

3. Did you receive any lump sum payments from your employer for:

  1. unused annual leave
  2. unused long service leave?

image 
You will need your PAYG payment summary – individual non‑business, PAYG payment summary – foreign employment or a comparable statement from your payer that shows an amount at ‘Lump sum A’ or ‘Lump sum B’.

Completing your tax return
If you do not have amounts shown at ‘Lump sum A’ on your payment summaries, go to step 4 below.
1 Add up the tax withheld from lump sum A amounts shown on your payment summaries.
Write the total under Tax withheld at the left of R item 3.
2. Add up all lump sum A amounts on your payment summaries.
Write the total at R.
3. Print in the TYPE box at R:
R if the amount related to a genuine redundancy payment, an early retirement scheme payment, or the invalidity segment of an employment termination payment or superannuation benefit
T for all other situations.

If you do not have any amounts shown at ‘Lump sum B’ on your payment summaries, you have finished this question.

4. Add up the tax withheld from lump sum B amounts shown on your payment summaries.
Write the total under Tax withheld at the left of H item 3.
5. Add up all lump sum B amounts on your payment summaries. Divide the total by 20. This is because only 5% is taxable.Write the total at H.

4. Employment termination payments

 image
Employment termination payments (ETPs) are payments you received because your employment was terminated. These payments appear on a PAYG payment summary – employment termination payment.
This item also covers:

  • death benefit ETPs
  • foreign ETPs
  • late termination payments
  • transitional termination payments.

    Do not show the following payments anywhere on your tax return:
    1. foreign termination payments
    2. directed termination payments
    3. ETPs you received as the trustee of a deceased estate.

 

Types Description
T if you received a transitional termination payment
S if you received an ETP in 2011–12 that was not a transitional termination payment or a death benefit ETP and you had received another such ETP in an earlier income year for the same termination of employment
D if you received a death benefit ETP and you were a death benefits dependant
B if you received a death benefit ETP in 2011–12 and you were not a death benefits dependant and you had received another death benefit ETP in an earlier income year for the same termination of employment
N if you received a death benefit ETP and you were not a death benefits dependant, and code B does not apply.

5. Australian Government allowances and payments (like newstart, youth allowance and austudy payment)

Did you receive any of the following Australian Government payments:
Newstart allowance
Youth Allowance
Austudy payment
parenting payment (partnered)
partner allowance
sickness allowance
special benefit
widow allowance
exceptional circumstances relief payment
interim income support payment
an education payment of any of the following when you were 16 years old or older
– ABSTUDY living allowance
– payment under the Veterans’ Children Education Scheme
– payment shown as ‘MRCA Education Allowance’ on your payment summary
other taxable Commonwealth education or training payments
an income support component from a Community Development Employment Project (CDEP)
a CDEP scheme participant supplement?

6. Australian Government pensions and allowances
Did you receive any of the following Australian Government payments:
age pension
bereavement allowance
carer payment
disability support pension, if you have reached
age-pension age
education entry payment
parenting payment (single)
widow B pension
wife pension, if either you or your partner was of age-pension age
age service pension
income support supplement
Defence Force income support allowance (DFISA) where the pension, payment or allowance to which it relates is taxable
DFISA-like payment from the Department of Veterans’ Affairs (DVA)
invalidity service pension, if you have reached age‑pension age
partner service pension?

7. Australian annuities and superannuation income streams
Australian annuities (also called non-superannuation annuities) are paid to you by Australian life insurance companies and friendly societies.
Australian superannuation income streams (including lump sum in arrears amounts) are paid to you by Australian superannuation funds, retirement savings account (RSA) providers and life insurance companies.
If you received a ‘taxable Australian superannuation lump sum payment’, do not show it here; show it at item 8.
Did you receive Australian annuities or superannuation income streams?

Sunday, April 14, 2013

Silverlight 5.0

 

When you compile you SL application number of actions are undertaken.

- Your code is verified to be correct.

- Silverlight App is compiled into a DLL. It is the DLL used by silverlight at run time.

These days MSBuild by Microsoft is used to step up the build process. It uses XML model scripts to determine what happens. These scripts contain ordered set of instructions. There are hundreds of predefined tasks. And also you can create your own ones

Actually a visual studio project file (csproj) is really a build script file. It is well formed XML containing build instructions. When you build you application is visual studio it calls MSBuild. MsBuild reads the build instructions and performs the requested build steps. Eventually MSBuild calls the compiler (vbc.exe, csc.exe). The language compiler then compiles the code into executable.

Assemblies

SL apps runs on the client.

A silverlight assembly must be downloaded to the client.

Any assembly you use must be compiled sepcifically for silverlight use.Your company libs, third party .

image

Core assemblies are :

  1. mscorlib.dll
  2. system.dll
  3. system.core.dll
  4. System.Net.dll
  5. System.Windows.dll
  6. System.Windows.Browser.dll
  7. System.xml.dll

Silverlight Add-on Assemblies:

  1. System.Windows.Controls.dll – Tree view, Tab control, date picker, calendar and Grid splitter controls
  2. System.Windows.Controls.Data.dll – DataGrid, DataPager
  3. System.Windows.Controls.Data.Input.dll – Data bound forms, Label, Description viewer, Validation summary
  4. System.Windows.Controls.Input.dll – AutoCompleteTextbox
  5. System.Windows.Controls.Navigation.dll – Frame and Page controls basis of silverlight navigation system.

image

XAML is used to write the code (layout) for silverlight. XAML is used for :

  • Silverlight
  • Windows Phone
  • Windows 8 Metro
  • XPS – XML Paper Specification

XAML is really an XML.
XAML doc is limited to single root element and that root is typically a UserControl element.
Normal XML rules apply to XAML:
    Attributes values must be delimited (“”, ‘ ‘ )
    User proper tag closure (<user></user> or <user />)


XAML elements are mapped to equivalent .NET classes. For example <Button> is an object element in XAML. So using an object element in XAML is same as :

  1. Instantiating an instance of the Button class
  2. Calling the default parameterless constructor.

Attributes:

XAML types has several types of attributes:

  1. Property Attributes: These correspond to object property. For example Width, Height
  2. Event Attributes: These correspond to object events. For example MouseMove
  3. Directive Attributes: These are parser instructions that have no programmatic equivalent. For ex: Assigning a localization ID with x:Uid, x:Name
  4. Attached Property Attributes: For example Grid.RowSpan

XAML Namespaces:

To put groups of elements, it is common to use Namespaces. In XAML using xmlns attrubute we can put elements into a namespace.

Type Converters
These are just like data type casting in .NET.

Markup Extensions

if you need runtime calculation and want that value to be assigned to a property in XAML, then you must use Markup Extensions.

The syntax for markup extension is like :image

Categories of markup Extensions:

  • DataBinding : Get datasource value and assign it to a property.
  • TemplateBinding: get value from a control template and assign to property.
  • StaticResource: Lookup resource defined in ResourceDictionary.
  • Null: Assign null value to a property.
  • Custom: We can create our own markup extension implementing IMarkupExtension interface.

Dependency Properties System:

SL uses a unique property system called Dependency property system. This was invested by WPF team of Microsoft. This new system enhances the underlying .NET framework and promise elements to plugin to useful services like animations, databinding, tempaltes, styles.

Dependency system contains two important parts:
1. Dependency Property
2. Attached Property

image

Creating a dependency property 

Creating a dependency property isn’t difficult, but the syntax takes a little getting used to. It’s
thoroughly different from creating an ordinary .NET property.
The first step is to define an object that represents your property. This is an instance of the
DependencyProperty class (which is found in the System.Windows namespace). The information about your property needs to be available all the time. For that reason, your DependencyProperty object must be defined as a static field in the associated class.
For example, consider the FrameworkElement class from which all Silverlight elements inherit.
FrameworkElement defines a Margin dependency property that all elements share. It’s defined like this:
public class FrameworkElement: UIElement
{
public static readonly DependencyProperty MarginProperty;
...
}

By convention, the field that defines a dependency property has the name of the ordinary property
plus the word Property at the end. That way, you can separate the dependency property definition from the name of the actual property. The field is defined with the readonly keyword, which means it can be set only in the static constructor for the FrameworkElement.

Registering Dependency Property:

Defining the DependencyProperty object is just the first step. For it to become usable, you need to
register your dependency property with Silverlight. This step needs to be completed before any code
uses the property, so it must be performed in a static constructor for the associated class.
Silverlight ensures that DependencyProperty objects can’t be instantiated directly, because the
DependencyProperty class has no public constructor. Instead, a DependencyProperty instance can be
created only using the static DependencyProperty.Register() method. Silverlight also ensures that
DependencyProperty objects can’t be changed after they’re created, because all DependencyProperty
members are read-only. Instead, their values must be supplied as arguments to the Register() method.
The following code shows an example of how a DependencyProperty can be created. Here, the
FrameworkElement class uses a static constructor to initialize the MarginProperty:
static FrameworkElement()
{
MarginProperty = DependencyProperty.Register("Margin",
typeof(Thickness), typeof(FrameworkElement), null);
...
}

image

The DependencyProperty.Register() method accepts the following arguments:
• The property name (Margin in this example).
• The data type used by the property (the Thickness structure in this example).
• The type that owns this property (the FrameworkElement class in this example).
• A PropertyMetadata object that provides additional information. Currently,
Silverlight uses the PropertyMetadata to store just optional pieces of information:
a default value for the property and a callback that will be triggered when the
property is changed. If you don’t need to use either feature, supply a null value, as
in this example.

Attached Property:
An attached property is a full-fledged dependency property, and like all dependency properties, it’s managed by the Silverlight property system. The difference is that an attached property applies to a class other than the one where it’s defined.
The most common example of attached properties is found in the layout containers. For example, the Grid class defines the attached properties Row and Column, which you set on the contained elements to indicate where they should be positioned. Similarly, the Canvas defines the attached properties Left and Top that let you place elements using absolute coordinates.
To define an attached property, you use the DependencyProperty.RegisterAttached() method instead of Register(). Here’s the code from the Grid class that registers the attached Grid.Row property:

RowProperty = DependencyProperty.RegisterAttached("Row", typeof(int), typeof(Grid), null);

Silverlight Panels:

  • Stack Panel
  • Grid
  • Canvas
  • VirtualizingStackPanel (used by List Controls)
  • Wrap Panel
  • Dock Panel

Tip: To jump quickly from XAML to Event handling code, right click the event in xaml and choose Navigate to Event Handler option.

Assembly caching:

By default it is turned off and it can be turned on from Visual Studio project properties.

image 

Silverlight Object Parameters:

Source (required) - A URI that points to XAP file.
onError: A js event handler triggered when unhandled exception occurs.
background
minRuntimeVersion: min version of SL that client must have
autoUpgrade: default is True.
enableHTMLAccess: To access HTML elements within SL code
initParams: string to pass custom initialization information.
splashScreenSource:
windowless: just like transparent
onSourceDownloadProgressChanged:
onSourceDownloadComplete:
onLoad:
onResize'

Binding:

One way Binding:

Element-to-Element Binding
One-Way Binding
To understand how you can bind an element to another element, consider the simple window shown in Figure.
image
It contains two controls: a Slider and a TextBlock with a single line of text. If you pull the thumb in the slider to the right, the font size of the text is increased immediately. If you pull it to the left, the font size is reduced.

Clearly, it wouldn’t be difficult to create this behavior using code. You would simply react to the
Slider.ValueChanged event and copy the current value from the slider to the TextBlock. However, data binding makes it even easier. When using data binding, you don’t need to make any change to your source object (which is the Slider in this example). Just configure it to take the right range of values, as you would ordinarily.
<Slider x:Name="sliderFontSize" Margin="3" Minimum="1" Maximum="40" Value="10">
</Slider>

The binding is defined in the TextBlock element. Instead of setting the FontSize using a literal value, you use a binding expression, as shown here:
<TextBlock Margin="10" Text="Simple Text" x:Name="lblSampleText" FontSize="{Binding ElementName=sliderFontSize, Path=Value}" >
</TextBlock>

Data binding expressions use a XAML markup extension (and hence have curly braces). You begin with the word Binding, followed by any constructor arguments (there are none in this example) and then a list of the properties you want to set by name—in this case, ElementName and Path. ElementName indicates the source element. Path indicates the property in the source element. Thus, this binding expression copies the value from the Slider.Value property to the TextBlock.FontSize property.

Tip: The Path can point to a property of a property (for example, FontFamily.Source) or an indexer used by a property (for example, Content.Children[0]). You can also refer to an attached property (a property that’s defined in another class but applied to the bound element) by wrapping the property name in parentheses. For example, if you’re binding to an element that’s placed in a Grid, the path (Grid.Row) retrieves the row number where you’ve placed it.

One of the neat features of data binding is that your target is updated automatically, no matter how
the source is modified. In this example, the source can be modified in only one way—by the user’s
interaction with the slider thumb. However, consider a slightly revamped version of this example that adds a few buttons, each of which applies a preset value to the slider. Click one of these buttons, and this code runs:
private void cmd_SetLarge(object sender, RoutedEventArgs e)
{
   sliderFontSize.Value = 30;
}
This code sets the value of the slider, which in turn forces a change to the font size of the text
through data binding. It’s the same as if you had moved the slider thumb yourself.
However, this code wouldn’t work as well:
private void cmd_SetLarge(object sender, RoutedEventArgs e)
{
lblSampleText.FontSize = 30;
}
It sets the font of the text box directly. As a result, the slider position isn’t updated to match. Even
worse, this has the effect of wiping out your font size binding and replacing it with a literal value. If you move the slider thumb now, the text block won’t change at all.

Two way Binding:

Interestingly, there’s a way to force values to flow in both directions: from the source to the target and from the target to the source. The trick is to set the Mode property of the Binding. Here’s a revised bidirectional binding that allows you to apply changes to either the source or the target and have the other piece of the equation update itself automatically:

<TextBlock Margin="10" Text="Simple Text" Name="lblSampleText"
FontSize="{Binding ElementName=sliderFontSize, Path=Value, Mode=TwoWay}" >
</TextBlock>

In this example, there’s no reason to use a two-way binding, because you can solve the problem by manipulating the value of the slider rather than changing the font size of the TextBlock. However, consider a variation of this example that includes a text box where the user can set the font size precisely.

image

Here, the text box needs to use a two-way binding, because it both receives the bound data value
and sets it. When the user drags the slider (or clicks a button), the text box receives the new slider value.And when the user types a new value in the text box, the binding copies the value to the slider.Here’s the two-way binding expression you need:
<TextBox Text="{Binding ElementName=lblSampleText, Path=FontSize, Mode=TwoWay}">
</TextBox>

TIP: If you experiment with this example, you’ll discover that the text box applies its value to the slider only once it loses focus. This is the default update behavior in Silverlight, but you can change it by forcing immediate updates as the user types.

When setting margins, you can set a single width for all sides, like this:
<Button Margin="5" Content="Button 3"></Button>
Alternatively, you can set different margins for each side of a control in the order left, top, right,
bottom:
<Button Margin="5,10,5,10" Content="Button 3"></Button>
In code, you can set margins using the Thickness structure:
cmd.Margin = new Thickness(5);

TIP: If you want to divide the remaining space unequally, you can assign a weight, which you must place before the asterisk. For example, if you have two proportionately sized rows and you want the first to be half as high as the second, you could share the remaining space like this:
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
This tells the Grid that the height of the second row should be twice the height of the first row. You
can use whatever numbers you like to portion out the extra space.

Tip: Remember, if a Grid has just a single row or column, you can leave out the RowDefinitions section. Also, elements that don’t have their row position explicitly set are assumed to have a Grid.Row value of 0 and are placed in the first row. The same holds true for elements that don’t supply a Grid.Column value.

An event handler that responds to a button press by switching into full-screen mode:
private void Button_Click(object sender, RoutedEventArgs e)
{
   Application.Current.Host.Content.IsFullScreen = true;
}

Tuesday, April 9, 2013

Moq Framework for Unit Testing

 

 

Properties of a good Unit Test

  1. Atomic : A unit test should test a small piece of functionality
  2. Deterministic : A unit test should always either pass or fail.
  3. Repeatable: A test is repeatable when it passes consitently. If a test passes and fails without changing the test or any of the dependent code is not repeatable.
  4. Order independent and Isolated – A test should not be dependent on any other test.
  5. Fast: if a test is taking 1 second to run it is slow. It should take milisecond.
  6. Easy to Setup

 

image

A mocking framework replaces these dependencies with Fake copies of dependencies:

image

Hand rolled Mock Objects:

Fake implementations of abstractions

Used to verify class interactions in automated tests.

Created by hand writing code

Creating hand rolled mocks:

  1. Basic class
  2. Implement the dependency interface type
  3. Flush out the dependency functionality needed
    1. Return Values
    2. Exception throwing
    3. “was it called?”
    4. “How many times it called?”

AAA Syntax (Arrange Act and Assert)

Arrange

Create a mock object

Act

Execute the SUT (System under test)

Assert

Verify SUT’s interaction with the mock object

Saturday, April 6, 2013

Thunderbird - setting an email account

Once you install Mozilla Thunderbird you can set your email account.

0. Open Thunderbird and cancel whatever is coming.
1. Go to Tools menu -> Account Settings  (If tools menu is not visible press Alt +T)
2. Click Account Actions -> Add Email Account

3. Put your credentials here and press continue.

4. Press Manual Config (dont worry if it is still precessing. just click on Manual config button) and do the following setting:

5. Press Re-test button and wait till following message comes:

6. Press done once and let it do check password checking.
7. Finally your inbox is downloading your emails.
8. You can attach your number of email accounts this way by doing the same process.
Even Yahoo, gmail can be done this way.