Page 1 of 1

Filing expenses into Australian financial years

PostPosted: Wed Jul 06, 2016 10:15 pm
by deanpribetic
The Australian financial year goes from 1 July through to 30 June. This makes it somewhat complicated to use Hazel to file into those years.

I noticed I could use an embedded AppleScript as a condition in Hazel and started fooling around.

The script is:

Code: Select all
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"-"}

tell application "Finder"
   set filename to name of theFile
end tell

set expenseYear to (first text item of filename) as number
set expenseMonth to (second text item of filename) as number

-- Get the last two characters of the Year
set AppleScript's text item delimiters to savedDelimiters
set lastTwoCharactersOfYear to (characters 3 thru 4 of (expenseYear as text))
set financialYear to (lastTwoCharactersOfYear as text) as number


if expenseMonth ≥ 7 then
   set financialYear to financialYear + 1
end if


set returnText to "FY" & financialYear

-- Note: the order of the hazelOutputAttributes list needs to match the order of the outputAttributes in Hazel
return {hazelOutputAttributes:{returnText}, hazelPassesScript:true}


I also set up an output attribute on the embedded script called financialYear.

The script passes back the financial year to Hazel and then uses that to sort into subfolders with the form "FYXX"

Re: Filing expenses into Australian financial years

PostPosted: Thu Jul 07, 2016 11:03 am
by Mr_Noodle
I'm wondering if you can get the same effect by adjusting the date by -6 months (or is it +6 months?). Something to play with anyways.

Re: Filing expenses into Australian financial years

PostPosted: Thu Jul 07, 2016 10:26 pm
by deanpribetic
Mr_Noodle wrote:I'm wondering if you can get the same effect by adjusting the date by -6 months (or is it +6 months?). Something to play with anyways.


Oh wow! You are totally right…Date Adjust the matched date by +6 months and then use the last two digits of the date concatenated after the string "FY".

So much easier…thanks!

Re: Filing expenses into Australian financial years

PostPosted: Tue Aug 06, 2019 7:50 am
by Rug664
I just found this and it is something that I am currently looking it.

I was wondering what you meant by "adjusting the date"? Do you mean within Hazel or within the AppleScript?

Re: Filing expenses into Australian financial years

PostPosted: Tue Aug 06, 2019 11:04 am
by Mr_Noodle
Within Hazel. When you include a date in your pattern, you can click on it. A menu will appear with different options, including one to adjust the date.