using IdokladSdk.Enums;
using Microsoft.AspNetCore.Mvc;
using Idoklad.Services;
namespace Idoklad.Controllers;
/// Agenda statistics and summaries. Requires iDoklad credentials.
[ApiController]
[Route("statistics")]
[Produces("application/json")]
[Tags("Statistics")]
public sealed class StatisticsController : ControllerBase
{
private readonly StatisticsService _service;
public StatisticsController(StatisticsService service) => _service = service;
/// Invoicing totals for a relative period (e.g. LastSevenDays, ThisMonth).
[HttpGet("invoicing-for-period/{periodType}")]
public async Task InvoicingForPeriod(PeriodType periodType, CancellationToken ct)
=> Ok(await _service.InvoicingForPeriodAsync(periodType, ct));
/// Invoicing totals for a relative year (e.g. ThisYear, LastYear).
[HttpGet("invoicing-for-year/{yearType}")]
public async Task InvoicingForYear(YearType yearType, CancellationToken ct)
=> Ok(await _service.InvoicingForYearAsync(yearType, ct));
/// Invoicing summary broken down by quarter.
[HttpGet("quarter-summary")]
public async Task QuarterSummary(CancellationToken ct)
=> Ok(await _service.QuarterSummaryAsync(ct));
/// Top partners by turnover (optionally limited by count).
[HttpGet("top-partners")]
public async Task TopPartners([FromQuery] int? count, CancellationToken ct)
=> Ok(await _service.TopPartnersAsync(count, ct));
/// Overall agenda summary (totals and key figures).
[HttpGet("agenda-summary")]
public async Task AgendaSummary(CancellationToken ct)
=> Ok(await _service.AgendaSummaryAsync(ct));
/// Statistics for a single contact by id.
[HttpGet("contact/{id:int}")]
public async Task StatisticForContact(int id, CancellationToken ct)
=> Ok(await _service.StatisticForContactAsync(id, ct));
/// Receivables broken down by debt age intervals.
[HttpGet("debt-intervals")]
public async Task DebtIntervals(CancellationToken ct)
=> Ok(await _service.DebtIntervalsAsync(ct));
/// Top debtors by outstanding amount (optionally limited by count).
[HttpGet("top-debtors")]
public async Task TopDebtors([FromQuery] int? count, CancellationToken ct)
=> Ok(await _service.TopDebtorsAsync(count, ct));
/// Progress of the agenda towards the VAT-payer registration threshold.
[HttpGet("vat-payer-progress")]
public async Task VatPayerProgress(CancellationToken ct)
=> Ok(await _service.VatPayerProgressAsync(ct));
}