New source control repo for Biskilog POS - secure hub to store & manage source code. Streamlines dev process, tracks changes, & improves collaboration. Ensures reliable software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

101 lines
3.7 KiB

using Biskilog_Accounting.Shared.CustomModels;
using Biskilog_Accounting.Shared.Interfaces;
using Biskilog_Accounting.Shared.POSModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
using NuGet.Common;
namespace Biskilog_Accounting.Server.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AnalyticsController : ControllerBase
{
private readonly IAnalytics m_analyticService;
public AnalyticsController(IAnalytics a_analytics)
{
m_analyticService = a_analytics;
}
/// <summary>
/// Endpoint to return analysis on CancelledSales within a specified period
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("cancelledsales/{a_start}/{a_end}")]
public IEnumerable<CancelledSales> GetCancelledSalesAsync(DateTime a_start, DateTime a_end)
{
return m_analyticService.GetCancelledSales(a_start, a_end);
}
/// <summary>
/// Endpoint to return analysis on Sales within a specified period
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("sales/{a_start}/{a_end}")]
public IEnumerable<Tblcart> GetSalesAsync(DateTime a_start, DateTime a_end)
{
return m_analyticService.GetSalesTransaction(a_start, a_end);
}
/// <summary>
/// Endpoint to return analysis on in-debt customers
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("debtors")]
public IEnumerable<InDebtCustomers> GetInDebtCustomers()
{
return m_analyticService.GetInDebtCustomers();
}
/// <summary>
/// Endpoint to return analysis on product price changes
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("pricechanges/{a_start}/{a_end}")]
public IEnumerable<ProductPriceChange> GetPriceChanges(DateTime a_start, DateTime a_end)
{
return m_analyticService.GetPriceChanges(a_start, a_end);
}
/// <summary>
/// Endpoint to return analysis on sales by employees
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("employeesales/{a_start}/{a_end}")]
public Dictionary<string, List<SaleItem>> GetEmployeeSales(DateTime a_start, DateTime a_end)
{
return m_analyticService.GetEmployeeSales(a_start, a_end);
}
/// <summary>
/// Endpoint to return analysis on product items low on stock
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("lowonstock")]
public IEnumerable<ProductItem> GetLowOnStockItems()
{
string token = Request.Headers[HeaderNames.Authorization]!;
return m_analyticService.GetOutOfStockItems();
}
/// <summary>
/// Endpoint to return analysis on the most purchased product item
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("mostpurchaseditem/{a_start}/{a_end}")]
public IEnumerable<MostPurchasedItem> GetMostPurchased(DateTime a_start, DateTime a_end)
{
return m_analyticService.GetMostPurchasedItem(a_start, a_end);
}
}
}