Files
ERP_Distribution/Distribution/Features/ReceivedCheque/ReceivedChequeController.cs
T
Kalana B. Thilakarathna 87c807c16c
CI/CD - ERP Distribution / Build & Deploy Backend (pull_request) Failing after 11m8s
CI/CD - ERP Distribution / Build & Deploy Frontend (pull_request) Failing after 14m49s
feat: add cheque books and received cheques management
- 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.
2026-10-19 16:09:05 +05:30

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 }); }
}
}