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