You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
201 lines
8.2 KiB
Plaintext
201 lines
8.2 KiB
Plaintext
@page "/brmaintenance/invtycorrection"
|
|
@using KWWebInvApp.Data;
|
|
|
|
@inject IDialogService DialogService;
|
|
@inject UserServices userService;
|
|
|
|
<PageTitle>Branch Inventory Correction</PageTitle>
|
|
<MudText Typo="Typo.h4" GutterBottom="true">Branch Inventory Correction</MudText>
|
|
<MudText Typo="Typo.body1" GutterBottom="true">Select a specific branch and select the table to edit from the grid.</MudText>
|
|
<MudGrid>
|
|
<MudItem sm="12">
|
|
<MudCard>
|
|
<MudCardContent>
|
|
<MudGrid>
|
|
<MudItem xs="12" md="5">
|
|
<MudAutocomplete T="string" Label="Enter Branch Code" @bind-Value="selectedBranch" SearchFunc="@SearchBranch" CoerceValue=false />
|
|
</MudItem>
|
|
<MudItem xs="12" md="4">
|
|
<MudAutocomplete T="string" Label="Enter Model No." @bind-Value="selectedModelNo" SearchFunc="@SearchModelNo" CoerceValue=false />
|
|
</MudItem>
|
|
<MudItem xs="12" md="3">
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" ButtonType="ButtonType.Button" OnClick="GetRecord" FullWidth="true" Disabled=@disableStatusGetRecord>Get Record</MudButton>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudItem>
|
|
</MudGrid>
|
|
|
|
@if (branchItemLedger != null && branchItemLedger.modelno != null)
|
|
{
|
|
<MudText Typo="Typo.body1" Class="my-5 mt-10">Inventory details of @selectedBranch branch</MudText>
|
|
<EditForm Model="@branchItemLedger" OnValidSubmit="SaveBranchItemLedger">
|
|
<MudGrid>
|
|
<MudItem sm="12">
|
|
<MudCard>
|
|
<MudCardContent>
|
|
<MudGrid>
|
|
<MudItem sm="4">
|
|
<MudField Label="@branchItemLedger.modelno" Variant="Variant.Outlined">@branchItemLedger.itemcode</MudField>
|
|
</MudItem>
|
|
<MudItem sm="8">
|
|
<MudField Label="Remarks" Variant="Variant.Outlined">@branchItemLedger.remarks</MudField>
|
|
</MudItem>
|
|
</MudGrid>
|
|
<MudText Typo="Typo.body1" Class="my-3" Color="Color.Primary">Edit the details below</MudText>
|
|
<MudGrid>
|
|
<MudItem sm="12" md="2">
|
|
<MudTextField T="int" Label="Beginning Qty" @bind-Value="branchItemLedger.beginningqty" />
|
|
</MudItem>
|
|
<MudItem sm="12" md="2">
|
|
<MudTextField T="int" Label="In Qty" @bind-Value="branchItemLedger.inqty" />
|
|
</MudItem>
|
|
<MudItem sm="12" md="2">
|
|
<MudTextField T="int" Label="Out Qty" @bind-Value="branchItemLedger.outqty" />
|
|
</MudItem>
|
|
<MudItem sm="12" md="2">
|
|
<MudTextField T="int" Label="Sales Qty" @bind-Value="branchItemLedger.sales" />
|
|
</MudItem>
|
|
<MudItem sm="12" md="2">
|
|
<MudTextField T="int" Label="Adjustment" @bind-Value="branchItemLedger.adjustment" />
|
|
</MudItem>
|
|
<MudItem sm="12" md="2">
|
|
<MudTextField T="int" Label="Ending Qty" @bind-Value="branchItemLedger.endingqty" />
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudCardContent>
|
|
<MudCardActions>
|
|
<MudButton Class="ma-3" Variant="Variant.Filled" Color="Color.Primary" ButtonType="ButtonType.Submit" Disabled=@disableStatusSave>Update Record</MudButton>
|
|
<MudButton Class="ma-3" Variant="Variant.Filled" Color="Color.Secondary" OnClick="ResetUpdateBranchItemLedger">Reset</MudButton>
|
|
</MudCardActions>
|
|
</MudCard>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</EditForm>
|
|
}
|
|
else
|
|
{
|
|
<MudText Typo="Typo.caption">No Record to Show</MudText>
|
|
}
|
|
|
|
@code {
|
|
BranchServices.branch[]? branchList;
|
|
string? selectedBranch, selectedModelNo;
|
|
BranchItemLedgerServices.branchitemledger? branchItemLedger = null;
|
|
bool disableStatusGetRecord = false, disableStatusSave = true;
|
|
|
|
|
|
BranchServices.BranchServiceClient branchServiceClient = new();
|
|
ItemServices.ItemServiceClient itemServiceClient = new();
|
|
BranchItemLedgerServices.BranchItemLedgerServiceClient branchItemLedgerServiceClient = new();
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
branchList = await branchServiceClient.GetDataAsync();
|
|
}
|
|
|
|
async Task<IEnumerable<string>> SearchBranch(string value)
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
if (string.IsNullOrEmpty(value))
|
|
return branchList.Select(c=>c.brCode);
|
|
|
|
return branchList.Where(c => c.brCode.Contains(value, StringComparison.InvariantCultureIgnoreCase)).Select(c=>c.brCode);
|
|
}
|
|
|
|
async Task<IEnumerable<string>> SearchModelNo(string value)
|
|
{
|
|
ItemServices.items[] itemList;
|
|
|
|
if (string.IsNullOrEmpty(value) || value.Length < 2)
|
|
{
|
|
itemList = await itemServiceClient.GetTopDataAsync(10);
|
|
return itemList.Select(c => c.modelno);
|
|
}
|
|
|
|
itemList = await itemServiceClient.GetItemListByModelnoStartsWithAsync(value);
|
|
return itemList.Select(c => c.modelno);
|
|
}
|
|
|
|
async Task GetRecord()
|
|
{
|
|
if(string.IsNullOrEmpty(selectedBranch))
|
|
{
|
|
var dialogParam = new DialogParameters();
|
|
dialogParam.Add("ContentText", "No branch. Please enter in the Branch field.");
|
|
dialogParam.Add("ButtonText", "OK");
|
|
dialogParam.Add("Color", Color.Error);
|
|
|
|
DialogService.Show<MessageDialogs.WarningDialog>("No Branch", dialogParam);
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(selectedModelNo))
|
|
{
|
|
var dialogParam = new DialogParameters();
|
|
dialogParam.Add("ContentText", "No model number. Please enter in the Model Number field");
|
|
dialogParam.Add("ButtonText", "OK");
|
|
dialogParam.Add("Color", Color.Error);
|
|
|
|
DialogService.Show<MessageDialogs.WarningDialog>("No Mode Number", dialogParam);
|
|
return;
|
|
}
|
|
|
|
disableStatusGetRecord = true;
|
|
disableStatusSave = true;
|
|
|
|
branchItemLedger = await branchItemLedgerServiceClient.GetRemoteDataByBrCodeModelnoAsync(selectedBranch, selectedModelNo);
|
|
|
|
disableStatusGetRecord = false;
|
|
disableStatusSave = false;
|
|
}
|
|
|
|
async Task SaveBranchItemLedger()
|
|
{
|
|
if (branchItemLedger == null)
|
|
return;
|
|
|
|
disableStatusGetRecord = true;
|
|
disableStatusSave = true;
|
|
|
|
branchItemLedger.remarks = $"|Manually edit by {userService?.CurrentUser?.fullName}. {DateTime.Now:MM/dd/yyyy} [{branchItemLedger.beginningqty} {branchItemLedger.inqty} {branchItemLedger.outqty} {branchItemLedger.sales} {branchItemLedger.adjustment} {branchItemLedger.endingqty}]";
|
|
|
|
int result = await branchItemLedgerServiceClient.UpdateRemoteBranchItemLedgerAsync(branchItemLedger);
|
|
|
|
if(result > 0)
|
|
{
|
|
var dialogParam = new DialogParameters();
|
|
dialogParam.Add("ContentText", "Successfully updated the record");
|
|
dialogParam.Add("ButtonText", "OK");
|
|
dialogParam.Add("Color", Color.Info);
|
|
|
|
DialogService.Show<MessageDialogs.WarningDialog>("Success", dialogParam);
|
|
|
|
await ResetUpdateBranchItemLedger();
|
|
}
|
|
else
|
|
{
|
|
var dialogParam = new DialogParameters();
|
|
dialogParam.Add("ContentText", "Failed to update the record");
|
|
dialogParam.Add("ButtonText", "OK");
|
|
dialogParam.Add("Color", Color.Error);
|
|
|
|
DialogService.Show<MessageDialogs.WarningDialog>("Failed", dialogParam);
|
|
|
|
disableStatusGetRecord = false;
|
|
disableStatusSave = false;
|
|
}
|
|
}
|
|
|
|
async Task ResetUpdateBranchItemLedger()
|
|
{
|
|
await Task.Delay(1);
|
|
|
|
disableStatusGetRecord = false;
|
|
disableStatusSave = true;
|
|
branchItemLedger = null;
|
|
}
|
|
}
|