@using Indotalent.Features.Purchase.PaymentDisburse.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject PaymentDisburseService PaymentDisburseService @inject ISnackbar Snackbar
Add Payment Disburse Process payment to vendor for an existing bill.
Basic Information Payment Date Bill Reference @foreach (var item in _lookup.Bills) { @item.Name } Payment Method @foreach (var item in _lookup.PaymentMethods) { @item.Name } Status @foreach (var item in _lookup.Statuses) { @item.Name } Payment Amount Vendor Description <_PaymentDisburseItemDataTable Items="_items" /> Bill Commercial Summary
Sub Total @_billSubTotal.ToString("N2")
Tax Amount @_billTax.ToString("N2")
Grand Total @_billGrandTotal.ToString("N2")
Cancel @if (_processing) { Processing... } else { Process Disburse }
@code { [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private CreatePaymentDisburseRequest _model = new() { PaymentDate = DateTime.Today, Status = Indotalent.Data.Enums.PaymentDisburseStatus.Draft }; private PaymentDisburseLookupResponse _lookup = new(); private List _items = new(); private string _vendorName = ""; private decimal _billSubTotal = 0; private decimal _billTax = 0; private decimal _billGrandTotal = 0; private bool _processing = false; protected override async Task OnInitializedAsync() { var res = await PaymentDisburseService.GetPaymentDisburseLookupAsync(); if (res != null && res.IsSuccess) _lookup = res.Value ?? new(); } private async Task OnBillChanged(string billId) { _model.BillId = billId; if (string.IsNullOrEmpty(billId)) { ResetBillData(); return; } var res = await PaymentDisburseService.GetBillDetailForPaymentAsync(billId); await Task.Delay(500); if (res != null && res.IsSuccess && res.Value != null) { _items = res.Value.Items; _vendorName = res.Value.VendorName ?? ""; _billSubTotal = res.Value.PurchaseOrderBeforeTaxAmount; _billTax = res.Value.PurchaseOrderTaxAmount; _billGrandTotal = res.Value.PurchaseOrderAfterTaxAmount; _model.PaymentAmount = res.Value.PaymentAmount; Snackbar.Add($"Bill {res.Value.BillNumber} items loaded.", Severity.Info); } } private void ResetBillData() { _items.Clear(); _vendorName = ""; _billSubTotal = 0; _billTax = 0; _billGrandTotal = 0; _model.PaymentAmount = 0; } private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await PaymentDisburseService.CreatePaymentDisburseAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Payment recorded successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }