對於使用 Asana 時程表和預算功能的組織,定期報告對於準確的會計和薪資管理至關重要。雖然 Asana 提供強大的應用程式內檢視,但您偶爾可能需要在月底或季度末匯出整個網域中所有時間紀錄的完整 CSV,以便進行外部稽核或自訂處理。
本文說明如何使用 Asana API 彙總整個工作空間的時間記錄,並將其格式化為符合您內部要求的、整潔且可供會計使用的 CSV 檔案。
注意
雖然本指南是為時程表和預算附加元件的使用者量身打造,但此基於 API 的匯出方法也適用於透過標準 Asana 任務欄位記錄時間的非附加元件使用者。
雖然 Asana 使用者介面提供強大的儀表板,但透過應用程式開發介面 (API) 進行匯出可讓您做到:
為確保與標準會計慣例相容,您的匯出指令碼應產生一個 CSV 檔案,其中包含您的審核者檢視匯出中顯示的以下欄位:
欄 | 描述 |
任務名稱 | 已記錄時間的任務標題。 |
時間 (小時) | 總持續時間從分鐘轉換為小數小時。 |
日期 | 執行工作的具體日期。 |
提交者 | 時間記錄者的團隊成員姓名。 |
任務 GID | Asana 任務的唯一識別碼。 |
專案 GID | 上層專案的唯一識別碼。 |
任務狀態 | 任務目前是「未完成」還是「已完成」。 |
紀錄 GID | 特定時間記錄的唯一識別碼。 |
若要匯出「所有」時間,您的指令碼必須迭代您的專案以尋找任務,然後使用Get time tracking entries for a task端點擷取這些任務的時間項目。
Python
匯入 Asana
匯入 pandas as pd# 初始化用戶端 client = asana.Client.access_token('YOUR_PERSONAL_ACCESS_TOKEN')workspace_gid = 'YOUR_WORKSPACE_GID'def export_domain_time():all_time_data = []
# 1. 迭代工作空間中的所有專案projects = client.projects.get_projects({'workspace': workspace_gid})針對專案中的專案:# 2. 取得專案中的所有任務tasks = client.tasks.get_tasks_for_project(project['gid'], opt_fields=['name', 'gid', 'completed', 'completed_at', 'priority'])
for task in tasks:# 3. 取得每個任務的時間記錄time_entries = client.time_tracking_entries.get_time_tracking_entries_for_task(task['gid'],
opt_fields=['created_by.name', 'duration_minutes', 'entered_on', 'gid'])
for entry in time_entries:# 以小數格式計算時數hours = round(entry['duration_minutes'] / 60, 2)# 建立與 CSV 範本相符的列all_time_data.append({"任務名稱": task['name'],"Time (hours)": hours,"Date": entry['entered_on'],"提交者": entry['created_by']['name'],"任務 GID": task['gid'],"專案 GID": project['gid'],"Task Status": "已完成" if task['completed'] else "未完成","任務完成日期": task.get('completed_at', ''),"任務優先順序": task.get('priority', ''),"記錄 GID": entry['gid']})
# 4. 將資料儲存為 CSV 檔df = pd.DataFrame(all_time_data)df.to_csv('asana_time_export_accounting.csv', index=False)print("匯出已完成:asana_time_export_accounting.csv")
export_domain_time()
為整個組織執行此匯出時,請謹記以下最佳作法:
注意
This article has been AI-translated.
Send translation feedback.

These cookies are strictly necessary to provide you with certain features. For example, these cookies allow you to access secure areas that require registration and set your privacy preferences. Because these cookies are essential to providing services to you, they cannot be disabled. You can set your browser to block or alert you about these cookies, but it may cause some parts of the site to not work.
Third party trackers collect information used for analytics and to personalize your experience with targeted ads. Under the Virginia Consumer Data Protection Act, you have the right to opt-out of the sale of your personal data to third parties. You also have the right to opt out of targeted advertising related processing. You may exercise your right to opt out of the sale of personal data and targeted advertising by using this toggle. If you opt out, we will not be able to offer you personalized ads and we will stop sharing your personal information with third parties. For more information please see our Privacy Statement.
These cookies allow us or our third-party analytics providers to collect information and statistics on use of our services by you and other visitors. This information helps us to improve our services and products for the benefit of you and others.
These cookies, provided by our third-party advertising partners, collect information about your browsing habits, as well as your preferences for various features and services. They also provide us with auditing, research, and reporting to know when advertising content has been displayed and how successful the content has been. This information allows us and our third-party advertising providers to display relevant advertising content.
These cookies provide enhanced functionality, providing chat support, allowing you to more easily complete forms, personalizing content to your preferences, and selecting your communications preferences. If you do not enable these cookies, or choose to disable them in the future, that could impact your ability to use certain features.