Filing expenses into Australian financial years

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

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"
deanpribetic
 
Posts: 3
Joined: Wed Jul 06, 2016 10:12 pm

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.
Mr_Noodle
Site Admin
 
Posts: 8235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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!
deanpribetic
 
Posts: 3
Joined: Wed Jul 06, 2016 10:12 pm

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?
Rug664
 
Posts: 8
Joined: Sun Aug 18, 2013 7:20 am

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.
Mr_Noodle
Site Admin
 
Posts: 8235
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Tips & Tricks - DO NOT POST QUESTIONS

cron