Added Sending to CustomerOrders more than one order (selected ones)

This commit is contained in:
2025-01-28 21:36:18 +01:00
parent 13e5b12a6f
commit 40cd96460e
5 changed files with 143 additions and 116 deletions

View File

@@ -40,23 +40,23 @@
</div> </div>
</div> </div>
<br/> <br/>
<SortableList TItem="EdiCustomerOrderTranslateDto" Data="_ediCustomerOrderTranslate"> @* <SortableList TItem="EdiCustomerOrderTranslateDto" Data="_ediCustomerOrderTranslate"> *@
<ItemTemplate> @* <ItemTemplate> *@
<u>Id:</u>&emsp;<b>@context.Id</b><br /> @* <u>Id:</u>&emsp;<b>@context.Id</b><br /> *@
<u>CoEdiOrder:</u>&emsp;<b>@context.CoEdiOrder</b><br /> @* <u>CoEdiOrder:</u>&emsp;<b>@context.CoEdiOrder</b><br /> *@
<u>CoRowPointer:</u>&emsp;<b>@context.CoRowPointer</b><br /> @* <u>CoRowPointer:</u>&emsp;<b>@context.CoRowPointer</b><br /> *@
<u>CoCoNum:</u>&emsp;<b>@context.CoCoNum</b><br /> @* <u>CoCoNum:</u>&emsp;<b>@context.CoCoNum</b><br /> *@
<u>CoType:</u>&emsp;<b>@context.CoType</b><br /> @* <u>CoType:</u>&emsp;<b>@context.CoType</b><br /> *@
<u>CoTakenBy:</u>&emsp;<b>@context.CoTakenBy</b><br /> @* <u>CoTakenBy:</u>&emsp;<b>@context.CoTakenBy</b><br /> *@
<u>EdiCoCoNum:</u>&emsp;<b>@context.EdiCoCoNum</b><br /> @* <u>EdiCoCoNum:</u>&emsp;<b>@context.EdiCoCoNum</b><br /> *@
<u>OrdersCount:</u>&emsp;<b>@context.OrdersCount</b><br /> @* <u>OrdersCount:</u>&emsp;<b>@context.OrdersCount</b><br /> *@
<u>OrderFound:</u>&emsp;<b>@context.OrderFound</b><br /> @* <u>OrderFound:</u>&emsp;<b>@context.OrderFound</b><br /> *@
<u>CreatedDate:</u>&emsp;<b>@context.CreatedDate.ToString("yyyy-MM-dd HH:mm:ss")</b><br /> @* <u>CreatedDate:</u>&emsp;<b>@context.CreatedDate.ToString("yyyy-MM-dd HH:mm:ss")</b><br /> *@
<u>FoundNumbers:</u>&emsp;<b>@context.FoundNumbers</b><br /> @* <u>FoundNumbers:</u>&emsp;<b>@context.FoundNumbers</b><br /> *@
<u>ScheduleOrderId:</u>&emsp;<b>@context.ScheduleOrderId</b><br /> @* <u>ScheduleOrderId:</u>&emsp;<b>@context.ScheduleOrderId</b><br /> *@
</ItemTemplate> @* </ItemTemplate> *@
</SortableList> @* </SortableList> *@
<br /> @* <br /> *@
<div class="row"> <div class="row">
<h3>Indeksy</h3> <h3>Indeksy</h3>
</div> </div>

View File

@@ -21,7 +21,7 @@
{ {
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<Button Color="ButtonColor.Primary" @onclick="SendOrderToSyteLine">Księguj bieżący</Button> <Button Color="ButtonColor.Primary" @onclick="SendOrderToSyteLine">@_text</Button>
</div> </div>
</div> </div>
} }
@@ -37,6 +37,7 @@
PageSize="20" PageSize="20"
AllowSelection="true" AllowSelection="true"
AllowRowClick="true" AllowRowClick="true"
SelectionMode="GridSelectionMode.Multiple"
OnRowDoubleClick="OnRowDoubleClick" OnRowDoubleClick="OnRowDoubleClick"
SelectedItemsChanged="SelectedItemsChanged"> SelectedItemsChanged="SelectedItemsChanged">
@@ -72,9 +73,22 @@
</Grid> </Grid>
</div> </div>
<Modal @ref="_modal" Title="@_modalDto.Title"> <Modal @ref="_modal" Title="@_text">
<BodyTemplate> <BodyTemplate>
@_modalDto.Body @if (_responses.Any(x => x.Status == 1))
{
foreach (ResponseDto response in _responses.Where(x => x.Status == 1))
{
<p>Zamówienie EDI @response.Identifier zostało poprawnie zaksięgowane w Zamówieniach klienta pod numerem '@response.ExternalIdentifier'</p>
}
}
@if (_responses.Any(x => x.Status == 0))
{
foreach (ResponseDto response in _responses.Where(x => x.Status == 0))
{
<p>Błąd: Zamówienie EDI @response.Identifier nie zostało poprawnie zaksięgowane w Zamówieniach klienta.<br/>Lista błędów:<br/>@response.Message</p>
}
}
</BodyTemplate> </BodyTemplate>
<FooterTemplate> <FooterTemplate>
<Button Color="ButtonColor.Primary" @onclick="OnHideModalClick">OK</Button> <Button Color="ButtonColor.Primary" @onclick="OnHideModalClick">OK</Button>
@@ -83,19 +97,22 @@
@code { @code {
Grid<EdiCustomerOrderDto>? _grid; Grid<EdiCustomerOrderDto>? _grid;
private IEnumerable<EdiCustomerOrderDto>? _ediCustomerOrders; private List<EdiCustomerOrderDto> _ediCustomerOrders = new();
private List<EdiCustomerOrderDto> _selectedEdiCustomerOrders = new();
private EdiCustomerOrderDto? _selectedEdiCustomerOrder; private List<ResponseDto> _responses = new();
private Modal _modal = default!; private Modal _modal = default!;
private ModalDto _modalDto = new(null, null); private ModalDto _modalDto = new(null, null);
private bool _isVisible; private bool _isVisible;
private bool _filter; private bool _filter = true;
private string _text = "Księguj bieżący";
private async Task<GridDataProviderResult<EdiCustomerOrderDto>> EdiCustomerOrdersDataProvider(GridDataProviderRequest<EdiCustomerOrderDto> request) private async Task<GridDataProviderResult<EdiCustomerOrderDto>> EdiCustomerOrdersDataProvider(GridDataProviderRequest<EdiCustomerOrderDto> request)
{ {
_ediCustomerOrders = await EdiCustomerOrderService.GetEdiCustomerOrdersAsync() ?? new List<EdiCustomerOrderDto>(); _ediCustomerOrders = (await EdiCustomerOrderService.GetEdiCustomerOrdersAsync() ?? new List<EdiCustomerOrderDto>()).ToList();
_ediCustomerOrders = _ediCustomerOrders.OrderByDescending(x => x.CreateDate).ToList(); _ediCustomerOrders = _ediCustomerOrders.OrderByDescending(x => x.CreateDate).ToList();
if (_filter) if (_filter)
@@ -103,6 +120,8 @@
_ediCustomerOrders = _ediCustomerOrders.Where(x => x.Posted == 0).ToList(); _ediCustomerOrders = _ediCustomerOrders.Where(x => x.Posted == 0).ToList();
} }
_filter = true;
StateHasChanged(); StateHasChanged();
return await Task.FromResult(request.ApplyTo(_ediCustomerOrders)); return await Task.FromResult(request.ApplyTo(_ediCustomerOrders));
@@ -115,30 +134,39 @@
NavigationManager.NavigateTo($"/EdiCustomerOrder/{customerOrderId}"); NavigationManager.NavigateTo($"/EdiCustomerOrder/{customerOrderId}");
} }
private async void SendOrderToSyteLine() private async Task<bool> SendOrderToSyteLine()
{ {
if (_selectedEdiCustomerOrder == null) return; if (!_selectedEdiCustomerOrders.Any()) return false;
ResponseDto response = await EdiCustomerOrderService.SendOrderToSyteline(_selectedEdiCustomerOrder.CustomerOrderNumber); _responses = new List<ResponseDto>();
if (response.Status == 1) foreach (EdiCustomerOrderDto selectedEdiCustomerOrder in _selectedEdiCustomerOrders)
{ {
_modalDto = new ModalDto("Wysłano", $"Zamówienie EDI {_selectedEdiCustomerOrder.CustomerOrderNumber} zostało poprawnie zaksięgowane w Zamówieniach klienta pod numerem '{_selectedEdiCustomerOrder.EdiCustomerOrderTranslates.FirstOrDefault()?.CoCoNum}'"); ResponseDto response = await EdiCustomerOrderService.SendOrderToSyteline(selectedEdiCustomerOrder.CustomerOrderNumber);
await _modal.ShowAsync();
_grid?.RefreshDataAsync(); if (response.Status == 1)
} {
else response.ExternalIdentifier = selectedEdiCustomerOrder.EdiCustomerOrderTranslates.FirstOrDefault()?.CoCoNum;
{ }
_modalDto = new ModalDto("Błąd", $"Zamówienie EDI {_selectedEdiCustomerOrder.CustomerOrderNumber} nie zostało poprawnie zaksięgowane w Zamówieniach klienta.{Environment.NewLine}Lista błędów:{Environment.NewLine}{response.Message}");
await _modal.ShowAsync(); _responses.Add(response);
} }
await _modal.ShowAsync();
_grid?.RefreshDataAsync();
return true;
} }
private void SelectedItemsChanged(HashSet<EdiCustomerOrderDto> obj) private void SelectedItemsChanged(HashSet<EdiCustomerOrderDto> obj)
{ {
_selectedEdiCustomerOrder = obj.FirstOrDefault() ?? null; _isVisible = false;
_isVisible = _selectedEdiCustomerOrder?.Posted == 0;
if (!obj.Any()) return;
_selectedEdiCustomerOrders = obj.ToList();
_isVisible = _selectedEdiCustomerOrders.Any(x => x.Posted == 0);
_text = obj.Count > 1 ? "Księguj zaznaczone" : "Księguj bieżący";
} }
private async Task OnHideModalClick() private async Task OnHideModalClick()

View File

@@ -4,101 +4,98 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-md-4 bg-light" style="min-height: 150vh;"> <h2 style="margin: 5px">Indeksy:</h2>
<h2 style="margin: 5px">Indeksy:</h2> <Grid @ref="_grid"
<Grid @ref="_grid" TItem="ScheduleOrderDetailDto"
TItem="ScheduleOrderDetailDto" Class="table table-hover table-bordered table-striped"
DataProvider="ScheduleOrderDetailsDataProvider"
AllowFiltering="true"
Responsive="true"
AllowPaging="true"
PageSize="20"
AllowSelection="true"
AllowRowClick="true"
SelectionMode="GridSelectionMode.Single"
SelectedItemsChanged="SelectedItemChanged">
<GridColumns>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Id" PropertyName="Id">
@context.ID
</GridColumn>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="SalesChannelProductCode"
PropertyName="SalesChannelProductCode">
@context.Sc_productCode
</GridColumn>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="ShipperProductCode"
PropertyName="ShipperProductCode">
@context.Sh_productCode
</GridColumn>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Price" PropertyName="Price">
@context.Price
</GridColumn>
</GridColumns>
</Grid>
</div>
@if (_isVisible)
{
<div class="row">
<h2 style="margin: 5px">Dodatkowe informacje:</h2>
<SortableList TItem="ScheduleOrderDetailMiscDto" Data="_scheduleOrderDetailMiscs">
<ItemTemplate>
<u>@context.Label:</u>&emsp;<b>@context.Value</b>
</ItemTemplate>
</SortableList>
</div>
}
@if (_isVisible)
{
<div class="row">
<h2 style="margin: 5px">Harmonogramy:</h2>
<Grid @ref="_detailDetailsGrid"
TItem="ScheduleOrderDetailDetailDto"
Data="_scheduleOrderDetailsDetails"
Class="table table-hover table-bordered table-striped" Class="table table-hover table-bordered table-striped"
DataProvider="ScheduleOrderDetailsDataProvider"
AllowFiltering="true" AllowFiltering="true"
Responsive="true" Responsive="true"
AllowPaging="true" AllowPaging="true"
PageSize="20" PageSize="20"
AllowSelection="true" AllowSelection="true"
AllowRowClick="true"
SelectionMode="GridSelectionMode.Single" SelectionMode="GridSelectionMode.Single"
SelectedItemsChanged="SelectedItemChanged"> SelectedItemsChanged="SelectedDetailDetailChanged">
<GridColumns> <GridColumns>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Id" PropertyName="Id"> <GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Id" PropertyName="Id">
@context.ID @context.ID
</GridColumn> </GridColumn>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="SalesChannelProductCode" PropertyName="SalesChannelProductCode"> <GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="DateFrom"
@context.Sc_productCode PropertyName="DateFrom">
@context.DateFrom
</GridColumn> </GridColumn>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="ShipperProductCode" PropertyName="ShipperProductCode"> <GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="DateTo" PropertyName="DateTo">
@context.Sh_productCode @context.DateTo
</GridColumn> </GridColumn>
<GridColumn TItem="ScheduleOrderDetailDto" HeaderText="Price" PropertyName="Price"> <GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Qty" PropertyName="Qty">
@context.Price @context.Qty
</GridColumn> </GridColumn>
</GridColumns> </GridColumns>
</Grid> </Grid>
@if (_isVisible)
{
<div id="rightTopContainer" class="col-12 bg-light" style="height: auto;">
<h2 style="margin: 5px">Dodatkowe informacje:</h2>
<SortableList TItem="ScheduleOrderDetailMiscDto" Data="_scheduleOrderDetailMiscs">
<ItemTemplate>
<u>@context.Label:</u>&emsp;<b>@context.Value</b>
</ItemTemplate>
</SortableList>
</div>
}
</div> </div>
<div class="col-md-8"> @if (_isVisibleDetailDetail)
{
<div class="row"> <div class="row">
@if (_isVisible) <h2 style="margin: 5px">Dodatkowe informacje:</h2>
{ <SortableList TItem="ScheduleOrderDetailDetailMiscDto" Data="_scheduleOrderDetailDetailMiscs">
<div id="rightBottomContainer" class="col-12 bg-light"> <ItemTemplate>
<h2 style="margin: 5px">Harmonogramy:</h2> <u>@context.Label:</u>&emsp;<b>@context.Value</b>
<Grid @ref="_detailDetailsGrid" </ItemTemplate>
TItem="ScheduleOrderDetailDetailDto" </SortableList>
Data="_scheduleOrderDetailsDetails"
Class="table table-hover table-bordered table-striped"
AllowFiltering="true"
Responsive="true"
AllowPaging="true"
PageSize="20"
AllowSelection="true"
SelectionMode="GridSelectionMode.Single"
SelectedItemsChanged="SelectedDetailDetailChanged">
<GridColumns>
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Id" PropertyName="Id">
@context.ID
</GridColumn>
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="DateFrom" PropertyName="DateFrom">
@context.DateFrom
</GridColumn>
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="DateTo" PropertyName="DateTo">
@context.DateTo
</GridColumn>
<GridColumn TItem="ScheduleOrderDetailDetailDto" HeaderText="Qty" PropertyName="Qty">
@context.Qty
</GridColumn>
</GridColumns>
</Grid>
</div>
@if (_isVisibleDetailDetail)
{
<div id="rightTopContainer" class="col-12 bg-light" style="height: auto;">
<h2 style="margin: 5px">Dodatkowe informacje:</h2>
<SortableList TItem="ScheduleOrderDetailDetailMiscDto" Data="_scheduleOrderDetailDetailMiscs">
<ItemTemplate>
<u>@context.Label:</u>&emsp;<b>@context.Value</b>
</ItemTemplate>
</SortableList>
</div>
}
}
</div> </div>
</div> }
</div> }
</div> </div>
@code { @code {
[Parameter] [Parameter] public int ScheduleOrderId { get; set; }
public int ScheduleOrderId { get; set; }
private bool _isVisible; private bool _isVisible;
private bool _isVisibleDetailDetail; private bool _isVisibleDetailDetail;

View File

@@ -5,12 +5,14 @@
public int Status { get; set; } public int Status { get; set; }
public string Identifier { get; set; } public string Identifier { get; set; }
public string? Message { get; set; } public string? Message { get; set; }
public string? ExternalIdentifier { get; set; }
public ResponseDto(int status, string identifier, string? message) public ResponseDto(int status, string identifier, string? message, string? externalIdentifier)
{ {
Status = status; Status = status;
Identifier = identifier; Identifier = identifier;
Message = message; Message = message;
ExternalIdentifier = externalIdentifier;
} }
} }
} }

View File

@@ -23,7 +23,7 @@ namespace OrdersManagement.Services
if (responseMessage.IsSuccessStatusCode) if (responseMessage.IsSuccessStatusCode)
{ {
return new ResponseDto(1, customerOrderNumber, null); return new ResponseDto(1, customerOrderNumber, null, null);
} }
string? errorMessage = null; string? errorMessage = null;
@@ -35,7 +35,7 @@ namespace OrdersManagement.Services
errorMessage = string.Join("\r\n", logs.Select(x => x.ErrMsg)); errorMessage = string.Join("\r\n", logs.Select(x => x.ErrMsg));
} }
return new ResponseDto(0, customerOrderNumber, errorMessage); return new ResponseDto(0, customerOrderNumber, errorMessage, null);
} }
} }
} }