Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save confluencepoint/81a9b3aa56df651971757afe1f15f321 to your computer and use it in GitHub Desktop.

Select an option

Save confluencepoint/81a9b3aa56df651971757afe1f15f321 to your computer and use it in GitHub Desktop.
Findet alle heutigen Events des Kalenders "Nachhilfe" und bucht einen entsprechenden Bargeldumsatz in MoneyMoney.
#!/usr/bin/osascript
set today_midnight to ((current date) - 3600 * (hours of (current date)) - 60 * (minutes of (current date)) - (seconds of (current date)))
set now to (current date)
-- Heutige Events
tell application "Calendar"
tell calendar "Nachhilfe"
set todays_events to every event whose start date is greater than or equal to today_midnight ¬
and start date is less than or equal to now
end tell
if todays_events is not equal to "" then
repeat with current_event in todays_events
-- Variablen
set begin_date to start date of current_event
set end_date to end date of current_event
set end_date_string to end_date as string
set event_name to summary of current_event as string
-- Ermittle den Betrag: 15€/60min
set begin_time to time of begin_date
set end_time to time of end_date
set betrag to (15 * (end_time - begin_time) / 3600) as integer
-- Buche nun einen Umsatz:
my buchebargeldumsatz(end_date_string, event_name, betrag)
end repeat
end if
end tell
-- Erstellt Bargeld-Umsatz für Nachhilfe-Event
on buchebargeldumsatz(end_date_string, event_name, betrag)
tell application "MoneyMoney"
add transaction to account "Bargeld" on date (end_date_string) to (event_name) amount (betrag) purpose "Nachhilfe" category "Nachhilfe"
end tell
end buchebargeldumsatz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment