get_current_quarter_deals
Retrieve CRM deals for the current quarter using automatic date calculation, with options to filter by status, salesperson, and result limits.
Instructions
Get deals for the current quarter with date context (automatically uses correct quarter based on today's date)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Filter by deal status (default: all_not_deleted) | |
| user_id | No | Filter by specific user/salesperson | |
| limit | No | Max number of deals to return (default: 50) |
Implementation Reference
- src/pipedrive-client.ts:612-674 (handler)The handler implementation for get_current_quarter_deals in PipedriveClient class. It fetches deals and performs client-side filtering by date to ensure they belong to the current quarter.
async getCurrentQuarterDeals(params?: { status?: 'all_not_deleted' | 'open' | 'won' | 'lost'; user_id?: number; limit?: number; }): Promise<PipedriveResponse<any[]>> { const now = new Date(); const year = now.getFullYear(); const month = now.getMonth() + 1; // Determine current quarter dates let startDate: string, endDate: string; if (month >= 1 && month <= 3) { startDate = `${year}-01-01`; endDate = `${year}-03-31`; } else if (month >= 4 && month <= 6) { startDate = `${year}-04-01`; endDate = `${year}-06-30`; } else if (month >= 7 && month <= 9) { startDate = `${year}-07-01`; endDate = `${year}-09-30`; } else { startDate = `${year}-10-01`; endDate = `${year}-12-31`; } // Get deals within current quarter date range const response = await this.handleRequest<Deal[]>( this.client.get('/deals', { params: { ...params, start: 0, limit: Math.min(params?.limit || 50, 100), // Note: Pipedrive API filtering by date might need to be done client-side } }) ); // Filter deals by current quarter (client-side filtering since Pipedrive API date filtering is limited) if (response.success && response.data) { const quarterDeals = response.data.filter(deal => { if (!deal.add_time) return false; const dealDate = new Date(deal.add_time).toISOString().split('T')[0]; return dealDate >= startDate && dealDate <= endDate; }); return { ...response, data: quarterDeals, additional_data: { ...response.additional_data, quarter_filter: { start_date: startDate, end_date: endDate, quarter: `Q${Math.ceil(month / 3)} ${year}`, total_filtered: quarterDeals.length, original_count: response.data.length } } as any }; } return response; } - src/tools/quarterly.ts:4-25 (schema)The schema and definition for the get_current_quarter_deals tool.
{ name: 'get_current_quarter_deals', description: 'Get deals for the current quarter with date context (automatically uses correct quarter based on today\'s date)', inputSchema: { type: 'object', properties: { status: { type: 'string', enum: ['all_not_deleted', 'open', 'won', 'lost'], description: 'Filter by deal status (default: all_not_deleted)', }, user_id: { type: 'number', description: 'Filter by specific user/salesperson', }, limit: { type: 'number', description: 'Max number of deals to return (default: 50)', }, }, }, },