OrderView update process state to printed when printed

This commit is contained in:
Frede Hundewadt 2023-10-13 16:51:29 +02:00
parent 67a53988e1
commit 9ed0aad0d5
17 changed files with 235 additions and 41 deletions

View file

@ -27,6 +27,9 @@
<i class="bi-activity"></i> Sælger Liste
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-info" href="/sales/orderlist/dk">
<i class="bi-door-open"></i> Åbne ordrer
</a>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/dk">
<i class="bi-phone"></i> Telefon Bestilling
</a>
@ -48,6 +51,9 @@
<i class="bi-activity"></i> Sælger Liste
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-info" href="/sales/orderlist/no">
<i class="bi-door-open"></i> Åbne ordrer
</a>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/no">
<i class="bi-phone"></i> Telefon Bestilling
</a>
@ -66,9 +72,12 @@
<div class="list-group">
<AuthorizeView Roles="Admin,Office">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/se">
<i class="bi-activity"></i> Sælger Liste
<i class="bi-activity"> Sælger Liste</i>
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-info" href="/sales/orderlist/se">
<i class="bi-door-open"></i> Åbne ordrer
</a>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/se">
<i class="bi-phone"></i> Telefon Bestilling
</a>

View file

@ -0,0 +1,9 @@
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public interface IOfficeOpenOrdersRepository
{
Task<List<OpenOrderListView>> GetOpenOrders();
Task<List<OpenOrderListView>> GetOpenOrders(string countryCode);
}

View file

@ -28,27 +28,27 @@ public interface IOrderProcessRepository
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
Task<List<WarehouseOrderView>> GetWarehouseOrderListByDate(string date);
Task<List<WarehouseOrderView>> GetOrderListByDate(string date);
/// <summary>
/// Get orders by status
/// Get orders by state
/// </summary>
/// <param name="status"></param>
/// <param name="state"></param>
/// <param name="express"></param>
/// <returns></returns>
Task<List<WarehouseOrderView>> GetWarehouseOrderListByStatus(string status, string express = "");
Task<List<WarehouseOrderView>> GetOrderListByStatus(string state, string express = "");
/// <summary>
/// Get order with orderId
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
Task<WarehouseOrderView> GetWarehouseOrder(string orderId);
Task<WarehouseOrderView> GetOrderById(string orderId);
/// <summary>
/// Update Order status setting new process status
/// Update Order state setting new process state
/// </summary>
/// <param name="processState"></param>
/// <param name="orderState"></param>
/// <returns></returns>
Task UpdateWarehouseOrderStatus(OrderProcessState processState);
Task UpdateOrderStatus(OrderProcessState orderState);
}

View file

@ -0,0 +1,52 @@
using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using Wonky.Entity.Configuration;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public class OfficeOpenOrdersRepository : IOfficeOpenOrdersRepository
{
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private readonly ILogger<OfficeOpenOrdersRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
public OfficeOpenOrdersRepository(HttpClient client,
ILogger<OfficeOpenOrdersRepository> logger,
NavigationManager navigation,
IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_api = configuration.Value;
}
public async Task<List<OpenOrderListView>> GetOpenOrders()
{
var result = await _client
.GetFromJsonAsync<List<OpenOrderListView>>(
$"{_api.OfficeSales}", _options);
return result ?? new List<OpenOrderListView>();
}
public async Task<List<OpenOrderListView>> GetOpenOrders(string countryCode)
{
var result = await _client
.GetFromJsonAsync<List<OpenOrderListView>>(
$"{_api.OfficeSales}/country/{countryCode}", _options);
return result ?? new List<OpenOrderListView>();
}
}

View file

@ -52,22 +52,22 @@ public class OrderProcessRepository : IOrderProcessRepository
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public async Task<List<WarehouseOrderView>> GetWarehouseOrderListByDate(string date)
public async Task<List<WarehouseOrderView>> GetOrderListByDate(string date)
{
var result = await _client.GetFromJsonAsync<List<WarehouseOrderView>>($"{_api.Warehouse}/date?date={date}", _options);
var result = await _client.GetFromJsonAsync<List<WarehouseOrderView>>($"{_api.OrderProcess}/date?date={date}", _options);
return result ?? new List<WarehouseOrderView>();
}
/// <summary>
/// Get orders by status
/// Get orders by state
/// </summary>
/// <param name="status"></param>
/// <param name="state"></param>
/// <param name="express"></param>
/// <returns></returns>
public async Task<List<WarehouseOrderView>> GetWarehouseOrderListByStatus(string status, string express = "")
public async Task<List<WarehouseOrderView>> GetOrderListByStatus(string state, string express = "")
{
var result = await _client.GetFromJsonAsync<List<WarehouseOrderView>>(
$"{_api.Warehouse}/state?status={status}&express={express}", _options);
$"{_api.OrderProcess}/state?status={state}&express={express}", _options);
return result ?? new List<WarehouseOrderView>();
}
@ -76,20 +76,20 @@ public class OrderProcessRepository : IOrderProcessRepository
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
public async Task<WarehouseOrderView> GetWarehouseOrder(string orderId)
public async Task<WarehouseOrderView> GetOrderById(string orderId)
{
var result = await _client.GetFromJsonAsync<WarehouseOrderView>($"{_api.Warehouse}/{orderId}", _options);
var result = await _client.GetFromJsonAsync<WarehouseOrderView>($"{_api.OrderProcess}/{orderId}", _options);
return result ?? new WarehouseOrderView();
}
/// <summary>
/// Update Order status setting new process status
/// Update Order state setting new process state
/// </summary>
/// <param name="processState"></param>
/// <param name="orderState"></param>
/// <returns></returns>
public async Task UpdateWarehouseOrderStatus(OrderProcessState processState)
public async Task UpdateOrderStatus(OrderProcessState orderState)
{
_logger.LogDebug("process => {}", JsonSerializer.Serialize(processState, _options));
await _client.PutAsJsonAsync($"{_api.Warehouse}/{processState.OrderId}", processState, _options);
_logger.LogDebug("process => {}", JsonSerializer.Serialize(orderState, _options));
await _client.PutAsJsonAsync($"{_api.OrderProcess}/{orderState.OrderId}", orderState, _options);
}
}

View file

@ -72,7 +72,7 @@ public partial class CommonReportPrintOrderPage
foreach (var item in orders)
{
Toaster.ShowInfo($"Behandler {current++} af {count} ordrer. Vent venligst");
await ProcessRepo.UpdateWarehouseOrderStatus(new OrderProcessState
await ProcessRepo.UpdateOrderStatus(new OrderProcessState
{
OrderId = item.ActivityId,
ProcessStatusEnum = Utils.EnumToString(ProcessStatus.Printed)

View file

@ -113,7 +113,7 @@ public partial class OfficeAdvisorReportViewPage : IDisposable
{
Toaster.ClearInfoToasts();
Toaster.ShowInfo($"Behandler {current++} af {count} ordrer. Vent venligst");
await ProcessRepo.UpdateWarehouseOrderStatus(new OrderProcessState
await ProcessRepo.UpdateOrderStatus(new OrderProcessState
{
OrderId = item.ActivityId,
ProcessStatusEnum = Utils.EnumToString(ProcessStatus.Printed)

View file

@ -0,0 +1,41 @@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Admin,Office,Supervisor,Warehouse")]
@page "/sales/orderlist/{CountryCode}"
<PageTitle>Åbne ordrer @CountryCode</PageTitle>
@if (OrderLIst.Any())
{
<div class="list-group">
<div class="list-group-item">
<div class="row">
<div class="col-sm-6">Navn</div>
<div class="col-sm-2">Konto</div>
<div class="col-sm-2">Dato</div>
<div class="col-sm-2"></div>
</div>
</div>
@foreach (var order in OrderLIst)
{
<a class="list-group-item list-group-item-action" href="/office/customers/@order.CompanyId/orders/@order.SalesHeadId">
<div class="row">
<div class="col-sm-6">@order.CompanyName</div>
<div class="col-sm-2">@order.Account</div>
<div class="col-sm-2">@order.OrderDate</div>
<div class="col-sm-2">@order.SalesRep</div>
</div>
</a>
}
</div>
}
else
{
<span>Afventer svar fra service ... Vent venligst.</span>
}
@if (Working)
{
<WorkingThreeDots />
}

View file

@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Entity.Views;
#pragma warning disable CS8618
namespace Wonky.Client.Pages;
public partial class OfficeOpenOrderListPage : IDisposable
{
// #############################################################
[Inject] public ILogger<OfficeOpenOrderListPage> Logger { get; set; }
[Inject] public IOfficeOpenOrdersRepository OpenOrdersRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
// #############################################################
[Parameter] public string CountryCode { get; set; } = "";
// #############################################################
private bool Working { get; set; } = true;
private List<OpenOrderListView> OrderLIst { get; set; } = new();
protected override async Task OnParametersSetAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
Logger.LogInformation("---- CountryCode is '{}'", CountryCode);
OrderLIst = await OpenOrdersRepo.GetOpenOrders(CountryCode);
Working = false;
}
public void Dispose()
{
Interceptor.DisposeEvent();
}
}

View file

@ -28,7 +28,7 @@
<div class="d-print-none">
<div class="row">
<div class="col-sm-1">
<button type="button" class="btn btn-warning d-block" onclick="window.print();">PRINT</button>
<button type="button" class="btn btn-warning d-block" @onclick="@OfficePrint">PRINT</button>
</div>
@if (ReportItem is { Express: true, ProcessStatusEnum: "None" })
{

View file

@ -19,6 +19,9 @@ using System.Text.Json;
using Blazored.LocalStorage;
using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Wonky.Client.Enums;
using Wonky.Client.Helpers;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Local.Services;
@ -39,6 +42,9 @@ public partial class OfficeOrderViewPage : IDisposable
[Inject] public ILogger<OfficeOrderViewPage> Logger { get; set; }
[Inject] public IToastService Toast { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
[Inject] public IJSRuntime JsRuntime { get; set; }
[Inject] public IOrderProcessRepository ProcessRepo { get; set; }
// #############################################################
[Parameter] public string CompanyId { get; set; } = "";
@ -48,6 +54,8 @@ public partial class OfficeOrderViewPage : IDisposable
private ReportItemView ReportItem { get; set; } = new();
private bool IsNotified { get; set; }
private bool Working { get; set; } = true;
private IJSObjectReference JsModule { get; set; }
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{
@ -64,9 +72,15 @@ public partial class OfficeOrderViewPage : IDisposable
Working = false;
}
/// <summary>
/// Set activity process state to express. Send confirmation notification to salesRep
/// </summary>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
JsModule = await JsRuntime
.InvokeAsync<IJSObjectReference>("import", "/scripts/print-invoke.js");
}
}
private async Task SetExpressState()
{
// disable doubled actions
@ -131,6 +145,17 @@ public partial class OfficeOrderViewPage : IDisposable
Working = false;
}
private async Task OfficePrint()
{
await ProcessRepo.UpdateOrderStatus(new OrderProcessState
{
OrderId = OrderId,
ProcessStatusEnum = Utils.EnumToString(ProcessStatus.Printed)
});
await JsModule.InvokeVoidAsync("printInvoke");
}
public void Dispose()
{
Interceptor.DisposeEvent();

View file

@ -81,6 +81,7 @@ builder.Services.AddScoped<ICountryUserInfoRepository, CountryUserInfoRepository
builder.Services.AddScoped<ISupportDocumentRepository, SupportDocumentRepository>();
builder.Services.AddScoped<ISupportManagementRepository, SupportManagementRepository>();
builder.Services.AddScoped<ICountryActivityRepository, CountryActivityRepository>();
builder.Services.AddScoped<IOfficeOpenOrdersRepository, OfficeOpenOrdersRepository>();
// warehouse repository
builder.Services.AddScoped<IOrderProcessRepository, OrderProcessRepository>();
// mail service

View file

@ -11,14 +11,14 @@
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Blazored.Toast" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-rc.1.23421.29" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-rc.2.23480.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Toolbelt.Blazor.HttpClientInterceptor" Version="10.2.0" />
</ItemGroup>

View file

@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "255.0",
"version": "257.0",
"rc": true,
"sandBox": true,
"image": "grumpy-coder.png",
@ -11,7 +11,7 @@
"LogLevel": {
"Default": "Debug",
"System": "Debug",
"Microsoft": "None"
"Microsoft": "Debug"
},
"Debug": {
"LogLevel": {
@ -32,7 +32,9 @@
"officeAdvisors": "api/v2/office/users/advisors",
"officeCustomers": "api/v2/office/customers",
"officeReports": "api/v2/office/reports",
"officeSales": "api/v2/office/sales",
"officeUsers": "api/v2/office/users/admin",
"orderProcess": "api/v2/orders/process",
"publicProducts": "api/v2/public/products",
"serviceAuth": "v2/token",
"serviceGlsId": "",
@ -54,7 +56,6 @@
"userManagerSetPasswd": "api/v2/app/manage/passwd",
"userRoles": "api/v2/app/manage/roles",
"userSupport": "/api/v2/app/manage/support",
"warehouse": "api/v2/warehouse/packages",
"b2bCustomer": "api/v2/b2b"
}
}

View file

@ -83,6 +83,10 @@ public class ApiConfig
/// </summary>
public string OfficeReports { get; set; } = "";
/// <summary>
/// Endpoint for Office Sales actions
/// </summary>
public string OfficeSales { get; set; } = "";
/// <summary>
/// Public Product url
/// </summary>
@ -189,7 +193,7 @@ public class ApiConfig
/// <summary>
/// Uri for warehouse requests
/// </summary>
public string Warehouse { get; set; } = "";
public string OrderProcess { get; set; } = "";
/// <summary>
/// Uri for B2BCustomer

View file

@ -0,0 +1,11 @@
namespace Wonky.Entity.Views;
public class OpenOrderListView
{
public string CompanyId { get; set; } = "";
public string CompanyName { get; set; } = "";
public string Account { get; set; } = "";
public string SalesHeadId { get; set; } = "";
public string OrderDate { get; set; } = "";
public string SalesRep { get; set; } = "";
}