Files
Kalana B. Thilakarathna b992d07689 feat: add supplier payment and allocation models, API, and frontend components
- Created `SupplierPayment` and `SupplierPaymentGRN` models for managing supplier payments and their allocations.
- Implemented API endpoints for listing and creating supplier payments.
- Developed frontend components for displaying and recording supplier payments, including a dialog for payment creation.
- Integrated GRN allocations into the payment creation process, ensuring total allocations match the payment amount.
- Added pagination and loading states for the payments list.
2026-10-19 21:36:01 +05:30

27 lines
941 B
C#

using Microsoft.AspNetCore.Mvc;
namespace Distribution.Features.SupplierPayment;
[ApiController]
[Route("api/suppliers/{supplierId:guid}/payments")]
public class SupplierPaymentController(SupplierPaymentService service) : ControllerBase
{
[HttpGet]
public async Task<IActionResult> List(Guid supplierId, [FromQuery] int page = 1, [FromQuery] int pageSize = 20)
{
var result = await service.ListBySupplierAsync(supplierId, page, pageSize);
return result is null ? NotFound() : Ok(result);
}
[HttpPost]
public async Task<IActionResult> Create(Guid supplierId, CreateSupplierPaymentRequest request, CancellationToken ct)
{
try
{
var result = await service.CreateAsync(supplierId, request, ct);
return result is null ? NotFound() : Ok(result);
}
catch (InvalidOperationException ex) { return BadRequest(new { error = ex.Message }); }
}
}