87c807c16c
- Implemented ChequeBooksPage for viewing and filtering cheque books. - Added NewReceivedChequePage for recording received cheques. - Created ReceivedChequesPage for listing and managing received cheques. - Introduced API endpoints for bank accounts, cheque books, and received cheques. - Defined types for payments including bank accounts, cheque books, and received cheques.
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Distribution.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.ReceivedCheque;
|
|
|
|
[ApiController]
|
|
[Route("api/received-cheques")]
|
|
public class ReceivedChequeController(ReceivedChequeService service) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> List(
|
|
[FromQuery] int? companyId,
|
|
[FromQuery] int? branchId,
|
|
[FromQuery] ReceivedChequeStatus? status,
|
|
[FromQuery] ReceivedFromType? receivedFromType,
|
|
[FromQuery] int page = 1,
|
|
[FromQuery] int pageSize = 50)
|
|
=> Ok(await service.ListAsync(companyId, branchId, status, receivedFromType, page, pageSize));
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create(CreateReceivedChequeRequest request, CancellationToken ct)
|
|
{
|
|
try { return Ok(await service.CreateAsync(request, ct)); }
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
|
|
[HttpPut("{id:guid}/status")]
|
|
public async Task<IActionResult> UpdateStatus(Guid id, UpdateReceivedChequeStatusRequest request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var result = await service.UpdateStatusAsync(id, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
|
|
}
|
|
}
|