cmd

package
v0.0.0-...-dbe7189 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdCalculateTax = &cobra.Command{
	Use:   "tax",
	Short: "Calculate tax",
	Long:  `A fast income tax calulator for Australians, written in Go by Toby Scott.`,
	Run: func(cmd *cobra.Command, args []string) {

		questions := []*survey.Question{
			{
				Name:   "GrossAnnualSalary",
				Prompt: &survey.Input{Message: "Your annual salary (eg. 65000 = $65,000)", Default: os.Getenv("PFC_GROSS_SALARY")},
			},
			{
				Name:   "SalarySacrificePercent",
				Prompt: &survey.Input{Message: "How much are you salary sacrificing? (eg. 10 = 10%)", Default: os.Getenv("PFC_SALARY_SACRIFICE_PERCENTAGE")},
			},
			{
				Name:   "HasHecsHelpDebt",
				Prompt: &survey.Confirm{Message: "Do you have a HECS/HELP debt?", Default: os.Getenv("PFC_HAS_HELP_DEBT") == "true"},
			},
			{
				Name:   "HasPrivHealthCover",
				Prompt: &survey.Confirm{Message: "Do you have private health insurance?", Default: os.Getenv("PFC_HAS_PRIVATE_HEALTH_COVER") == "true"},
			},
			{
				Name:   "Single",
				Prompt: &survey.Confirm{Message: "Are you single? (not married or in a de facto relationship)", Default: os.Getenv("PFC_SINGLE") == "true"},
			},
			{
				Name:   "NumberOfDependants",
				Prompt: &survey.Input{Message: "How many dependants do you have?", Default: os.Getenv("PFC_NUMBER_OF_DEPENDANTS")},
			},
			{
				Name:   "SaptoEligible",
				Prompt: &survey.Confirm{Message: "Are you eligible for the seniors and pensioners tax offset (SAPTO)?", Default: os.Getenv("PFC_SAPTO_ELIGIBLE") == "true"},
			},
		}

		answers := struct {
			GrossAnnualSalary      int
			SalarySacrificePercent int
			HasHecsHelpDebt        bool
			HasPrivHealthCover     bool
			Single                 bool // Does not have a spouse (married or de facto)
			NumberOfDependants     int
			SaptoEligible          bool // Are you eligible for the seniors and pensioners tax offset (SAPTO)?
		}{}

		err := survey.Ask(questions, &answers)
		if err != nil {
			fmt.Println(err)
			return
		}

		salarySacrificeAmount := answers.GrossAnnualSalary * answers.SalarySacrificePercent / 100
		taxableIncome := helpers.CalcTaxableIncome(answers.GrossAnnualSalary, answers.SalarySacrificePercent)
		incomeTax := helpers.CalcIncomeTax(float64(taxableIncome))
		hecsRepaymentRate := helpers.CalcHecsHelpRepaymentRate(answers.GrossAnnualSalary)
		hecsRepaymentAmount := float64(answers.GrossAnnualSalary) * hecsRepaymentRate
		paysMedicareLevySurcharge := helpers.PaysMedicareLevySurcharge(float64(taxableIncome), answers.Single, answers.HasPrivHealthCover)
		medicareLevy := helpers.CalcMedicareLevy(float64(taxableIncome), answers.Single, paysMedicareLevySurcharge)

		fmt.Println("=====================================")
		fmt.Printf("Your gross annual salary is %s\n", helpers.FormatAsCurrency(float64(answers.GrossAnnualSalary)))
		fmt.Printf("You are salary sacrificing %s (%d%%)\n", helpers.FormatAsCurrency(float64(salarySacrificeAmount)), answers.SalarySacrificePercent)
		fmt.Printf("Your taxable income is %s\n", helpers.FormatAsCurrency(float64(taxableIncome)))
		fmt.Println("=====================================")
		fmt.Printf("Your income tax is %s\n", helpers.FormatAsCurrency(float64(incomeTax)))
		fmt.Printf("Your medicare levy is %s\n", helpers.FormatAsCurrency(float64(medicareLevy)))
		if answers.HasHecsHelpDebt {
			fmt.Printf("You have a HELP/HECS debt, your HECS repayment is %s (%s%% of %s)\n", helpers.FormatAsCurrency(float64(hecsRepaymentAmount)), (helpers.FormatAsCurrency(float64(hecsRepaymentRate * 100))), helpers.FormatAsCurrency(float64(answers.GrossAnnualSalary)))
		}
		fmt.Println("=====================================")
		fmt.Printf("Total going to the ATO: %s\n", helpers.FormatAsCurrency(float64(incomeTax+medicareLevy+hecsRepaymentAmount)))
		fmt.Printf("Salary sacrifice amount: %s\n", helpers.FormatAsCurrency(float64(salarySacrificeAmount)))
		fmt.Printf("Total take home pay: %s\n", helpers.FormatAsCurrency(float64(float64(answers.GrossAnnualSalary)-(incomeTax+medicareLevy+hecsRepaymentAmount)-float64(salarySacrificeAmount))))
		fmt.Println("=====================================")
	},
}
View Source
var CmdFirstHomeCalculator = &cobra.Command{
	Use:   "firsthome",
	Short: "First Home Calculator for Victorians",
	Long:  `Calculate stamp duty, grants, and concessions for first home buyers in Victoria.`,
	Run: func(cmd *cobra.Command, args []string) {

		questions := []*survey.Question{
			{
				Name:   "GrossAnnualSalary",
				Prompt: &survey.Input{Message: "Your annual salary (eg. 65000 = $65,000)", Default: os.Getenv("PFC_GROSS_SALARY")},
			},
			{
				Name: "PropertyCost",
				Prompt: &survey.Input{
					Message: "What is the cost of the property?",
					Default: "600000",
				},
			},
			{
				Name: "PropertyType",
				Prompt: &survey.Select{
					Message: "Is the property new or established?",
					Options: []string{"New", "Established"},
					Default: "Established",
				},
			},
			{
				Name: "FirstHome",
				Prompt: &survey.Confirm{
					Message: "Is this your first home?",
					Default: true,
				},
			},
			{
				Name: "PrincipalResidence",
				Prompt: &survey.Confirm{
					Message: "Do you intend to live in the property as your principal place of residence?",
					Default: true,
				},
			},
		}

		answers := struct {
			PropertyCost       float64
			PropertyType       string
			GrossAnnualSalary  float64
			FirstHome          bool
			PrincipalResidence bool
		}{}

		err := survey.Ask(questions, &answers)
		if err != nil {
			fmt.Println(err)
			return
		}

		stampDuty := fhhelpers.CalculateStampDuty(answers.PropertyCost, answers.PropertyType, answers.FirstHome)
		grant := fhhelpers.CalculateGrant(answers.PropertyCost, answers.PropertyType, answers.FirstHome)
		fhbgEligible := fhhelpers.IsFHBGEligible(answers.GrossAnnualSalary)
		fhsssContribution := fhhelpers.CalculateFHSSS(answers.GrossAnnualSalary)

		fmt.Println("=====================================")
		fmt.Printf("Cost of the property: %s\n", helpers.FormatAsCurrency(answers.PropertyCost))
		fmt.Printf("Type of property: %s\n", answers.PropertyType)
		fmt.Printf("Stamp Duty payable: %s\n", helpers.FormatAsCurrency(stampDuty))
		fmt.Printf("First Home Owner Grant: %s\n", helpers.FormatAsCurrency(grant))
		fmt.Println("=====================================")
		if fhbgEligible {
			fmt.Println("You are eligible for the First Home Buyer Grant (FHBG).")
		}
		if fhsssContribution > 0 {
			fmt.Printf("You can salary sacrifice %s this year for the FHSSS.\n", helpers.FormatAsCurrency(fhsssContribution))
		}
		fmt.Println("=====================================")
	},
}

Functions

func StartPFC

func StartPFC()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL