From c6625f08a2d24c99665b5cc9618612da8e9c5d01 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Sat, 31 Dec 2022 03:18:16 +0100 Subject: [PATCH 01/49] reworked documentation preparing for office order creation and country price lookup --- .../CustomerProductTableComponent.razor.cs | 4 +- .../Components/LandingComponentAdmin.razor.cs | 2 +- .../LandingComponentAdvisor.razor.cs | 10 +- Wonky.Client/Features/PagingLink.cs | 22 +- Wonky.Client/Features/PagingResponse.cs | 10 + Wonky.Client/Helpers/InputDateTime.cs | 102 ++++++--- Wonky.Client/Helpers/Squid.cs | 185 +++++++++++++++- Wonky.Client/Helpers/StringExtensions.cs | 8 +- Wonky.Client/Helpers/Utils.cs | 63 ++++-- Wonky.Client/Helpers/VatUtils.cs | 54 ++++- ...itory.cs => IActivityCrmHttpRepository.cs} | 35 ++-- .../HttpInterfaces/ICatalogHttpRepository.cs | 26 ++- .../IContactCrmHttpRepository.cs | 47 +++++ .../ICrmContactHttpRepository.cs | 12 -- .../ICrmReportHttpRepository.cs | 28 --- .../ICrmTaskItemHttpRepository.cs | 29 --- ...itory.cs => ICustomerCrmHttpRepository.cs} | 27 ++- .../ICustomerHistoryCrmHttpRepository.cs | 70 +++++++ .../ICustomerOfficeHttpRepository.cs | 57 +++++ .../IOfficeCustomerHttpRepository.cs | 27 --- .../HttpInterfaces/IReportHttpRepository.cs | 75 +++++++ ...tory.cs => IReportOfficeHttpRepository.cs} | 26 ++- .../HttpInterfaces/ISendMailService.cs | 9 + .../ITaskItemCrmHttpRepository.cs | 66 ++++++ .../HttpInterfaces/IUserHttpRepository.cs | 46 ++++ .../IWarehouseHttpRepository.cs | 28 +++ ...tory.cs => IWorkplaceCrmHttpRepository.cs} | 38 +++- ...sitory.cs => ActivityCrmHttpRepository.cs} | 17 +- .../HttpRepository/CatalogHttpRepository.cs | 66 +++++- ...ository.cs => ContactCrmHttpRepository.cs} | 35 +++- ...sitory.cs => CustomerCrmHttpRepository.cs} | 40 ++-- ...cs => CustomerHistoryCrmHttpRepository.cs} | 28 +-- ...ory.cs => CustomerOfficeHttpRepository.cs} | 107 ++++------ .../OfficeReportHttpRepository.cs | 59 ------ ...pRepository.cs => ReportHttpRepository.cs} | 73 +++++-- .../HttpRepository/SendMailService.cs | 14 +- ...sitory.cs => TaskItemCrmHttpRepository.cs} | 46 +++- .../HttpRepository/UserHttpRepository.cs | 50 ++++- .../HttpRepository/WarehouseHttpRepository.cs | 31 ++- ...itory.cs => WorkplaceCrmHttpRepository.cs} | 43 +++- .../Pages/ActivityCreateCrmPage.razor.cs | 12 +- .../Pages/ActivityListCustomerPage.razor.cs | 6 +- .../Pages/ActivityListTodayCrmPage.razor.cs | 10 +- .../Pages/ActivityViewCrmPage.razor.cs | 2 +- Wonky.Client/Pages/CatalogCountryPage.razor | 53 +++++ .../Pages/CatalogCountryPage.razor.cs | 121 +++++++++++ ...CatalogPage.razor => CatalogCrmPage.razor} | 0 ...gPage.razor.cs => CatalogCrmPage.razor.cs} | 4 +- .../Pages/CustomerCreateCrmPage.razor.cs | 2 +- .../Pages/CustomerInvoiceListCrmPage.razor.cs | 4 +- .../Pages/CustomerListCountryPage.razor | 59 ++++++ .../Pages/CustomerListCountryPage.razor.cs | 151 +++++++++++++ .../Pages/CustomerListCrmPage.razor.cs | 42 ++-- .../Pages/CustomerListOfficePage.razor | 61 ------ .../Pages/CustomerListOfficePage.razor.cs | 131 ------------ .../Pages/CustomerProductListCrmPage.razor.cs | 4 +- .../Pages/CustomerViewCrmPage.razor.cs | 6 +- .../Pages/KrvItemViewAdminPage.razor.cs | 2 +- .../LandingPageAdminCountry.razor} | 17 +- .../Pages/LandingPageAdminUsers.razor | 17 +- .../Pages/OrderCreateOfficePage.razor | 198 ------------------ .../Pages/OrderCreateOfficePage.razor.cs | 196 ----------------- .../Pages/OrderViewOfficePage.razor.cs | 2 +- Wonky.Client/Pages/PrintCatalogPage.razor.cs | 2 +- Wonky.Client/Pages/QuoteListCrmPage.razor.cs | 2 +- .../Pages/ReportCreateCrmPage.razor.cs | 8 +- Wonky.Client/Pages/ReportListCrmPage.razor.cs | 2 +- .../Pages/ReportListOfficePage.razor.cs | 11 +- Wonky.Client/Pages/ReportViewCrmPage.razor.cs | 2 +- .../Pages/ReportViewOfficePage.razor.cs | 29 +-- .../Pages/TaskItemListCrmPage.razor.cs | 4 +- .../Pages/TaskItemViewCrmPage.razor.cs | 4 +- .../Pages/UserListSalesRepPage.razor.cs | 4 +- .../Pages/WorkplaceDocumentListPage.razor.cs | 2 +- Wonky.Client/Pages/WorkplaceListPage.razor.cs | 6 +- Wonky.Client/Pages/WorkplaceViewPage.razor.cs | 10 +- Wonky.Client/Program.cs | 20 +- Wonky.Client/Shared/ContactModal.razor.cs | 2 +- .../Shared/InventoryReorderModal.razor.cs | 4 +- Wonky.Client/Shared/InvoiceViewModal.razor.cs | 2 +- Wonky.Client/Shared/NavMenu.razor | 25 +-- Wonky.Client/Shared/PriceListModal.razor.cs | 2 +- .../Shared/ProductHistoryModal.razor.cs | 4 +- .../Shared/ProductPriceHistoryModal.razor.cs | 4 +- Wonky.Client/wwwroot/appsettings.json | 2 +- ...mpanyPagingParams.cs => CustomerPaging.cs} | 2 +- 86 files changed, 1813 insertions(+), 1155 deletions(-) rename Wonky.Client/HttpInterfaces/{ICrmActivityHttpRepository.cs => IActivityCrmHttpRepository.cs} (95%) create mode 100644 Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs delete mode 100644 Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs delete mode 100644 Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs delete mode 100644 Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs rename Wonky.Client/HttpInterfaces/{ICrmCompanyHttpRepository.cs => ICustomerCrmHttpRepository.cs} (81%) create mode 100644 Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs create mode 100644 Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs delete mode 100644 Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs create mode 100644 Wonky.Client/HttpInterfaces/IReportHttpRepository.cs rename Wonky.Client/HttpInterfaces/{ICrmHistoryHttpRepository.cs => IReportOfficeHttpRepository.cs} (56%) create mode 100644 Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs rename Wonky.Client/HttpInterfaces/{ICrmWorkplaceHttpRepository.cs => IWorkplaceCrmHttpRepository.cs} (51%) rename Wonky.Client/HttpRepository/{CrmActivityHttpRepository.cs => ActivityCrmHttpRepository.cs} (92%) rename Wonky.Client/HttpRepository/{CrmContactHttpRepository.cs => ContactCrmHttpRepository.cs} (71%) rename Wonky.Client/HttpRepository/{CrmCompanyHttpRepository.cs => CustomerCrmHttpRepository.cs} (85%) rename Wonky.Client/HttpRepository/{CrmHistoryHttpRepository.cs => CustomerHistoryCrmHttpRepository.cs} (87%) rename Wonky.Client/HttpRepository/{OfficeCustomerHttpRepository.cs => CustomerOfficeHttpRepository.cs} (77%) delete mode 100644 Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs rename Wonky.Client/HttpRepository/{CrmReportHttpRepository.cs => ReportHttpRepository.cs} (59%) rename Wonky.Client/HttpRepository/{CrmTaskItemHttpRepository.cs => TaskItemCrmHttpRepository.cs} (71%) rename Wonky.Client/HttpRepository/{CrmWorkplaceHttpRepository.cs => WorkplaceCrmHttpRepository.cs} (68%) create mode 100644 Wonky.Client/Pages/CatalogCountryPage.razor create mode 100644 Wonky.Client/Pages/CatalogCountryPage.razor.cs rename Wonky.Client/Pages/{CatalogPage.razor => CatalogCrmPage.razor} (100%) rename Wonky.Client/Pages/{CatalogPage.razor.cs => CatalogCrmPage.razor.cs} (97%) create mode 100644 Wonky.Client/Pages/CustomerListCountryPage.razor create mode 100644 Wonky.Client/Pages/CustomerListCountryPage.razor.cs delete mode 100644 Wonky.Client/Pages/CustomerListOfficePage.razor delete mode 100644 Wonky.Client/Pages/CustomerListOfficePage.razor.cs rename Wonky.Client/{HttpInterfaces/IOfficeReportHttpRepository.cs => Pages/LandingPageAdminCountry.razor} (76%) delete mode 100644 Wonky.Client/Pages/OrderCreateOfficePage.razor delete mode 100644 Wonky.Client/Pages/OrderCreateOfficePage.razor.cs rename Wonky.Entity/Requests/{CompanyPagingParams.cs => CustomerPaging.cs} (98%) diff --git a/Wonky.Client/Components/CustomerProductTableComponent.razor.cs b/Wonky.Client/Components/CustomerProductTableComponent.razor.cs index 136a5094..b1ec58d4 100644 --- a/Wonky.Client/Components/CustomerProductTableComponent.razor.cs +++ b/Wonky.Client/Components/CustomerProductTableComponent.razor.cs @@ -30,7 +30,7 @@ public partial class CustomerProductTableComponent [CascadingParameter] public DraftStateProvider DraftStateProvider { get; set; } = new(); [Parameter] public List ProductList { get; set; } = new(); [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICatalogHttpRepository Catalog { get; set; } + [Inject] public ICatalogCrmHttpRepository CatalogCrm { get; set; } [Inject] public ILocalStorageService Storage { get; set; } // private variables private SalesItemView SalesItem { get; set; } = new(); @@ -89,7 +89,7 @@ public partial class CustomerProductTableComponent private async Task CallShowReorderModal(string sku) { // fetch item from http repo - SalesItem = await Catalog.GetSalesItemSku(sku); + SalesItem = await CatalogCrm.GetSalesItemSku(sku); ReorderModal.Show(); } diff --git a/Wonky.Client/Components/LandingComponentAdmin.razor.cs b/Wonky.Client/Components/LandingComponentAdmin.razor.cs index a342cae0..bfa137f2 100644 --- a/Wonky.Client/Components/LandingComponentAdmin.razor.cs +++ b/Wonky.Client/Components/LandingComponentAdmin.razor.cs @@ -36,7 +36,7 @@ public partial class LandingComponentAdmin : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IToastService Toaster { get; set; } - [Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } private readonly JsonSerializerOptions _options = new JsonSerializerOptions diff --git a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs index c471c4fd..c2351ea9 100644 --- a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs +++ b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs @@ -36,7 +36,7 @@ public partial class LandingComponentAdvisor : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Inteceptor { get; set; } [Inject] public IToastService Toaster { get; set; } - [Inject] public ICrmTaskItemHttpRepository TaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } private readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions @@ -63,7 +63,7 @@ public partial class LandingComponentAdvisor : IDisposable private async Task GetAllTasks() { - TaskItems = await TaskItemRepo.GetTaskList(); + TaskItems = await TaskRepo.GetTaskList(); } private async Task OnCompleteTask(string taskItemId) @@ -77,14 +77,14 @@ public partial class LandingComponentAdvisor : IDisposable { SelectedDate = DateTime.Parse(workDate); TaskItems = new List(); - TaskItems = await TaskItemRepo.GetTaskList($"{SelectedDate:yyyy-MM-dd}"); + TaskItems = await TaskRepo.GetTaskList($"{SelectedDate:yyyy-MM-dd}"); } private async Task OnTaskCompleted(string taskItemId) { var item = TaskItems.Find(x => x.TaskItemId == taskItemId); item.IsCompleted = true; - await TaskItemRepo.UpdateTaskItem(taskItemId, item); + await TaskRepo.UpdateTaskItem(taskItemId, item); TaskItems.Remove(item); Toaster.ShowInfo("Opgaven er markeret som udført."); } @@ -93,7 +93,7 @@ public partial class LandingComponentAdvisor : IDisposable { var item = TaskItems.First(x => x.TaskItemId == taskItemId); TaskItems.Remove(item); - await TaskItemRepo.DeleteTaskItem(taskItemId); + await TaskRepo.DeleteTaskItem(taskItemId); Toaster.ShowInfo("Opgaven er slettet."); } diff --git a/Wonky.Client/Features/PagingLink.cs b/Wonky.Client/Features/PagingLink.cs index a4d6c97a..240cb2d5 100644 --- a/Wonky.Client/Features/PagingLink.cs +++ b/Wonky.Client/Features/PagingLink.cs @@ -14,14 +14,34 @@ // namespace Wonky.Client.Features; - +/// +/// PagingLink class +/// public class PagingLink { + /// + /// Text + /// public string Text { get; set; } + /// + /// Page + /// public int Page { get; set; } + /// + /// Enabled + /// public bool Enabled { get; set; } + /// + /// Active + /// public bool Active { get; set; } + /// + /// The paging link + /// + /// + /// + /// public PagingLink(int page, bool enabled, string text) { Page = page; diff --git a/Wonky.Client/Features/PagingResponse.cs b/Wonky.Client/Features/PagingResponse.cs index 5cde91c4..da8245c8 100644 --- a/Wonky.Client/Features/PagingResponse.cs +++ b/Wonky.Client/Features/PagingResponse.cs @@ -18,8 +18,18 @@ using Wonky.Entity.Requests; namespace Wonky.Client.Features; +/// +/// PagingResponse T class +/// +/// public class PagingResponse where T : class { + /// + /// Items + /// public List? Items { get; set; } + /// + /// Meta DAta + /// public MetaData? MetaData { get; set; } } \ No newline at end of file diff --git a/Wonky.Client/Helpers/InputDateTime.cs b/Wonky.Client/Helpers/InputDateTime.cs index 8bf8a65c..5ae2983f 100644 --- a/Wonky.Client/Helpers/InputDateTime.cs +++ b/Wonky.Client/Helpers/InputDateTime.cs @@ -21,73 +21,99 @@ using Microsoft.AspNetCore.Components.Rendering; namespace Wonky.Client.Helpers; +/// +/// InputDateTime Component +/// +/// public class InputDateTime : InputDate { private const string DateFormat = "yyyy-MM-ddTHH:mm"; - /// - protected override void BuildRenderTree ( RenderTreeBuilder builder ) + /// + /// BuildTender + /// + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) { - builder.OpenElement( 0, "input" ); - builder.AddMultipleAttributes( 1, AdditionalAttributes ); - builder.AddAttribute( 2, "type", "datetime-local" ); - builder.AddAttribute( 3, "class", CssClass ); - builder.AddAttribute( 4, "value", BindConverter.FormatValue( CurrentValueAsString ) ); - builder.AddAttribute( 5, "onchange", EventCallback.Factory.CreateBinder( this, __value => CurrentValueAsString = __value, CurrentValueAsString ) ); + builder.OpenElement(0, "input"); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "type", "datetime-local"); + builder.AddAttribute(3, "class", CssClass); + builder.AddAttribute(4, "value", BindConverter.FormatValue(CurrentValueAsString)); + builder.AddAttribute(5, "onchange", + EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, + CurrentValueAsString)); builder.CloseElement(); } - /// - protected override string FormatValueAsString ( TValue value ) + /// + /// Format value as string + /// + /// + /// + protected override string FormatValueAsString(TValue value) { - switch ( value ) + return value switch { - case DateTime dateTimeValue: - return BindConverter.FormatValue( dateTimeValue, DateFormat, CultureInfo.InvariantCulture ); - case DateTimeOffset dateTimeOffsetValue: - return BindConverter.FormatValue( dateTimeOffsetValue, DateFormat, CultureInfo.InvariantCulture ); - default: - return string.Empty; // Handles null for Nullable, etc. - } + DateTime dateTimeValue => + BindConverter.FormatValue(dateTimeValue, DateFormat, CultureInfo.InvariantCulture), + DateTimeOffset dateTimeOffsetValue => BindConverter.FormatValue(dateTimeOffsetValue, DateFormat, + CultureInfo.InvariantCulture), + _ => string.Empty + }; } - /// - protected override bool TryParseValueFromString ( string value, out TValue result, out string validationErrorMessage ) + /// + /// TryParseValueFromString + /// + /// + /// + /// + /// + /// + protected override bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage) { // Unwrap nullable types. We don't have to deal with receiving empty values for nullable // types here, because the underlying InputBase already covers that. - var targetType = Nullable.GetUnderlyingType( typeof( TValue ) ) ?? typeof( TValue ); + var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); bool success; - if ( targetType == typeof( DateTime ) ) + if (targetType == typeof(DateTime)) { - success = TryParseDateTime( value, out result ); + success = TryParseDateTime(value, out result); } - else if ( targetType == typeof( DateTimeOffset ) ) + else if (targetType == typeof(DateTimeOffset)) { - success = TryParseDateTimeOffset( value, out result ); + success = TryParseDateTimeOffset(value, out result); } else { - throw new InvalidOperationException( $"The type '{targetType}' is not a supported date type." ); + throw new InvalidOperationException($"The type '{targetType}' is not a supported date type."); } - if ( success ) + if (success) { validationErrorMessage = null; return true; } else { - validationErrorMessage = string.Format( ParsingErrorMessage, FieldIdentifier.FieldName ); + validationErrorMessage = string.Format(ParsingErrorMessage, FieldIdentifier.FieldName); return false; } } - static bool TryParseDateTime ( string value, out TValue result ) + /// + /// TrypParseDateTime + /// + /// + /// + /// + private static bool TryParseDateTime(string value, out TValue result) { - var success = BindConverter.TryConvertToDateTime( value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue ); - if ( success ) + var success = + BindConverter.TryConvertToDateTime(value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue); + if (success) { result = (TValue)(object)parsedValue; return true; @@ -99,10 +125,18 @@ public class InputDateTime : InputDate } } - static bool TryParseDateTimeOffset ( string value, out TValue result ) + /// + /// TryParseDateTimeOffset + /// + /// + /// + /// + private static bool TryParseDateTimeOffset(string value, out TValue result) { - var success = BindConverter.TryConvertToDateTimeOffset( value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue ); - if ( success ) + var success = + BindConverter.TryConvertToDateTimeOffset(value, CultureInfo.InvariantCulture, DateFormat, + out var parsedValue); + if (success) { result = (TValue)(object)parsedValue; return true; diff --git a/Wonky.Client/Helpers/Squid.cs b/Wonky.Client/Helpers/Squid.cs index aa4a2c56..2283ec17 100644 --- a/Wonky.Client/Helpers/Squid.cs +++ b/Wonky.Client/Helpers/Squid.cs @@ -28,36 +28,79 @@ using System.Diagnostics; namespace Wonky.Client.Helpers { + /// + /// Squid is guid string shortened and url safe + /// [DebuggerDisplay("{" + nameof(Value) + "}")] public readonly struct Squid : IEquatable - { + { + /// + /// Return Empty value + /// + // ReSharper disable once MemberCanBePrivate.Global public static readonly Squid Empty = new(Guid.Empty); + + /// + /// Decode Squid to Guid + /// + /// public Squid(string value) { Value = value; Guid = DecodeSquid(value); } + + /// + /// Generate Squid from Guid object + /// + /// public Squid(Guid obj) { Value = EncodeGuid(obj); Guid = obj; } -#pragma warning disable CA1720 // Identifier contains type name + + /// + /// Guid + /// + // ReSharper disable once MemberCanBePrivate.Global public Guid Guid { get; } -#pragma warning restore CA1720 // Identifier contains type name + public string Value { get; } + + /// + /// ToString() function + /// + /// public override string ToString() { return Value; } - public override bool Equals(object obj) + + /// + /// Equality + /// + /// + /// + public override bool Equals(object? obj) { return obj is Squid other && Equals(other); } + + /// + /// EQuality + /// + /// + /// public bool Equals(Squid obj) { return Guid.Equals(obj.Guid) && Value == obj.Value; } + + /// + /// Get hashcode + /// + /// public override int GetHashCode() { unchecked @@ -65,15 +108,33 @@ namespace Wonky.Client.Helpers return (Guid.GetHashCode() * 397) ^ (Value != null ? Value.GetHashCode() : 0); } } + + /// + /// Create Squid from new Guid + /// + /// public static Squid NewGuid() { - return new(Guid.NewGuid()); + return new Squid(Guid.NewGuid()); } + + /// + /// Encode string + /// + /// + /// public static string EncodeString(string value) { var guid = new Guid(value); return EncodeGuid(guid); } + + /// + /// Encode Guid + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static string EncodeGuid(Guid obj) { var encoded = Convert.ToBase64String(obj.ToByteArray()); @@ -82,25 +143,52 @@ namespace Wonky.Client.Helpers .Replace("+", "-"); return encoded.Substring(0, 22); } + + /// + /// Decode Squid + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static Guid DecodeSquid(string value) { - if (value == null) return Empty; + if (!value.Any()) return Empty; value = value .Replace("_", "/") .Replace("-", "+"); var blob = Convert.FromBase64String(value + "=="); return new Guid(blob); } + + /// + /// Guid From Squid + /// + /// + /// public static Guid FromSquid(Squid obj) { return obj.Guid; } + + /// + /// Squid From String + /// + /// + /// public static Squid FromString(string value) { if (string.IsNullOrEmpty(value)) return Empty; return TryParse(value, out Squid obj) ? obj : Empty; } + + /// + /// TryDecode + /// + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static bool TryDecode(string value, out Guid obj) { try @@ -109,15 +197,21 @@ namespace Wonky.Client.Helpers obj = DecodeSquid(value); return true; } -#pragma warning disable CA1031 // Do not catch general exception types catch (Exception) -#pragma warning restore CA1031 // Do not catch general exception types { // Return empty Guid obj = Guid.Empty; return false; } } + + /// + /// TryParse + /// + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static bool TryParse(string value, out Squid obj) { // Parse as Squid string. @@ -126,15 +220,24 @@ namespace Wonky.Client.Helpers obj = oGuid; return true; } + // Parse as Guid string. if (Guid.TryParse(value, out oGuid)) { obj = oGuid; return true; } + obj = Empty; return false; } + + /// + /// TryParse + /// + /// + /// + /// public static bool TryParse(string value, out Guid obj) { // Try a Squid string. @@ -146,38 +249,98 @@ namespace Wonky.Client.Helpers obj = Guid.Empty; return false; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Squid x, Squid y) { return x.Guid == y.Guid; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Squid x, Guid y) { return x.Guid == y; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Guid x, Squid y) { return y == x; // NB: order of arguments } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Squid x, Squid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Squid x, Guid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Guid x, Squid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// public static implicit operator string(Squid oSquid) { return oSquid.Value; } + + /// + /// Operator + /// + /// + /// public static implicit operator Guid(Squid oSquid) { return oSquid.Guid; } + + /// + /// Operator + /// + /// + /// public static implicit operator Squid(string value) { if (string.IsNullOrEmpty(value)) @@ -185,6 +348,12 @@ namespace Wonky.Client.Helpers return TryParse(value, out Squid oSquid) ? oSquid : Empty; } + + /// + /// Operator + /// + /// + /// public static implicit operator Squid(Guid oGuid) { return oGuid == Guid.Empty ? Empty : new Squid(oGuid); diff --git a/Wonky.Client/Helpers/StringExtensions.cs b/Wonky.Client/Helpers/StringExtensions.cs index e9168eda..51a5c3a4 100644 --- a/Wonky.Client/Helpers/StringExtensions.cs +++ b/Wonky.Client/Helpers/StringExtensions.cs @@ -17,7 +17,13 @@ namespace Wonky.Client.Helpers; public static class StringExtensions { - public static string Left(this string value, int maxLength) + /// + /// Left Pad a string with spaces until maxlength + /// + /// + /// + /// + public static string PadLeft(this string value, int maxLength) { if (string.IsNullOrEmpty(value)) return value; maxLength = Math.Abs(maxLength); diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index 75c75119..82da8565 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -21,60 +21,95 @@ namespace Wonky.Client.Helpers; public static class Utils { + /// + /// Helper to parse querystring + /// + /// + /// public static Dictionary ParseQuery(string query) { if (string.IsNullOrWhiteSpace(query) || query.Contains("://")) return new Dictionary(); - + // remove the question mark + query = query.Replace("?", ""); + // split into pairs var elements = query.Split("&"); - + // return elements as list return elements.Select( - data - => data.Split("=")) + data + => data.Split("=")) .ToDictionary(element => element[0], element => element[1]); } - + + /// + /// Validate email format + /// + /// + /// public static bool IsValidEmail(string email) { var trimmedEmail = email.Trim(); - if (trimmedEmail.EndsWith(".")) { + if (trimmedEmail.EndsWith(".")) + { return false; // suggested by @TK-421 } - try { + + try + { var addr = new MailAddress(email); return addr.Address == trimmedEmail; } - catch { + catch + { return false; } } - + + /// + /// return enum as the string value + /// + /// + /// public static string EnumToString(Enum value) { return value.ToString(); } - + + /// + /// Generate unique hashcode from time + /// + /// public static int GetHashFromNow() { return DateTime.Now.ToFileTimeUtc().GetHashCode(); } + /// + /// Get visit state as colored icon + /// + /// + /// public static string GetVisitState(string dtNextVisit) { if (dtNextVisit is "0001-01-01" or "1970-01-01") return "the-draw"; if (!DateTime.TryParse(dtNextVisit, out _)) return "the-draw"; - + var dtNow = DateTime.Now; var dtNext = DateTime.Parse(dtNextVisit); if (dtNow > dtNext) return "the-ugly"; - + return dtNow > dtNext.AddDays(-14) ? "the-bad" : "the-good"; } - + + /// + /// Translate process status to icon + /// + /// + /// public static string GetProcessStatus(string processStatus) { return processStatus.ToLower() switch @@ -86,5 +121,5 @@ public static class Utils "shipped" => "the-dead", _ => "question-square" }; - } + } } \ No newline at end of file diff --git a/Wonky.Client/Helpers/VatUtils.cs b/Wonky.Client/Helpers/VatUtils.cs index 83f77e9b..c2e05e51 100644 --- a/Wonky.Client/Helpers/VatUtils.cs +++ b/Wonky.Client/Helpers/VatUtils.cs @@ -21,14 +21,19 @@ public class VatUtils { // https://ec.europa.eu/taxation_customs/vies/faqvies.do#item_11 // https://ec.europa.eu/taxation_customs/vies/ - + /// + /// Entrypoint for validating vat number + /// + /// + /// + /// public static bool ValidateFormat(string countryCode, string vatNumber) { if (string.IsNullOrWhiteSpace(vatNumber) || string.IsNullOrWhiteSpace(countryCode) || !IsDigitsOnly(vatNumber)) return false; - + var sanitisedVat = SanitizeVatNumber(vatNumber); - + return countryCode.ToUpperInvariant() switch { "DK" => ValidateFormatDk(sanitisedVat), @@ -38,10 +43,21 @@ public class VatUtils }; } + /// + /// Validate string is only numbers + /// + /// + /// private static bool IsDigitsOnly(string check) { return check.All(c => c is >= '0' and <= '9'); } + + /// + /// Validate Danish Vat number format + /// + /// + /// private static bool ValidateFormatDk(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Denmark @@ -57,6 +73,11 @@ public class VatUtils return ValidateMod11(vatNumber); } + /// + /// Validate Norwegian Vat number format + /// + /// + /// private static bool ValidateFormatNo(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Norway @@ -69,6 +90,11 @@ public class VatUtils return long.Parse(vatNumber) != 0 && ValidateMod11(vatNumber); } + /// + /// Validate Swedish Vat number format + /// + /// + /// private static bool ValidateFormatSe(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Sweden @@ -81,7 +107,7 @@ public class VatUtils var vatToCheck = vatNumber; if (vatToCheck.Length < 10 || long.Parse(vatToCheck) == 0) return false; - + var r = new[] { 0, 2, 4, 6, 8 } .Sum(m => (int)char.GetNumericValue(vatToCheck[m]) / 5 + (int)char.GetNumericValue(vatToCheck[m]) * 2 % 10); @@ -89,11 +115,17 @@ public class VatUtils var c10 = (10 - (r + c1) % 10) % 10; if (vatToCheck.Length == 10) { - return $"{vatToCheck[..9]}{c10}" == vatNumber; + return $"{vatToCheck[..9]}{c10}" == vatNumber; } + return $"{vatToCheck[..9]}{c10}01" == vatNumber; } - + + /// + /// Modulus11 validator + /// + /// + /// private static bool ValidateMod11(string number) { if (long.Parse(number) == 0) @@ -108,14 +140,18 @@ public class VatUtils return sum % 11 == 0; } + /// + /// Sanitize Vat number to it's raw numbers + /// + /// + /// private static string SanitizeVatNumber(string vatNumber) { - return vatNumber.ToUpperInvariant() - .Replace(" ", "") + return vatNumber.Replace(" ", "") .Replace("-", "") .Replace("DK", "") .Replace("NO", "") - .Replace("SE","") + .Replace("SE", "") .Replace("MVA", ""); } } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs b/Wonky.Client/HttpInterfaces/IActivityCrmHttpRepository.cs similarity index 95% rename from Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IActivityCrmHttpRepository.cs index dbab34d8..4dcd1fc4 100644 --- a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IActivityCrmHttpRepository.cs @@ -18,7 +18,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmActivityHttpRepository +/// +/// Interface Activity CRM Http repository +/// +public interface IActivityCrmHttpRepository { /// /// Get a list of open quotes @@ -33,13 +36,6 @@ public interface ICrmActivityHttpRepository /// Task UpdateQuoteStatus(ReportItemView activity); - /// - /// Get activities by date - /// - /// - /// - Task GetActivities(string activityDate); - /// /// Create new activity /// @@ -47,12 +43,26 @@ public interface ICrmActivityHttpRepository /// Task CreateActivity(ActivityDto model); + /// + /// Get activities by date + /// + /// + /// + Task GetActivities(string activityDate); + /// /// Get activity data by id /// /// /// Task GetActivity(string activityId); + + /// + /// Get activities for customer Id + /// + /// + /// + Task> GetCustomerActivities(string customerId); /// /// Get activity by id formatted for report @@ -61,20 +71,13 @@ public interface ICrmActivityHttpRepository /// Task GetReportItem(string activityId); - /// - /// Get activities for customer Id - /// - /// - /// - Task> GetCustomerActivities(string customerId); - /// /// Set backend process state to express /// /// /// ApiResponseView Task GetExpressState(string activityId); - + /// /// Update office note for activity /// diff --git a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs index 3b07d212..68770aa9 100644 --- a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs @@ -19,7 +19,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICatalogHttpRepository +/// +/// Interface Catalog Http repository +/// +public interface ICatalogCrmHttpRepository { /// /// Get a paged sales item list @@ -28,6 +31,14 @@ public interface ICatalogHttpRepository /// Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters); + /// + /// Get a paged sales item list for country + /// + /// + /// + /// + Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters, string countryCode); + /// /// Get sales item by id /// @@ -43,7 +54,7 @@ public interface ICatalogHttpRepository Task GetSalesItemSku(string sku); /// - /// Overload Get sales item by id and country code + /// Overload Get sales item by sku and country code /// /// /// @@ -57,5 +68,16 @@ public interface ICatalogHttpRepository /// Task GetSalesVariantId(string variantId); + /// + /// Complete catalog for print + /// + /// Task> GetPriceList(); + + /// + /// Complete catalog for print country + /// + /// + /// + Task> GetPriceList(string countryCode); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs b/Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs new file mode 100644 index 00000000..633723fa --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs @@ -0,0 +1,47 @@ +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Contacts CRM Http repository +/// +/// +public interface IContactCrmHttpRepository +{ + /// + /// Create Contact + /// + /// + /// + Task CreateContact(ContactDto model); + + /// + /// Get Contact + /// + /// + /// + /// + Task GetContact(string companyId, string contactId); + + /// + /// Get Contacts + /// + /// + /// + Task> GetContacts(string companyId); + + /// + /// Delete Contact + /// + /// + /// + /// + Task DeleteContact(string companyId, string contactId); + + /// + /// Update Contact + /// + /// + /// + Task UpdateContact(ContactDto model); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs deleted file mode 100644 index 685b999f..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Wonky.Entity.DTO; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmContactHttpRepository -{ - Task CreateContact(ContactDto model); - Task GetContact(string companyId, string contactId); - Task> GetContacts(string companyId); - Task DeleteContact(string companyId, string contactId); - Task UpdateContact(ContactDto model); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs deleted file mode 100644 index d6211053..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmReportHttpRepository -{ - Task ReportExist(string workDate); - Task> GetReports(); - Task GetReport(string workDate); - Task InitializeReportData(string workDate); - Task PostReport(string workDate, ReportDto reportDto); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs deleted file mode 100644 index 3a15fb3c..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using Wonky.Entity.DTO; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmTaskItemHttpRepository -{ - Task?> GetTaskList(); - Task?> GetTaskList(string workDate); - Task GetTaskItem(string taskItemId); - Task CreateTaskItem(TaskItemDto taskItem); - Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem); - Task DeleteTaskItem(string taskItemId); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICustomerCrmHttpRepository.cs similarity index 81% rename from Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs rename to Wonky.Client/HttpInterfaces/ICustomerCrmHttpRepository.cs index 4c90faab..e5bd56b7 100644 --- a/Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICustomerCrmHttpRepository.cs @@ -19,48 +19,57 @@ using Wonky.Entity.Requests; namespace Wonky.Client.HttpInterfaces; -public interface ICrmCompanyHttpRepository +/// +/// Interface Customer CRM Http repository +/// +public interface ICustomerCrmHttpRepository { /// - /// Get a list of CRM entities + /// Get a list of CRM customers (SalesRep) /// /// /// A paged response defined by pagingParameters - Task> GetCompanies(CompanyPagingParams pagingParameters); + Task> GetCompanies(CustomerPaging pagingParameters); + /// - /// Get CRM entity by Id + /// Get CRM customer by Id (SalesRep) /// /// /// A CRM Company entity Task GetCompanyById(string companyId); + /// - /// Create new CRM entity + /// Create Customer (SalesRep) /// /// /// The Id of the entity Task CreateCompany(CompanyDto model); + /// - /// Delete the CRM entity + /// Delete the CRM customer (SalesRep) /// /// /// true/false to define success Task DeleteCompany(string companyId); + /// - /// Update CRM entity properties + /// Update CRM customer properties (SalesRep) /// /// /// /// A CRM Company entity Task UpdateCrmData(string companyId, CompanyDto model); + /// - /// Update ERP entity properties + /// Update ERP customer properties (SalesRep) /// /// /// /// A CRM Company entity Task UpdateErpData(string companyId, CompanyDto model); + /// - /// Update Entity Vat Number + /// Update customer Vat Number (SalesRep) /// /// /// diff --git a/Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs new file mode 100644 index 00000000..360812d2 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs @@ -0,0 +1,70 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface Customer History CRM Http repository +/// +public interface ICustomerHistoryCrmHttpRepository +{ + /// + /// Fetch Invoice LIst + /// + /// + /// + Task FetchInvoiceList(string companyId); + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + Task FetchInvoice(string companyId, string invoiceId); + + /// + /// Fetch inventory from given customer + /// + /// + /// + Task> FetchInventory(string companyId); + + /// + /// Fetch History for given customer + /// + /// + /// + Task> FetchHistory(string companyId); + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + Task> FetchHistory(string companyId, string sku); + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + Task ErpInvoiceToCrmRpc(string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs new file mode 100644 index 00000000..c5cffab2 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs @@ -0,0 +1,57 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Client.Features; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Customer Office Http repository +/// +public interface ICustomerOfficeHttpRepository +{ + /// + /// Get customers paged for given country + /// + /// + /// + /// + Task> GetCompaniesPaged(CustomerPaging pagingParameters, string countryCode); + + /// + /// Get customers paged for given sales rep + /// + /// + /// + /// + Task> GetCompaniesPagedSalesRep(string salesRepId, CustomerPaging pagingParameters); + + /// + /// Get customer by Id + /// + /// + /// + Task GetByCustomerId(string companyId); + + /// + /// Update Company data + /// + /// + /// + /// + Task UpdateCompany(string companyId, CompanyDto model); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs deleted file mode 100644 index 746c2308..00000000 --- a/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Client.Features; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpInterfaces; - -public interface IOfficeCustomerHttpRepository -{ - Task> GetCompaniesPaged(CompanyPagingParams pagingParameters); - Task> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters); - Task GetByCustomerId(string companyId); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/IReportHttpRepository.cs new file mode 100644 index 00000000..f6cfa923 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IReportHttpRepository.cs @@ -0,0 +1,75 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface Report Http repository +/// +public interface IReportHttpRepository +{ + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + Task ReportExist(string workDate); + + /// + /// Get Reports for (SalesRep) + /// + /// + Task> GetReports(); + + /// + /// Get Report for given date (SalesRep) + /// + /// + /// + Task GetReport(string workDate); + + /// + /// Initialize Report for given data (SalesRep) + /// + /// + /// + Task InitializeReportData(string workDate); + + /// + /// Create Report for given data - using reportData + /// + /// + /// + /// + Task CreateReport(string workDate, ReportDto reportDto); + + /// + /// Get Reports for given userId (Office) + /// + /// + /// + Task> GetCountryReports(string userId); + + /// + /// Get Report for given userId and workDate (Office) + /// + /// + /// + /// + Task GetCountryReport(string userId, string workDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs b/Wonky.Client/HttpInterfaces/IReportOfficeHttpRepository.cs similarity index 56% rename from Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IReportOfficeHttpRepository.cs index fc83c7c7..a70d909e 100644 --- a/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IReportOfficeHttpRepository.cs @@ -18,12 +18,24 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmHistoryHttpRepository +/// +/// Interface for Report http repository +/// +/// Possibly duplicated in IReportHttpRepository +public interface IReportOfficeHttpRepository { - Task FetchInvoiceList(string companyId); - Task FetchInvoice(string companyId, string invoiceId); - Task> FetchInventory(string companyId); - Task> FetchHistory(string companyId); - Task> FetchHistory(string companyId, string sku); - Task ErpInvoiceToCrmRpc(string companyId, string syncDate); + /// + /// Get reports for given userId + /// + /// + /// + Task> GetReports(string userId); + + /// + /// Get report for given userId and workDate + /// + /// + /// + /// + Task GetReport(string userId, string workDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ISendMailService.cs b/Wonky.Client/HttpInterfaces/ISendMailService.cs index 14d5d163..719f150a 100644 --- a/Wonky.Client/HttpInterfaces/ISendMailService.cs +++ b/Wonky.Client/HttpInterfaces/ISendMailService.cs @@ -3,7 +3,16 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; +/// +/// Interface for sending emai +/// public interface ISendMailService { + /// + /// Send Mail + /// + /// + /// + /// Task SendMail(string messageType, EmailMessage message); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs b/Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs new file mode 100644 index 00000000..d881f124 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs @@ -0,0 +1,66 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for handling CRM Tasks http repository +/// +public interface ITaskItemCrmHttpRepository +{ + /// + /// Get Task List (SalesRep) + /// + /// + Task> GetTaskList(); + + /// + /// Get Task List for given workDate (SalesRep) + /// + /// + /// + Task> GetTaskList(string workDate); + + /// + /// Get Task Item by id (SalesRep) + /// + /// + /// + Task GetTaskItem(string taskItemId); + + /// + /// Create task using taskItem (SalesRep) + /// + /// + /// + Task CreateTaskItem(TaskItemDto taskItem); + + /// + /// Delete Task Item (SalesRep + /// + /// + /// + Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem); + + /// + /// Delete Task Item (SalesRep + /// + /// + /// + Task DeleteTaskItem(string taskItemId); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs b/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs index 08f17f94..fcb5223d 100644 --- a/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs @@ -18,13 +18,59 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; +/// +/// Interface for User handling over http +/// public interface IUserHttpRepository { + /// + /// Get Advisors (Office) + /// + /// Task> GetAdvisors(); + + /// + /// Get Advisor Info for given userId + /// + /// + /// Task GetAdvisorInfo(string userId); + + /// + /// Update Advisor using userId and updated data + /// + /// + /// + /// Task UpdateAdvisor(string userId, UserUpdateDto model); + + /// + /// Get Administrative Users + /// + /// Task> GetAdminUsers(); + + /// + /// Get Admin Info for giver userId + /// + /// + /// Task GetAdminUserInfo(string userId); + + /// + /// Update Admin user using userId and updated data + /// + /// + /// + /// Task UpdateAdminUser(string userId, UserUpdateDto model); + + /// + /// Set new user password + /// + /// + /// + /// + /// Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs b/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs index afa8842b..d03b9255 100644 --- a/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs @@ -17,9 +17,37 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; +/// +/// Interface for processing orders in warehouse +/// public interface IWarehouseHttpRepository { + /// + /// Get warehouse order list by date + /// + /// + /// + Task> GetWarehouseOrderListByDate(string date); + + /// + /// Get orders by status + /// + /// + /// + /// Task> GetWarehouseOrderListByStatus(string status, string express = ""); + + /// + /// Get order with orderId + /// + /// + /// Task GetWarehouseOrder(string orderId); + + /// + /// Update Order status setting new process status + /// + /// + /// Task UpdateWarehouseOrderStatus(WarehouseProcess process); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs b/Wonky.Client/HttpInterfaces/IWorkplaceCrmHttpRepository.cs similarity index 51% rename from Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IWorkplaceCrmHttpRepository.cs index 740c3a01..21de0e06 100644 --- a/Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IWorkplaceCrmHttpRepository.cs @@ -18,11 +18,47 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmWorkplaceHttpRepository +/// +/// Interface for handling Customer Workplaces (chemical document service) +/// +public interface IWorkplaceCrmHttpRepository { + /// + /// Get Workplaces for given customer id + /// + /// + /// Task> GetWorkplaces(string companyId); + + /// + /// Get specific workplace using customer id and workplace id + /// + /// + /// + /// Task GetWorkplace(string companyId, string workplaceId); + + /// + /// Create new workplace given the customer id and workplace data + /// + /// + /// + /// Task CreateWorkplace(string companyId, WorkplaceDto workplace); + + /// + /// Update workplace given the customer id and updated data + /// + /// + /// + /// Task UpdateWorkplace(string companyId, WorkplaceDto workplace); + + /// + /// Delete workplace given customer id and workplace id + /// + /// + /// + /// Task DeleteWorkplace(string companyId, string workplaceId); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs b/Wonky.Client/HttpRepository/ActivityCrmHttpRepository.cs similarity index 92% rename from Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs rename to Wonky.Client/HttpRepository/ActivityCrmHttpRepository.cs index 2e1d877b..4e167378 100644 --- a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ActivityCrmHttpRepository.cs @@ -25,7 +25,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmActivityHttpRepository : ICrmActivityHttpRepository +/// +/// Implementing Interface Activity CRM Http repository +/// +public class ActivityCrmHttpRepository : IActivityCrmHttpRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { @@ -33,12 +36,12 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmActivityHttpRepository(HttpClient client, - ILogger logger, + public ActivityCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -48,9 +51,9 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository } /// - /// Get a list of quotes + /// Get a list of open quotes /// - /// List of activities with Quote status + /// List of Activities with ActivityStatus == Quote public async Task> GetQuotes() { return await _client.GetFromJsonAsync>($"{_api.CrmActivities}/quotes", _options); @@ -63,7 +66,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// public async Task UpdateQuoteStatus(ReportItemView activity) { - var response = await _client.PutAsJsonAsync( + var response = await _client.PutAsJsonAsync( $"{_api.CrmActivities}/quote/{activity.ActivityId}", activity, _options); var content = await response.Content.ReadAsStringAsync(); _logger.LogDebug("UpdateQuote Response Content <= {}", content); diff --git a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs b/Wonky.Client/HttpRepository/CatalogHttpRepository.cs index 3ad86041..5c476c28 100644 --- a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CatalogHttpRepository.cs @@ -31,7 +31,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CatalogHttpRepository : ICatalogHttpRepository +public class CatalogCrmHttpRepository : ICatalogCrmHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -39,12 +39,12 @@ public class CatalogHttpRepository : ICatalogHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CatalogHttpRepository(HttpClient client, - ILogger logger, + public CatalogCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -91,6 +91,45 @@ public class CatalogHttpRepository : ICatalogHttpRepository return pagingResponse; } + /// + /// Get a paged sales item list for country + /// + /// + /// + /// + public async Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters, string countryCode) + { + var queryString = new Dictionary + { + ["pageNumber"] = pagingParameters.PageNumber.ToString(), + ["pageSize"] = pagingParameters.PageSize.ToString(), + ["orderBy"] = pagingParameters.OrderBy, + ["searchColumn"] = pagingParameters.SearchColumn, + ["searchTerm"] = pagingParameters.SearchTerm, + ["selectGroup"] = pagingParameters.SelectGroup == "0" ? "" : pagingParameters.SelectGroup, + }; + var response = await _client + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/{countryCode}/page", queryString)); + + if (!response.IsSuccessStatusCode) + { + return new PagingResponse + { + Items = new List(), + MetaData = new MetaData() + }; + } + var content = await response.Content.ReadAsStringAsync(); + + var pagingResponse = new PagingResponse + { + Items = JsonSerializer.Deserialize>(content, _options), + MetaData = JsonSerializer.Deserialize( + response.Headers.GetValues("X-Pagination").First(), _options) + }; + return pagingResponse; + } + /// /// Get sales item by id /// @@ -115,7 +154,7 @@ public class CatalogHttpRepository : ICatalogHttpRepository } /// - /// Overload Get sales item by id and country code + /// Overload Get sales item by sku and country code /// /// /// @@ -137,9 +176,24 @@ public class CatalogHttpRepository : ICatalogHttpRepository .GetFromJsonAsync($"{_apiConfig.Catalog}/variant/{variantId}"); return salesItem ?? new SalesItemView(); } - + + /// + /// Complete catalog for print + /// + /// public async Task> GetPriceList() { return await _client.GetFromJsonAsync>($"{_apiConfig.Catalog}", _options); } + + /// + /// Complete catalog for print country + /// + /// + /// + public async Task> GetPriceList(string countryCode) + { + return await _client.GetFromJsonAsync>($"{_apiConfig.Catalog}/{countryCode}", _options); + } + } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmContactHttpRepository.cs b/Wonky.Client/HttpRepository/ContactCrmHttpRepository.cs similarity index 71% rename from Wonky.Client/HttpRepository/CrmContactHttpRepository.cs rename to Wonky.Client/HttpRepository/ContactCrmHttpRepository.cs index 83e93730..285c6c1c 100644 --- a/Wonky.Client/HttpRepository/CrmContactHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ContactCrmHttpRepository.cs @@ -8,7 +8,7 @@ using Wonky.Entity.DTO; namespace Wonky.Client.HttpRepository; -public class CrmContactHttpRepository : ICrmContactHttpRepository +public class ContactCrmHttpRepository : IContactCrmHttpRepository { private readonly JsonSerializerOptions _options = new () { @@ -16,12 +16,12 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _conf; - public CrmContactHttpRepository(HttpClient client, - ILogger logger, + public ContactCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions apiConfig) { @@ -32,9 +32,10 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository } /// - /// Create contact + /// Create Contact /// /// + /// public async Task CreateContact(ContactDto model) { var response = await _client.PostAsJsonAsync( @@ -42,13 +43,23 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository return await response.Content.ReadAsStringAsync(); } - + /// + /// Get Contact + /// + /// + /// + /// public async Task GetContact(string companyId, string contactId) { return await _client.GetFromJsonAsync( $"{_conf.CrmCustomers}/{companyId}/contacts/{contactId}"); } + /// + /// Get Contacts + /// + /// + /// public async Task> GetContacts(string companyId) { var response = await _client.GetAsync( @@ -58,13 +69,23 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository ? new List() : JsonSerializer.Deserialize>(content, _options); } - + /// + /// Delete Contact + /// + /// + /// + /// public async Task DeleteContact(string companyId, string contactId) { await _client.DeleteAsync( $"{_conf.CrmCustomers}/{companyId}/contacts/{contactId}"); } + /// + /// Update Contact + /// + /// + /// public async Task UpdateContact(ContactDto model) { await _client.PutAsJsonAsync( diff --git a/Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs b/Wonky.Client/HttpRepository/CustomerCrmHttpRepository.cs similarity index 85% rename from Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs rename to Wonky.Client/HttpRepository/CustomerCrmHttpRepository.cs index 73054895..9161989c 100644 --- a/Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CustomerCrmHttpRepository.cs @@ -34,7 +34,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository +public class CustomerCrmCrmHttpRepository : ICustomerCrmHttpRepository { private readonly JsonSerializerOptions _options = new () { @@ -42,12 +42,12 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _conf; - public CrmCompanyHttpRepository(HttpClient client, - ILogger logger, + public CustomerCrmCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions apiConfig) { @@ -58,11 +58,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Get from crm endpoint + /// Get a list of CRM customers (SalesRep) /// /// - /// Paged response - public async Task> GetCompanies(CompanyPagingParams pagingParameters) + /// A paged response defined by pagingParameters + public async Task> GetCompanies(CustomerPaging pagingParameters) { var queryString = new Dictionary { @@ -93,17 +93,21 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; return pagingResponse; } - + /// + /// Get CRM customer by Id (SalesRep) + /// + /// + /// A CRM Company entity public async Task GetCompanyById(string companyId) { return await _client.GetFromJsonAsync($"{_conf.CrmCustomers}/{companyId}", _options); } /// - /// Create company from model + /// Create Customer (SalesRep) /// /// - /// company id + /// The Id of the entity public async Task CreateCompany(CompanyDto model) { var response = await _client.PostAsJsonAsync($"{_conf.CrmCustomers}", model, _options); @@ -113,10 +117,10 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Delete company + /// Delete the CRM customer (SalesRep) /// /// - /// + /// true/false to define success public async Task DeleteCompany(string companyId) { var response = await _client.DeleteAsync($"{_conf.CrmCustomers}/{companyId}"); @@ -124,11 +128,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update Company CRM properties + /// Update CRM customer properties (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateCrmData(string companyId, CompanyDto model) { var updateModel = new UpdateCrmDto @@ -146,11 +150,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update Company ERP properties + /// Update ERP customer properties (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateErpData(string companyId, CompanyDto model) { var updateModel = new UpdateErpDto @@ -172,11 +176,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update company VAT number + /// Update customer Vat Number (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateCompanyVat(string companyId, string vatNumber) { var model = new Dictionary diff --git a/Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs b/Wonky.Client/HttpRepository/CustomerHistoryCrmHttpRepository.cs similarity index 87% rename from Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs rename to Wonky.Client/HttpRepository/CustomerHistoryCrmHttpRepository.cs index 2d33cbde..25fa1eaa 100644 --- a/Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CustomerHistoryCrmHttpRepository.cs @@ -25,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository +public class CustomerHistoryCrmHttpRepository : ICustomerHistoryCrmHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -33,12 +33,12 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmHistoryHttpRepository( - HttpClient client, ILogger logger, + public CustomerHistoryCrmHttpRepository( + HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -48,7 +48,7 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// fetch a list of invoices for CompanyId + /// Fetch Invoice LIst /// /// /// @@ -62,7 +62,7 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch invoice from archiveHeadId + /// Fetch given invoice for given customer /// /// /// @@ -74,10 +74,10 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// fetch inventory - summarized list of products + /// Fetch inventory from given customer /// /// - /// List of products + /// public async Task> FetchInventory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmInventoryExt}"); @@ -90,10 +90,10 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch history for all products + /// Fetch History for given customer /// /// - /// List of products + /// public async Task> FetchHistory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}"); @@ -106,11 +106,11 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch history for single product + /// Fetch history for given customer and a given product /// /// /// - /// list of products + /// public async Task> FetchHistory(string companyId, string sku) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}/{sku}"); @@ -123,11 +123,11 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// execute a remote procedure designed to update crm database from erp system based on a date string + /// RPC call to initiate remote server sync for given customer /// /// /// - /// date string + /// public async Task ErpInvoiceToCrmRpc(string companyId, string syncDate) { var x = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmRpcSyncExt}/{syncDate}"); diff --git a/Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs b/Wonky.Client/HttpRepository/CustomerOfficeHttpRepository.cs similarity index 77% rename from Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs rename to Wonky.Client/HttpRepository/CustomerOfficeHttpRepository.cs index 61beb540..f2787c0a 100644 --- a/Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CustomerOfficeHttpRepository.cs @@ -34,66 +34,36 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository +public class CustomerOfficeHttpRepository : ICustomerOfficeHttpRepository { private readonly JsonSerializerOptions _options = new () { PropertyNameCaseInsensitive = true }; - private readonly NavigationManager _navigation; - private ILogger _logger; + private readonly NavigationManager _navigator; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public OfficeCustomerHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public CustomerOfficeHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigator, IOptions apiConfig) { _client = client; _logger = logger; - _navigation = navigation; + _navigator = navigator; _api = apiConfig.Value; } - - /// - /// Get paged list of customer entities by sales rep id - /// - /// - /// - /// - public async Task> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters) - { - var queryString = new Dictionary - { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = pagingParameters.SearchTerm, - ["searchColumn"] = pagingParameters.SearchColumn, - ["orderBy"] = pagingParameters.OrderBy, - ["isHidden"] = pagingParameters.IsHidden.ToString(), - ["hasFolded"] = pagingParameters.HasFolded.ToString(), - ["countryCode"] = pagingParameters.CountryCode - }; - - var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString)); - var content = await response.Content.ReadAsStringAsync(); - var pagingResponse = new PagingResponse - { - Items = JsonSerializer.Deserialize>(content, _options), - MetaData = JsonSerializer.Deserialize(response.Headers.GetValues("X-Pagination").First(), _options) - }; - return pagingResponse; - } - /// - /// Get paged list of customer companies by country code + /// Get customers paged for given sales rep /// /// + /// /// - public async Task> GetCompaniesPaged(CompanyPagingParams pagingParameters) + public async Task> GetCompaniesPaged(CustomerPaging pagingParameters, string countryCode) { var queryString = new Dictionary { @@ -118,6 +88,36 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository return pagingResponse; } + /// + /// Get customers paged for given sales rep + /// + /// + /// + /// + public async Task> GetCompaniesPagedSalesRep(string salesRepId, CustomerPaging pagingParameters) + { + var queryString = new Dictionary + { + ["pageNumber"] = pagingParameters.PageNumber.ToString(), + ["pageSize"] = pagingParameters.PageSize.ToString(), + ["searchTerm"] = pagingParameters.SearchTerm, + ["searchColumn"] = pagingParameters.SearchColumn, + ["orderBy"] = pagingParameters.OrderBy, + ["isHidden"] = pagingParameters.IsHidden.ToString(), + ["hasFolded"] = pagingParameters.HasFolded.ToString(), + ["countryCode"] = pagingParameters.CountryCode + }; + + var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString)); + var content = await response.Content.ReadAsStringAsync(); + var pagingResponse = new PagingResponse + { + Items = JsonSerializer.Deserialize>(content, _options), + MetaData = JsonSerializer.Deserialize(response.Headers.GetValues("X-Pagination").First(), _options) + }; + return pagingResponse; + + } /// /// Get customer entity by id /// @@ -128,22 +128,9 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository var company = await _client.GetFromJsonAsync($"{_api.OfficeCustomers}/id/{companyId}"); return company ?? new CompanyDto(); } - + /// - /// Create company from model - /// - /// - /// company id - public async Task CreateCompany(CompanyDto model) - { - var response = await _client.PostAsJsonAsync($"{_api.OfficeCustomers}", model); - var content = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(content, _options); - return result.CompanyId; - } - - /// - /// Update company card + /// Update Company data /// /// /// @@ -156,14 +143,4 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository return response.IsSuccessStatusCode; } - /// - /// Delete company - /// - /// - /// - public async Task DeleteCompany(string companyId) - { - var response = await _client.DeleteAsync($"{_api.OfficeCustomers}/{companyId}"); - return response.IsSuccessStatusCode; - } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs b/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs deleted file mode 100644 index 42319199..00000000 --- a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System.Net.Http.Json; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Options; -using Wonky.Client.HttpInterfaces; -using Wonky.Entity.Configuration; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpRepository; - -public class OfficeReportHttpRepository : IOfficeReportHttpRepository -{ - private readonly JsonSerializerOptions _options = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }; - - private readonly NavigationManager _navigation; - private ILogger _logger; - private readonly HttpClient _client; - private readonly ApiConfig _apiConfig; - - public OfficeReportHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, IOptions configuration) - { - _client = client; - _logger = logger; - _navigation = navigation; - _apiConfig = configuration.Value; - } - - public async Task> GetReports(string userId) - { - return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); - } - - public async Task GetReport(string userId, string workDate) - { - return await _client.GetFromJsonAsync($"{_apiConfig.OfficeReports}/{userId}/{workDate}"); - - } -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs b/Wonky.Client/HttpRepository/ReportHttpRepository.cs similarity index 59% rename from Wonky.Client/HttpRepository/CrmReportHttpRepository.cs rename to Wonky.Client/HttpRepository/ReportHttpRepository.cs index 71074793..c9f4f551 100644 --- a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ReportHttpRepository.cs @@ -25,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmReportHttpRepository :ICrmReportHttpRepository +public class ReportHttpRepository : IReportHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -33,12 +33,12 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CrmReportHttpRepository(HttpClient client, - ILogger logger, + public ReportHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -47,22 +47,42 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository _apiConfig = configuration.Value; } - public async Task> GetReports() - { - return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); - } + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// public async Task ReportExist(string workDate) { var result = await _client.GetFromJsonAsync( $"{_apiConfig.CrmReports}/exist/{workDate}"); return result.ReportClosed; } - + + /// + /// Get Reports for (SalesRep) + /// + /// + public async Task> GetReports() + { + return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); + } + + /// + /// Get Report for given date (SalesRep) + /// + /// + /// public async Task GetReport(string workDate) { return await _client.GetFromJsonAsync($"{_apiConfig.CrmReports}/{workDate}"); - } + + /// + /// Initialize Report for given data (SalesRep) + /// + /// + /// public async Task InitializeReportData(string workDate) { var initData = await _client @@ -70,13 +90,19 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository return initData ?? new ReportInitDto(); } - public async Task PostReport(string workDate, ReportDto reportDto) + /// + /// Create Report for given data - using reportData + /// + /// + /// + /// + public async Task CreateReport(string workDate, ReportDto reportDto) { var response = await _client .PostAsJsonAsync($"{_apiConfig.CrmReports}/{workDate}", reportDto, _options); - + var jsonDate = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(jsonDate); + var result = JsonSerializer.Deserialize(jsonDate); return new ApiResponseView { Code = result.Code, @@ -85,4 +111,25 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository IsSuccess = result.IsSuccess }; } + + /// + /// Get Reports for given userId (Office) + /// + /// + /// + public async Task> GetCountryReports(string userId) + { + return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); + } + + /// + /// Get Report for given userId and workDate (Office) + /// + /// + /// + /// + public async Task GetCountryReport(string userId, string workDate) + { + return await _client.GetFromJsonAsync($"{_apiConfig.OfficeReports}/{userId}/{workDate}"); + } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/SendMailService.cs b/Wonky.Client/HttpRepository/SendMailService.cs index 3281b434..2a6e4177 100644 --- a/Wonky.Client/HttpRepository/SendMailService.cs +++ b/Wonky.Client/HttpRepository/SendMailService.cs @@ -16,13 +16,13 @@ public class SendMailService : ISendMailService { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public SendMailService(HttpClient client, ILogger logger, + public SendMailService(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -30,14 +30,20 @@ public class SendMailService : ISendMailService _navigation = navigation; _api = configuration.Value; } - + + /// + /// Send Mail + /// + /// + /// + /// public async Task SendMail(string messageType, EmailMessage message) { var response = await _client.PostAsJsonAsync($"{_api.ServicesMail}/{messageType}", message, _options); if (!response.IsSuccessStatusCode) return new ApiResponseView { - Code = (int) response.StatusCode, + Code = (int)response.StatusCode, Message = $"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}", IsSuccess = false, Id = "" diff --git a/Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs b/Wonky.Client/HttpRepository/TaskItemCrmHttpRepository.cs similarity index 71% rename from Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs rename to Wonky.Client/HttpRepository/TaskItemCrmHttpRepository.cs index c2c01e8b..655eb177 100644 --- a/Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs +++ b/Wonky.Client/HttpRepository/TaskItemCrmHttpRepository.cs @@ -26,21 +26,21 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmTaskItemHttpRepository : ICrmTaskItemHttpRepository +public class TaskItemCrmHttpRepository : ITaskItemCrmHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CrmTaskItemHttpRepository(HttpClient client, - ILogger logger, + public TaskItemCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -49,32 +49,60 @@ public class CrmTaskItemHttpRepository : ICrmTaskItemHttpRepository _apiConfig = configuration.Value; } - + /// + /// Get Task List (SalesRep) + /// + /// public async Task?> GetTaskList() { return await _client.GetFromJsonAsync>($"{_apiConfig.CrmTasks}", _options); } + /// + /// Get Task List for given workDate (SalesRep) + /// + /// + /// public async Task?> GetTaskList(string workDate) { return await _client.GetFromJsonAsync>($"{_apiConfig.CrmTasks}/date/{workDate}", _options); } + /// + /// Get Task Item by id (SalesRep) + /// + /// + /// public async Task GetTaskItem(string taskItemId) { return await _client.GetFromJsonAsync($"{_apiConfig.CrmTasks}/{taskItemId}", _options); } - + + /// + /// Create task using taskItem (SalesRep) + /// + /// + /// public async Task CreateTaskItem(TaskItemDto taskItem) { await _client.PostAsJsonAsync($"{_apiConfig.CrmTasks}", taskItem, _options); } - + + /// + /// Delete Task Item (SalesRep + /// + /// + /// public async Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem) { await _client.PutAsJsonAsync($"{_apiConfig.CrmTasks}/{taskItemId}", taskItem, _options); } - + + /// + /// Delete Task Item (SalesRep + /// + /// + /// public async Task DeleteTaskItem(string taskItemId) { await _client.DeleteAsync($"{_apiConfig.CrmTasks}/{taskItemId}"); diff --git a/Wonky.Client/HttpRepository/UserHttpRepository.cs b/Wonky.Client/HttpRepository/UserHttpRepository.cs index ab00e9dc..8597ba03 100644 --- a/Wonky.Client/HttpRepository/UserHttpRepository.cs +++ b/Wonky.Client/HttpRepository/UserHttpRepository.cs @@ -31,13 +31,13 @@ public class UserHttpRepository : IUserHttpRepository { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public UserHttpRepository(HttpClient client, ILogger logger, + public UserHttpRepository(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -45,40 +45,78 @@ public class UserHttpRepository : IUserHttpRepository _navigation = navigation; _api = configuration.Value; } - + + /// + /// Get Advisors (Office) + /// + /// public async Task> GetAdvisors() { return await _client.GetFromJsonAsync>(_api.OfficeAdvisors); } - + + /// + /// Get Advisor Info for given userId + /// + /// + /// public async Task GetAdvisorInfo(string userId) { return await _client.GetFromJsonAsync($"{_api.OfficeAdvisors}/{userId}"); } + /// + /// Update Advisor using userId and updated data + /// + /// + /// + /// public async Task UpdateAdvisor(string userId, UserUpdateDto model) { await _client.PutAsJsonAsync($"{_api.OfficeAdvisors}/{userId}", model, _options); } + /// + /// Get Administrative Users + /// + /// public async Task> GetAdminUsers() { return await _client.GetFromJsonAsync>(_api.OfficeUsers); } + /// + /// Get Admin Info for giver userId + /// + /// + /// public async Task GetAdminUserInfo(string userId) { return await _client.GetFromJsonAsync($"{_api.OfficeUsers}/{userId}"); } - + + /// + /// Update Admin user using userId and updated data + /// + /// + /// + /// public async Task UpdateAdminUser(string userId, UserUpdateDto model) { await _client.PutAsJsonAsync($"{_api.OfficeUsers}/{userId}", model, _options); } + /// + /// Set new user password + /// + /// + /// + /// + /// public async Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd) { - var passwd = new Dictionary {{"newPassword", newPasswd}, {"confirmPassword", confirmPasswd}}; + var passwd = new Dictionary + { { "newPassword", newPasswd }, { "confirmPassword", confirmPasswd } }; await _client.PostAsJsonAsync($"{_api.OfficeUserPasswd}/{userId}", passwd, _options); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs b/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs index ec429f4e..b0af0c0d 100644 --- a/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs +++ b/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs @@ -29,7 +29,7 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; private ILogger _logger; private readonly HttpClient _client; @@ -37,7 +37,7 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository public WarehouseHttpRepository(HttpClient client, ILogger logger, - NavigationManager navigation, + NavigationManager navigation, IOptions configuration) { _client = client; @@ -46,20 +46,43 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository _api = configuration.Value; } + /// + /// Get warehouse order list by date + /// + /// + /// public async Task> GetWarehouseOrderListByDate(string date) { return await _client.GetFromJsonAsync>($"{_api.Warehouse}?date={date}", _options); } - + + /// + /// Get orders by status + /// + /// + /// + /// public async Task> GetWarehouseOrderListByStatus(string status, string express = "") { - return await _client.GetFromJsonAsync>($"{_api.Warehouse}?status={status}&express={express}", _options); + return await _client.GetFromJsonAsync>( + $"{_api.Warehouse}?status={status}&express={express}", _options); } + /// + /// Get order with orderId + /// + /// + /// public async Task GetWarehouseOrder(string orderId) { return await _client.GetFromJsonAsync($"{_api.Warehouse}/{orderId}", _options); } + + /// + /// Update Order status setting new process status + /// + /// + /// public async Task UpdateWarehouseOrderStatus(WarehouseProcess process) { _logger.LogDebug("process => {}", JsonSerializer.Serialize(process, _options)); diff --git a/Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs b/Wonky.Client/HttpRepository/WorkplaceCrmHttpRepository.cs similarity index 68% rename from Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs rename to Wonky.Client/HttpRepository/WorkplaceCrmHttpRepository.cs index ea91b497..06d42e08 100644 --- a/Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs +++ b/Wonky.Client/HttpRepository/WorkplaceCrmHttpRepository.cs @@ -24,21 +24,21 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository +public class WorkplaceCrmHttpRepository : IWorkplaceCrmHttpRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmWorkplaceHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public WorkplaceCrmHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) { _client = client; @@ -46,7 +46,12 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository _navigation = navigation; _api = configuration.Value; } - + + /// + /// Get Workplaces for given customer id + /// + /// + /// public async Task> GetWorkplaces(string companyId) { var result = await _client.GetFromJsonAsync>( @@ -54,6 +59,12 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository return result ?? new List(); } + /// + /// Get specific workplace using customer id and workplace id + /// + /// + /// + /// public async Task GetWorkplace(string companyId, string workplaceId) { var result = await _client.GetFromJsonAsync( @@ -61,18 +72,36 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository return result ?? new WorkplaceDto(); } + /// + /// Create new workplace given the customer id and workplace data + /// + /// + /// + /// public async Task CreateWorkplace(string companyId, WorkplaceDto workplace) { await _client.PostAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", workplace, _options); } + /// + /// Update workplace given the customer id and updated data + /// + /// + /// + /// public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace) { await _client.PutAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplace.WorkplaceId}", workplace, _options); } + /// + /// Delete workplace given customer id and workplace id + /// + /// + /// + /// public async Task DeleteWorkplace(string companyId, string workplaceId) { await _client.DeleteAsync( diff --git a/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs b/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs index 75cb6ed2..4b280514 100644 --- a/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs @@ -43,11 +43,11 @@ public partial class ActivityCreateCrmPage : IDisposable [Inject] public IToastService Toast { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository Catalog { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository CatalogCrm { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } // variables private readonly JsonSerializerOptions? _options = new() {PropertyNameCaseInsensitive = true}; private SalesItemView SelectedItem { get; set; } = new(); @@ -258,7 +258,7 @@ public partial class ActivityCreateCrmPage : IDisposable // get selected item if (string.IsNullOrWhiteSpace(sku.ItemId)) return; - SelectedItem = await Catalog.GetSalesItemId(sku.ItemId); + SelectedItem = await CatalogCrm.GetSalesItemId(sku.ItemId); ShowItem = true; Price = sku.Rate; Quantity = sku.Quantity; diff --git a/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs b/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs index c255395a..c848db43 100644 --- a/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs +++ b/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs @@ -29,8 +29,8 @@ public partial class ActivityListCustomerPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } private List Activities { get; set; } = new(); private CompanyDto Company { get; set; } = new(); private bool Working { get; set; } = true; @@ -48,7 +48,7 @@ public partial class ActivityListCustomerPage : IDisposable private async Task GetActivities() { Working = true; - Activities = await CrmActivityRepo.GetCustomerActivities(CompanyId); + Activities = await ActivityRepo.GetCustomerActivities(CompanyId); if(Activities.Any()) Activities = Activities.OrderByDescending(x => x.OrderDate).ToList(); Working = false; diff --git a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs b/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs index ee65739b..0e1dd073 100644 --- a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs +++ b/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs @@ -31,8 +31,8 @@ public partial class ActivityListTodayCrmPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public IToastService Toaster { get; set; } private ReportStatusView? ReportStatusView { get; set; } = new(); private UserPref UserPref { get; set; } = new(); @@ -46,7 +46,7 @@ public partial class ActivityListTodayCrmPage : IDisposable Interceptor.RegisterBeforeSendEvent(); UserPref = await UserProfileService.GetPreferences(); SelectedDate = string.IsNullOrWhiteSpace(UserPref.WorkDate) ? DateTime.Now : DateTime.Parse(UserPref.WorkDate); - ReportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + ReportExist = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); await GetActivities($"{SelectedDate:yyyy-MM-dd}"); Working = false; } @@ -57,8 +57,8 @@ public partial class ActivityListTodayCrmPage : IDisposable Toaster.ShowInfo("Vent nogle sekunder for data", "HENTER DATA"); SelectedDate = DateTime.Parse(workDate); ReportStatusView = new ReportStatusView(); - ReportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); - ReportStatusView = await CrmActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); + ReportExist = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + ReportStatusView = await ActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); Logger.LogDebug("Activities => {}", JsonSerializer.Serialize(ReportStatusView)); Working = false; Toaster.ClearAll(); diff --git a/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs b/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs index 32506389..681a8529 100644 --- a/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs @@ -34,7 +34,7 @@ public partial class ActivityViewCrmPage : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string OrderId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public NavigationManager Navigator { get; set; } diff --git a/Wonky.Client/Pages/CatalogCountryPage.razor b/Wonky.Client/Pages/CatalogCountryPage.razor new file mode 100644 index 00000000..930ffc16 --- /dev/null +++ b/Wonky.Client/Pages/CatalogCountryPage.razor @@ -0,0 +1,53 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@page "/price-catalog/{CountryCode}" +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization + +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ +@if (Working) +{ + +} diff --git a/Wonky.Client/Pages/CatalogCountryPage.razor.cs b/Wonky.Client/Pages/CatalogCountryPage.razor.cs new file mode 100644 index 00000000..3d84f092 --- /dev/null +++ b/Wonky.Client/Pages/CatalogCountryPage.razor.cs @@ -0,0 +1,121 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazored.LocalStorage; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Wonky.Client.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Services; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class CatalogCountryPage : IDisposable +{ + [Parameter] public string CountryCode { get; set; } = ""; + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public ICatalogCrmHttpRepository ItemRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public UserProfileService ProfileService { get; set; } + private List Items { get; set; } = new(); + private MetaData MetaInfo { get; set; } = new(); + private CatalogPagingParams PageParams = new(); + private UserPref Prefs = new(); + private UserInfoView UserInfo { get; set; } = new(); + private bool Working { get; set; } = true; + + protected override async Task OnParametersSetAsync() + { + Prefs = await ProfileService.GetPreferences(); + UserInfo = await Storage.GetItemAsync("_xu"); + + PageParams.CountryCode = UserInfo.CountryCode; + + PageParams.OrderBy = Prefs.ItemSort; + PageParams.SearchColumn = Prefs.ItemSearch; + PageParams.PageSize = Convert.ToInt32(Prefs.PageSize); + + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + await FetchSalesItems(); + } + + private async Task SetSearchPhrase(string searchTerm) + { + Items = new List(); + PageParams.PageNumber = 1; + PageParams.SearchTerm = searchTerm; + await FetchSalesItems(); + } + + private async Task SetPageSize(string pageSize) + { + Items = new List(); + PageParams.PageSize = Convert.ToInt32(pageSize); + PageParams.PageNumber = 1; + await FetchSalesItems(); + } + + private async Task SetSearchCol(string columnName) + { + Items = new List(); + PageParams.PageNumber = 1; + PageParams.SearchColumn = columnName; + await FetchSalesItems(); + } + + private async Task SetSortCol(string orderBy) + { + Items = new List(); + PageParams.OrderBy = orderBy; + await FetchSalesItems(); + } + + private async Task SetSelectedPage(int page) + { + Items = new List(); + PageParams.PageNumber = page; + await FetchSalesItems(); + } + + private async Task SetGroupCol(string groupFilter) + { + Items = new List(); + PageParams.PageNumber = 1; + PageParams.SelectGroup = groupFilter; + await FetchSalesItems(); + } + + private async Task FetchSalesItems() + { + Working = true; + var pagingResponse = await ItemRepo.GetSalesItemsPaged(PageParams, CountryCode); + Working = false; + Items = pagingResponse.Items!; + MetaInfo = pagingResponse.MetaData; + } + + + public void Dispose() => Interceptor.DisposeEvent(); + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CatalogPage.razor b/Wonky.Client/Pages/CatalogCrmPage.razor similarity index 100% rename from Wonky.Client/Pages/CatalogPage.razor rename to Wonky.Client/Pages/CatalogCrmPage.razor diff --git a/Wonky.Client/Pages/CatalogPage.razor.cs b/Wonky.Client/Pages/CatalogCrmPage.razor.cs similarity index 97% rename from Wonky.Client/Pages/CatalogPage.razor.cs rename to Wonky.Client/Pages/CatalogCrmPage.razor.cs index da655145..d681e3b2 100644 --- a/Wonky.Client/Pages/CatalogPage.razor.cs +++ b/Wonky.Client/Pages/CatalogCrmPage.razor.cs @@ -29,10 +29,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class CatalogPage : IDisposable +public partial class CatalogCrmPage : IDisposable { [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository ItemRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository ItemRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public UserProfileService ProfileService { get; set; } private List Items { get; set; } = new(); diff --git a/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs b/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs index 06aa3abb..cf9b3553 100644 --- a/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs @@ -43,7 +43,7 @@ namespace Wonky.Client.Pages [Inject] public ILogger Logger { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public VatInfoLookupService VatService { get; set; } private EditContext CompanyContext { get; set; } diff --git a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs index 4e8731ed..d3ad746b 100644 --- a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs @@ -14,9 +14,9 @@ namespace Wonky.Client.Pages; public partial class CustomerInvoiceListCrmPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/CustomerListCountryPage.razor b/Wonky.Client/Pages/CustomerListCountryPage.razor new file mode 100644 index 00000000..f24f3c8e --- /dev/null +++ b/Wonky.Client/Pages/CustomerListCountryPage.razor @@ -0,0 +1,59 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@page "/office/{countryCode}/customers" +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization + +@attribute [Authorize(Roles = "Admin,Office")] + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+ +
+
+ + + +@if (Working) +{ + +} + diff --git a/Wonky.Client/Pages/CustomerListCountryPage.razor.cs b/Wonky.Client/Pages/CustomerListCountryPage.razor.cs new file mode 100644 index 00000000..0ce0fddb --- /dev/null +++ b/Wonky.Client/Pages/CustomerListCountryPage.razor.cs @@ -0,0 +1,151 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazored.LocalStorage; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Services; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages +{ + public partial class CustomerListCountryPage : IDisposable + { + [Parameter] public string CountryCode { get; set; } = ""; + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public UserProfileService ProfileService { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + private List Companies { get; set; } = new(); + private UserPref Prefs { get; set; } = new(); + private UserInfoView UserInfo { get; set; } = new(); + private string SavedSearch { get; set; } = ""; + private bool IncludeFolded { get; set; } + private bool Working { get; set; } = true; + private MetaData PageData { get; set; } = new(); + private CustomerPaging Paging { get; set; } = new(); + + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + // set preferences + Prefs = await ProfileService.GetPreferences(); + UserInfo = await Storage.GetItemAsync("_xu"); + Paging.OrderBy = Prefs.CompanySort; + Paging.SearchColumn = Prefs.CompanySearch; + Paging.PageSize = Convert.ToInt32(Prefs.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; + Paging.CountryCode = UserInfo.CountryCode; + + // load saved search + SavedSearch = string.IsNullOrWhiteSpace(Prefs.CompanyFilterPhrase) ? "" : Prefs.CompanyFilterPhrase; + Paging.SearchTerm = SavedSearch; + + // get companies + await FetchCustomers(); + Working = false; + + } + + private async Task OnFoldedClick() + { + IncludeFolded = !IncludeFolded; + Companies = new List(); + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; + await FetchCustomers(); + } + + private async Task SelectedPage(int page) + { + Companies = new List(); + Paging.PageNumber = page; + await FetchCustomers(); + } + + private async Task SetSearchCol(string searchColumn) + { + Companies = new List(); + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; + await FetchCustomers(); + } + private async Task SetPageSize(string pageSize) + { + Companies = new List(); + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; + await FetchCustomers(); + } + + private async Task SetSearchPhrase(string searchTerm) + { + Companies = new List(); + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; + await FetchCustomers(); + } + + private async Task SetSortCol(string orderBy) + { + Companies = new List(); + Paging.OrderBy = orderBy; + await FetchCustomers(); + } + + /// + /// Removes a company from CRM + /// + /// + private async Task DeleteCompany(string companyId) + { + Companies = new List(); + await CompanyRepo.DeleteCompany(companyId); + if (Paging.PageNumber > 1 && Companies.Count == 1) + Paging.PageNumber--; + await FetchCustomers(); + } + + private async Task FetchCustomers() + { + Working = true; + var pageRes = await CompanyRepo.GetCompanies(Paging); + Working = false; + if (pageRes.Items.Any()) + { + Companies = pageRes.Items; + PageData = pageRes.MetaData; + } + else + { + Companies = new List(); + PageData = new MetaData(); + } + } + + public void Dispose() => Interceptor.DisposeEvent(); + } +} + + \ No newline at end of file diff --git a/Wonky.Client/Pages/CustomerListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerListCrmPage.razor.cs index f99730a0..3ec296f0 100644 --- a/Wonky.Client/Pages/CustomerListCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerListCrmPage.razor.cs @@ -32,7 +32,7 @@ namespace Wonky.Client.Pages { [Inject] public ILocalStorageService Storage { get; set; } [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } private List Companies { get; set; } = new(); @@ -42,7 +42,7 @@ namespace Wonky.Client.Pages private bool IncludeFolded { get; set; } private bool Working { get; set; } = true; private MetaData PageData { get; set; } = new(); - private CompanyPagingParams PageParams { get; set; } = new(); + private CustomerPaging Paging { get; set; } = new(); protected override void OnParametersSet() { @@ -56,15 +56,15 @@ namespace Wonky.Client.Pages // set preferences Prefs = await ProfileService.GetPreferences(); UserInfo = await Storage.GetItemAsync("_xu"); - PageParams.OrderBy = Prefs.CompanySort; - PageParams.SearchColumn = Prefs.CompanySearch; - PageParams.PageSize = Convert.ToInt32(Prefs.PageSize); - PageParams.HasFolded = IncludeFolded ? 1 : 0; - PageParams.CountryCode = UserInfo.CountryCode; + Paging.OrderBy = Prefs.CompanySort; + Paging.SearchColumn = Prefs.CompanySearch; + Paging.PageSize = Convert.ToInt32(Prefs.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; + Paging.CountryCode = UserInfo.CountryCode; // load saved search SavedSearch = string.IsNullOrWhiteSpace(Prefs.CompanyFilterPhrase) ? "" : Prefs.CompanyFilterPhrase; - PageParams.SearchTerm = SavedSearch; + Paging.SearchTerm = SavedSearch; // get companies await FetchCompanies(); @@ -75,45 +75,45 @@ namespace Wonky.Client.Pages { IncludeFolded = !IncludeFolded; Companies = new List(); - PageParams.PageNumber = 1; - PageParams.HasFolded = IncludeFolded ? 1 : 0; + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; await FetchCompanies(); } private async Task SelectedPage(int page) { Companies = new List(); - PageParams.PageNumber = page; + Paging.PageNumber = page; await FetchCompanies(); } private async Task SetSearchCol(string searchColumn) { Companies = new List(); - PageParams.SearchColumn = searchColumn; - PageParams.PageNumber = 1; + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; await FetchCompanies(); } private async Task SetPageSize(string pageSize) { Companies = new List(); - PageParams.PageSize = Convert.ToInt32(pageSize); - PageParams.PageNumber = 1; + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; await FetchCompanies(); } private async Task SetSearchPhrase(string searchTerm) { Companies = new List(); - PageParams.PageNumber = 1; - PageParams.SearchTerm = searchTerm; + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; await FetchCompanies(); } private async Task SetSortCol(string orderBy) { Companies = new List(); - PageParams.OrderBy = orderBy; + Paging.OrderBy = orderBy; await FetchCompanies(); } @@ -125,15 +125,15 @@ namespace Wonky.Client.Pages { Companies = new List(); await CompanyRepo.DeleteCompany(companyId); - if (PageParams.PageNumber > 1 && Companies.Count == 1) - PageParams.PageNumber--; + if (Paging.PageNumber > 1 && Companies.Count == 1) + Paging.PageNumber--; await FetchCompanies(); } private async Task FetchCompanies() { Working = true; - var pageRes = await CompanyRepo.GetCompanies(PageParams); + var pageRes = await CompanyRepo.GetCompanies(Paging); Working = false; if (pageRes.Items.Any()) { diff --git a/Wonky.Client/Pages/CustomerListOfficePage.razor b/Wonky.Client/Pages/CustomerListOfficePage.razor deleted file mode 100644 index b84981ef..00000000 --- a/Wonky.Client/Pages/CustomerListOfficePage.razor +++ /dev/null @@ -1,61 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Wonky.Client.Components -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] -@page "/office/companies/{CountryCode}" - -
-
-
-
- -
-
- -
-
- -
-
- -
-
-
-
-
- - -
-
-
- -
- -
-
-
- - - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/CustomerListOfficePage.razor.cs b/Wonky.Client/Pages/CustomerListOfficePage.razor.cs deleted file mode 100644 index 60f5345c..00000000 --- a/Wonky.Client/Pages/CustomerListOfficePage.razor.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.Services; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.Pages; - -public partial class CustomerListOfficePage : IDisposable -{ - [Parameter] public string UserId { get; set; } = ""; - [Parameter] public string CountryCode { get; set; } = "dk"; - - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; } - [Inject] public UserProfileService UserProfileService { get; set; } - private List _companyList { get; set; } = new(); - private MetaData _metaData { get; set; } = new(); - private CompanyPagingParams _paging = new(); - private UserPref UserPref { get; set; } = new(); - private string _savedSearch { get; set; } = ""; - private bool _includeFolded { get; set; } - private bool Working { get; set; } = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.DisposeEvent(); - Interceptor.RegisterBeforeSendEvent(); - - // set preferences - UserPref = await UserProfileService.GetPreferences(); - - _paging.CountryCode = CountryCode; - - _paging.OrderBy = UserPref.CompanySort; - _paging.SearchColumn = UserPref.CompanySearch; - _paging.PageSize = Convert.ToInt32(UserPref.PageSize); - _paging.HasFolded = _includeFolded ? 1 : 0; - - // load saved search - _savedSearch = UserPref.CompanyFilterPhrase; - _paging.SearchTerm = _savedSearch; - - await FetchCompanies(); - Working = false; - } - - private async Task OnFoldedClick() - { - _includeFolded = !_includeFolded; - _companyList = new List(); - _paging.PageNumber = 1; - _paging.HasFolded = _includeFolded ? 1 : 0; - await FetchCompanies(); - } - - private async Task SelectedPage(int page) - { - _companyList = new List(); - _paging.PageNumber = page; - await FetchCompanies(); - } - - private async Task SetSearchCol(string searchColumn) - { - _companyList = new List(); - _paging.SearchColumn = searchColumn; - _paging.PageNumber = 1; - await FetchCompanies(); - } - private async Task SetPageSize(string pageSize) - { - _companyList = new List(); - _paging.PageSize = Convert.ToInt32(pageSize); - _paging.PageNumber = 1; - await FetchCompanies(); - } - - private async Task SetSearchPhrase(string searchTerm) - { - // if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.Length < 3) return; - - _companyList = new List(); - _paging.PageNumber = 1; - _paging.SearchTerm = searchTerm; - await FetchCompanies(); - if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.TrimEnd().Length > 2) - { - _savedSearch = searchTerm; - await UserProfileService.SetCompanyFilterPhrase(searchTerm.Trim()); - } - } - - private async Task SetSortCol(string orderBy) - { - _companyList = new List(); - _paging.OrderBy = orderBy; - await FetchCompanies(); - } - - private async Task FetchCompanies() - { - Working = true; - var pagingResponse = await CustomerRepo.GetCompaniesPagedSalesRep(UserId, _paging); - _companyList = pagingResponse.Items; - _metaData = pagingResponse.MetaData; - Working = false; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs index d0b20dd4..af1042cf 100644 --- a/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs @@ -30,8 +30,8 @@ namespace Wonky.Client.Pages; public partial class CustomerProductListCrmPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs b/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs index 593bf8fc..7b2b1a6a 100644 --- a/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs @@ -37,9 +37,9 @@ public partial class CustomerViewCrmPage : IDisposable [Inject] public IToastService Toaster { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public ICrmContactHttpRepository ContactRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } + [Inject] public IContactCrmHttpRepository ContactRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public VatInfoLookupService VatService { get; set; } [Inject] public ILocalStorageService Storage { get; set; } diff --git a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs b/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs index 70819c02..bada60d5 100644 --- a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs +++ b/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs @@ -28,7 +28,7 @@ public partial class KrvItemViewAdminPage : IDisposable { [Parameter] public string SalesItemId { get; set; } = ""; private SalesItemView _item { get; set; } = new (); - [Inject] public ICatalogHttpRepository _itemRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository _itemRepo { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } diff --git a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs b/Wonky.Client/Pages/LandingPageAdminCountry.razor similarity index 76% rename from Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs rename to Wonky.Client/Pages/LandingPageAdminCountry.razor index bcb6bf69..81b37bf6 100644 --- a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs +++ b/Wonky.Client/Pages/LandingPageAdminCountry.razor @@ -1,3 +1,4 @@ +@* // Copyright (C) 2022 FCS Frede's Computer Services. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -12,14 +13,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +*@ + +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin")] +@page "/office/{CountryCode}" -using Wonky.Entity.Views; -namespace Wonky.Client.HttpInterfaces; -public interface IOfficeReportHttpRepository -{ - Task> GetReports(string userId); - Task GetReport(string userId, string workDate); +@code { + + [Parameter] + public string CountryCode { get; set; } = ""; + } \ No newline at end of file diff --git a/Wonky.Client/Pages/LandingPageAdminUsers.razor b/Wonky.Client/Pages/LandingPageAdminUsers.razor index b7aa8857..e8863c3e 100644 --- a/Wonky.Client/Pages/LandingPageAdminUsers.razor +++ b/Wonky.Client/Pages/LandingPageAdminUsers.razor @@ -17,19 +17,12 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Admin")] -@page "/office/users/office" +@page "/office/{countryCode}/salesreps" -
-
-
-

Administrative brugere

-
-
-
-
- Danmark -
-
+
+
+
+
@code { diff --git a/Wonky.Client/Pages/OrderCreateOfficePage.razor b/Wonky.Client/Pages/OrderCreateOfficePage.razor deleted file mode 100644 index 30036b66..00000000 --- a/Wonky.Client/Pages/OrderCreateOfficePage.razor +++ /dev/null @@ -1,198 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] -@page "/office/customers/{CompanyId}/orders/new" - - - -
- -
- -
- -
- -
- -
- -
- -
-
- -
- - -
- - -
- - -
-
- -
- -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) - { - @foreach (var cartItem in DraftStateProvider.Draft.Items) - { - - - - - - - - - - } - } - - - - - - - - -
- Ordrekladde Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) - - -
NavnVarenrAntalEnhedsprisLinjesumSAS
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@cartItem.Price@cartItem.LineTotal - - - -
Total@DraftStateProvider.Draft.Total - -
-
-
-
-
- @* draft line *@ - @if (_selectedItem != null && ShowItem) - { - - - - - - - - - - - - - - - - - - - - - - - - -
Kladdelinje
AntalPrisRabatSASVarenr.
- - - - - - - - @_selectedItem.Sku - -
- } -
-
- -
-
-
- -
-
- -
-
- -
-
-
-
- -
-
- -
-
-
- - -
- - - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs b/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs deleted file mode 100644 index cf85067e..00000000 --- a/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using System.Globalization; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; -using Wonky.Client.Models; -using Wonky.Client.Shared; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class OrderCreateOfficePage : IDisposable -{ - [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } - [Parameter] public string CompanyId { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository OfficeCustomerRepo { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - [Inject] public ICatalogHttpRepository CatalogRepo { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ILogger Logger { get; set; } - - private ActivityDto _activity { get; set; } = new(); - private EditContext _editContext { get; set; } - private PriceListModal _priceList { get; set; } = new(); - private CompanyDto _company { get; set; } = new(); - private WebUserInfoView _userInfo { get; set; } = new(); - private SalesItemView _selectedItem { get; set; } = new(); - private string Rate { get; set; } = "0"; - private string Quantity { get; set; } = "1"; - private string Price { get; set; } = "0"; - private string Discount { get; set; } = "0"; - private bool ShowItem { get; set; } - private bool Sas { get; set; } - private bool FormInvalid { get; set; } = true; - private bool HideButton { get; set; } - private bool Working { get; set; } = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - _company = await OfficeCustomerRepo.GetByCustomerId(CompanyId); - } - - protected override async Task OnInitializedAsync() - { - - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - - _userInfo = await UserRepo.GetAdvisorInfo(_company.SalesRepId); - - _activity.ActivityDate = $"{DateTime.Now:yyyy-MM-dd}" ; - - // variable to validate if customer needs phone number update - // _phone = _company.Phone; - if (string.IsNullOrWhiteSpace(_company.Phone) - && !string.IsNullOrWhiteSpace(_company.Account) - && _company.Account != "NY" && _company.Account.Length > 7) - { - _company.Phone = _company.Account[..8]; - } - - _activity.ActivityStatusEnum = "order"; - _activity.ActivityTypeEnum = "phone"; - - // set up identification - _activity.CompanyId = _company.CompanyId; - _activity.BcId = _company.BcId; - _activity.SalesRepId = _company.SalesRepId; - _activity.SalesRep = _company.SalesRep; - _activity.Account = _company.Account; - _activity.VatNumber = _company.VatNumber; - _activity.Email = _company.Email; - _activity.Phone = _company.Phone; - _activity.Mobile = _company.Mobile; - - _activity.Name = _company.Name; - _activity.Address1 = _company.Address1; - _activity.Address2 = _company.Address2; - _activity.ZipCode = _company.ZipCode; - _activity.City = _company.City; - - _activity.DlvName = _company.Name; - _activity.DlvAddress1 = _company.Address1; - _activity.DlvAddress2 = _company.Address2; - _activity.DlvZipCode = _company.ZipCode; - _activity.DlvCity = _company.City; - - Working = false; - - } - private void CallPriceListModal() - { - _priceList.Show(); - } - - private async Task SelectSku(SelectedSku sku) - { - ShowItem = true; - _selectedItem = await CatalogRepo.GetSalesVariantId(sku.ItemId); - Price = sku.Rate; - Quantity = sku.Quantity; - } - - private async Task DeleteDraft() - { - await DraftStateProvider.DeleteDraftAsync(); - } - - private async Task CreateOrder() - { - Working = true; - await CrmActivityRepo.CreateActivity(_activity); - Working = false; - } - private async Task AddItem(SalesItemView salesItem) - { - ShowItem = false; - // create a new cart item - var item = new DraftItem - { - Item = salesItem, - Quantity = Convert.ToInt32(Quantity), - Price = Convert.ToDecimal(Price, CultureInfo.InvariantCulture), - Discount = Convert.ToDecimal(Discount, CultureInfo.InvariantCulture), - Sas = Sas - }; - // reset internals to initial state - Sas = false; - Quantity = "1"; - Price = "0"; - Discount = "0"; - // add it to the cart - DraftStateProvider.Draft.Items.Add(item); - // save the item using the CartStateProvider's save method - await DraftStateProvider.SaveChangesAsync(); - } - private async Task RemoveItem(DraftItem item) - { - // remove item - DraftStateProvider.Draft.Items.Remove(item); - // save the remaining draft - await DraftStateProvider.SaveChangesAsync(); - } - - private void HandleFieldChanged(object sender, FieldChangedEventArgs e) - { - if (DraftStateProvider.Draft.Items.Count == 0) - { - FormInvalid = true; - return; - } - - FormInvalid = !_editContext.Validate(); - StateHasChanged(); - } - private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) - { - FormInvalid = false; - - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/OrderViewOfficePage.razor.cs b/Wonky.Client/Pages/OrderViewOfficePage.razor.cs index d22868ed..ed7d10f8 100644 --- a/Wonky.Client/Pages/OrderViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/OrderViewOfficePage.razor.cs @@ -35,7 +35,7 @@ public partial class OrderViewOfficePage : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string OrderId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } [Inject] public ISendMailService MailService { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public IUserHttpRepository UserRepo { get; set; } diff --git a/Wonky.Client/Pages/PrintCatalogPage.razor.cs b/Wonky.Client/Pages/PrintCatalogPage.razor.cs index a7246b2b..05e994ad 100644 --- a/Wonky.Client/Pages/PrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/PrintCatalogPage.razor.cs @@ -32,7 +32,7 @@ namespace Wonky.Client.Pages; public partial class PrintCatalogPage : IDisposable { [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository ItemRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository ItemRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } private List Items { get; set; } = new(); private UserInfoView UserInfo { get; set; } = new(); diff --git a/Wonky.Client/Pages/QuoteListCrmPage.razor.cs b/Wonky.Client/Pages/QuoteListCrmPage.razor.cs index 556ec6e2..0a52cbae 100644 --- a/Wonky.Client/Pages/QuoteListCrmPage.razor.cs +++ b/Wonky.Client/Pages/QuoteListCrmPage.razor.cs @@ -15,7 +15,7 @@ namespace Wonky.Client.Pages; public partial class QuoteListCrmPage : IDisposable { - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } diff --git a/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs b/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs index 46beacd1..384c3ea4 100644 --- a/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs @@ -31,8 +31,8 @@ public partial class ReportCreateCrmPage : IDisposable { [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } @@ -130,7 +130,7 @@ public partial class ReportCreateCrmPage : IDisposable return; Working = true; - var result = await CrmReportRepo.PostReport($"{_workDate:yyyy-MM-dd}", Report); + var result = await ReportRepo.CreateReport($"{_workDate:yyyy-MM-dd}", Report); Toaster.ShowInfo($"{result.Message}", $"HTTP Status"); // reset km and date confirmation @@ -250,7 +250,7 @@ public partial class ReportCreateCrmPage : IDisposable InitialValues = new ReportFiguresDto(); Activities = new List(); - var data = await CrmReportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}"); + var data = await ReportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}"); if(data.ReportClosed) Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); diff --git a/Wonky.Client/Pages/ReportListCrmPage.razor.cs b/Wonky.Client/Pages/ReportListCrmPage.razor.cs index 65c07b1e..c2ffe20b 100644 --- a/Wonky.Client/Pages/ReportListCrmPage.razor.cs +++ b/Wonky.Client/Pages/ReportListCrmPage.razor.cs @@ -24,7 +24,7 @@ namespace Wonky.Client.Pages; public partial class ReportListCrmPage : IDisposable { - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/ReportListOfficePage.razor.cs b/Wonky.Client/Pages/ReportListOfficePage.razor.cs index d2e990a9..ac62b848 100644 --- a/Wonky.Client/Pages/ReportListOfficePage.razor.cs +++ b/Wonky.Client/Pages/ReportListOfficePage.razor.cs @@ -27,7 +27,7 @@ public partial class ReportListOfficePage : IDisposable { [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; - [Inject] public IOfficeReportHttpRepository ReportRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IUserHttpRepository UserRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } @@ -35,6 +35,9 @@ public partial class ReportListOfficePage : IDisposable private bool Working { get; set; } = true; private WebUserInfoView UserInfo { get; set; } = new(); + /// + /// override OnParametersSeAsync + /// protected override async Task OnParametersSetAsync() { Interceptor.RegisterEvent(); @@ -42,13 +45,17 @@ public partial class ReportListOfficePage : IDisposable UserInfo = await UserRepo.GetAdvisorInfo(UserId); - var reports = await ReportRepo.GetReports(UserId); + var reports = await ReportRepo.GetCountryReports(UserId); if (reports.Any()) ActivityReports = reports.OrderByDescending(x => x.ReportDate).ToList(); Working = false; } + /// + /// Callback to shoe the report + /// + /// private void ShowThisReport(string reportDate) { var uri = new Uri(Navigator.Uri); diff --git a/Wonky.Client/Pages/ReportViewCrmPage.razor.cs b/Wonky.Client/Pages/ReportViewCrmPage.razor.cs index dde5d10e..647d2979 100644 --- a/Wonky.Client/Pages/ReportViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/ReportViewCrmPage.razor.cs @@ -26,7 +26,7 @@ namespace Wonky.Client.Pages; public partial class ReportViewCrmPage : IDisposable { [Parameter] public string ReportDate { get; set; } - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } diff --git a/Wonky.Client/Pages/ReportViewOfficePage.razor.cs b/Wonky.Client/Pages/ReportViewOfficePage.razor.cs index abb21d03..fb76eb78 100644 --- a/Wonky.Client/Pages/ReportViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/ReportViewOfficePage.razor.cs @@ -40,8 +40,9 @@ public partial class ReportViewOfficePage : IDisposable /// /// Report Date /// - [Parameter] + [Parameter] public string ReportDate { get; set; } = ""; + /// /// Injected interceptor service /// @@ -52,7 +53,7 @@ public partial class ReportViewOfficePage : IDisposable /// Injected administrative report http repo ///
[Inject] - public IOfficeReportHttpRepository ReportRepo { get; set; } + public IReportHttpRepository ReportRepo { get; set; } /// /// Navigation Manager @@ -89,10 +90,10 @@ public partial class ReportViewOfficePage : IDisposable { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - + ProfileService.OnChange += ProfileServiceOnOnChange; await ProfileService.SetWorkDate(DateTime.Parse(ReportDate)); - + await FetchUserReport(ReportDate); } @@ -129,35 +130,35 @@ public partial class ReportViewOfficePage : IDisposable } ReportDate = workDate; - + // ensure the browser address bar contains the correct link Navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{workDate}", false, true); - + // return if we are already at it if (Working) { return; } - + // reset variables Report = new ReportView(); Activities = new List(); - + // set busy signal Working = true; - + // fetch report - Report = await ReportRepo.GetReport(UserId, workDate); - + Report = await ReportRepo.GetCountryReport(UserId, workDate); + // extract activities Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); - + // store locally if (!string.IsNullOrWhiteSpace(Report.ReportData.ReportDate)) { await Storage.SetItemAsync($"{UserId}-{workDate}", Report); } - + // remove busy signal Working = false; } @@ -168,7 +169,7 @@ public partial class ReportViewOfficePage : IDisposable Prefs = userPref; Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange => Prefs.WorkDate <= {}", Prefs.WorkDate); ReportDate = Prefs.WorkDate; - + StateHasChanged(); } diff --git a/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs b/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs index 2af94738..72de9476 100644 --- a/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs +++ b/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs @@ -31,7 +31,7 @@ public partial class TaskItemListCrmPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmTaskItemHttpRepository TaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } [Inject] public IToastService Toaster { get; set; } private UserPref Prefs { get; set; } = new(); private string WorkDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; @@ -55,7 +55,7 @@ public partial class TaskItemListCrmPage : IDisposable { Working = true; Toaster.ShowInfo("Vent nogle sekunder for data"); - TaskItems = await TaskItemRepo.GetTaskList(workDate); + TaskItems = await TaskRepo.GetTaskList(workDate); Toaster.ClearAll(); Working = false; diff --git a/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs b/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs index 6dd66623..a8800e6b 100644 --- a/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs @@ -28,7 +28,7 @@ public partial class TaskItemViewCrmPage : IDisposable { [Parameter] public string TaskItemId { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } private TaskItemDto _taskItem = new (); private EditContext _editContext { get; set; } private bool Working { get; set; } = true; @@ -39,7 +39,7 @@ public partial class TaskItemViewCrmPage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _taskItem = await CrmTaskItemRepo.GetTaskItem(TaskItemId); + _taskItem = await TaskRepo.GetTaskItem(TaskItemId); Console.WriteLine(JsonSerializer.Serialize(_taskItem)); Working = false; } diff --git a/Wonky.Client/Pages/UserListSalesRepPage.razor.cs b/Wonky.Client/Pages/UserListSalesRepPage.razor.cs index 4b0fed7a..a7118198 100644 --- a/Wonky.Client/Pages/UserListSalesRepPage.razor.cs +++ b/Wonky.Client/Pages/UserListSalesRepPage.razor.cs @@ -29,11 +29,11 @@ public partial class UserListSalesRepPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; } + [Inject] public ICustomerOfficeHttpRepository CustomerRepo { get; set; } [Inject] public UserProfileService UserProfileService { get; set; } private List _companyList { get; set; } = new(); private MetaData _metaData { get; set; } = new(); - private CompanyPagingParams _paging = new(); + private CustomerPaging _paging = new(); private UserPref UserPref { get; set; } = new(); private string _savedSearch { get; set; } = ""; private bool _includeFolded { get; set; } diff --git a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs index 7083f2e9..e9eb19a4 100644 --- a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs +++ b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs @@ -27,7 +27,7 @@ public partial class WorkplaceDocumentListPage [Parameter] public string WorkplaceId { get; set; } = ""; [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } + [Inject] public IWorkplaceCrmHttpRepository WorkplaceCrmRepo { get; set; } private bool Working { get; set; } = true; } \ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceListPage.razor.cs b/Wonky.Client/Pages/WorkplaceListPage.razor.cs index 143fc09b..d1367d51 100644 --- a/Wonky.Client/Pages/WorkplaceListPage.razor.cs +++ b/Wonky.Client/Pages/WorkplaceListPage.razor.cs @@ -27,8 +27,8 @@ namespace Wonky.Client.Pages; public partial class WorkplaceListPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } + [Inject] public IWorkplaceCrmHttpRepository WorkplaceCrmRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository _companyRepo { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } private List _workplaces { get; set; } = new(); private CompanyDto _company { get; set; } = new(); @@ -45,7 +45,7 @@ public partial class WorkplaceListPage : IDisposable protected override async Task OnInitializedAsync() { Working = true; - _workplaces = await CrmWorkplaceRepo.GetWorkplaces(CompanyId); + _workplaces = await WorkplaceCrmRepo.GetWorkplaces(CompanyId); Working = false; } diff --git a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs b/Wonky.Client/Pages/WorkplaceViewPage.razor.cs index 479f2146..c20547c0 100644 --- a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs +++ b/Wonky.Client/Pages/WorkplaceViewPage.razor.cs @@ -29,8 +29,8 @@ public partial class WorkplaceViewPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string WorkplaceId { get; set; } = ""; - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } + [Inject] public IWorkplaceCrmHttpRepository WorkplaceCrmRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository _companyRepo { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } [Inject] public NavigationManager _navigator { get; set; } private WorkplaceDto _workplace { get; set; } = new(); @@ -42,7 +42,7 @@ public partial class WorkplaceViewPage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _workplace = await CrmWorkplaceRepo.GetWorkplace(CompanyId, WorkplaceId); + _workplace = await WorkplaceCrmRepo.GetWorkplace(CompanyId, WorkplaceId); Working = false; } @@ -54,14 +54,14 @@ public partial class WorkplaceViewPage : IDisposable private async Task SubmitUpdate() { Working = true; - await CrmWorkplaceRepo.UpdateWorkplace(CompanyId, _workplace); + await WorkplaceCrmRepo.UpdateWorkplace(CompanyId, _workplace); Working = false; } private async Task DeleteWorkplace() { Working = true; - await CrmWorkplaceRepo.DeleteWorkplace(CompanyId, _workplace.WorkplaceId); + await WorkplaceCrmRepo.DeleteWorkplace(CompanyId, _workplace.WorkplaceId); _navigator.NavigateTo($"/companies/{CompanyId}/workplaces"); } diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 013ed6af..7ab56879 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -54,21 +54,21 @@ builder.Services.Configure(builder.Configuration.GetSection("ApiConfi // app info object builder.Services.Configure(builder.Configuration.GetSection("AppInfo")); // crm repositories -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); // administrative repositories builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); // warehouse repository builder.Services.AddScoped(); // catalog repository -builder.Services.AddScoped(); +builder.Services.AddScoped(); // mail service builder.Services.AddScoped(); // interceptor diff --git a/Wonky.Client/Shared/ContactModal.razor.cs b/Wonky.Client/Shared/ContactModal.razor.cs index 4cbff697..5c5b685c 100644 --- a/Wonky.Client/Shared/ContactModal.razor.cs +++ b/Wonky.Client/Shared/ContactModal.razor.cs @@ -31,7 +31,7 @@ public partial class ContactModal { [Parameter] public ContactDto ParamContact { get; set; } = new(); [Parameter] public string CompanyName { get; set; } = ""; - [Parameter] public ICrmContactHttpRepository ContactRepo { get; set; } + [Parameter] public IContactCrmHttpRepository ContactRepo { get; set; } [Parameter] public HttpInterceptorService Interceptor { get; set; } [Parameter] public EventCallback OnSaveClicked { get; set; } [Parameter] public EventCallback OnDeleteClicked { get; set; } diff --git a/Wonky.Client/Shared/InventoryReorderModal.razor.cs b/Wonky.Client/Shared/InventoryReorderModal.razor.cs index d2cbdb1a..c257614a 100644 --- a/Wonky.Client/Shared/InventoryReorderModal.razor.cs +++ b/Wonky.Client/Shared/InventoryReorderModal.razor.cs @@ -29,7 +29,7 @@ public partial class InventoryReorderModal { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public SalesItemView SalesItem { get; set; } = new(); - [Inject] public ICrmHistoryHttpRepository CrmHistoryRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository CustomerHistoryCrmRepo { get; set; } [Parameter] public EventCallback OnSelected { get; set; } private List? History { get; set; } = new(); private DraftItem SelectedItem { get; set; } = new(); @@ -43,7 +43,7 @@ public partial class InventoryReorderModal if (string.IsNullOrWhiteSpace(SalesItem.Sku)) return; - History = await CrmHistoryRepo.FetchHistory(CompanyId, SalesItem.Sku); + History = await CustomerHistoryCrmRepo.FetchHistory(CompanyId, SalesItem.Sku); if (!History.Any()) await Task.Delay(1000); SelectedItem.Item = SalesItem; diff --git a/Wonky.Client/Shared/InvoiceViewModal.razor.cs b/Wonky.Client/Shared/InvoiceViewModal.razor.cs index 329c7e23..f7e4c396 100644 --- a/Wonky.Client/Shared/InvoiceViewModal.razor.cs +++ b/Wonky.Client/Shared/InvoiceViewModal.razor.cs @@ -30,7 +30,7 @@ public partial class InvoiceViewModal : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string InvoiceId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } private string _modalDisplay = ""; private bool _showBackdrop; private InvoiceView Invoice { get; set; } = new(); diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index a7461b5f..5df0f9d9 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -44,33 +44,22 @@ - + - - - - - - - - @if (_items.Any()) + @if (Items.Any()) {
    - @foreach (var item in _items) + @foreach (var item in Items) {
  • diff --git a/Wonky.Client/Shared/PriceListModal.razor.cs b/Wonky.Client/Shared/PriceListModal.razor.cs index 2acb843a..9513817d 100644 --- a/Wonky.Client/Shared/PriceListModal.razor.cs +++ b/Wonky.Client/Shared/PriceListModal.razor.cs @@ -28,21 +28,20 @@ public partial class PriceListModal : IDisposable { [Parameter] public string CountryCode { get; set; } = "dk"; [Parameter] public EventCallback OnSelected { get; set; } - [Inject] public IAdvisorCatalogRepository ItemRepo { get; set; } + [Inject] public IAdvisorCatalogRepository Catalog { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public UserProfileService UserProfileService { get; set; } + [Inject] public UserProfileService ProfileService { get; set; } private string _modalDisplay = ""; private bool _showBackdrop; - private List _items { get; set; } = new(); - private MetaData? _metaData { get; set; } = new(); + private List Items { get; set; } = new(); + private MetaData? ResponseMeta { get; set; } = new(); private CatalogPaging _paging = new(); private UserPref _userPref = new(); protected override async Task OnInitializedAsync() { - _userPref = await UserProfileService.GetPreferences(); - _paging.CountryCode = CountryCode; + _userPref = await ProfileService.GetPreferences(); _paging.OrderBy = _userPref.ItemSort; _paging.SearchColumn = _userPref.ItemSearch; _paging.PageSize = Convert.ToInt32(_userPref.PageSize); @@ -59,13 +58,13 @@ public partial class PriceListModal : IDisposable private async Task SelectedPage(int page) { - _items = new List(); + Items = new List(); _paging.PageNumber = page; await GetSalesItems(); } private async Task SetSearchPhrase(string searchTerm) { - _items = new List(); + Items = new List(); _paging.PageNumber = 1; _paging.SearchTerm = searchTerm; await GetSalesItems(); @@ -73,14 +72,14 @@ public partial class PriceListModal : IDisposable private async Task GetSalesItems() { - var pagingResponse = await ItemRepo.GetSalesItemsPaged(_paging); - _items = pagingResponse.Items!; - _metaData = pagingResponse.MetaData; + var pagingResponse = await Catalog.GetSalesItemsPaged(_paging); + Items = pagingResponse.Items!; + ResponseMeta = pagingResponse.MetaData; } private async Task SetPageSize(string pageSize) { - _items = new List(); + Items = new List(); _paging.PageSize = Convert.ToInt32(pageSize); _paging.PageNumber = 1; await GetSalesItems(); @@ -88,7 +87,7 @@ public partial class PriceListModal : IDisposable private async Task SetSearchCol(string columnName) { - _items = new List(); + Items = new List(); _paging.PageNumber = 1; _paging.SearchColumn = columnName; await GetSalesItems(); @@ -96,7 +95,7 @@ public partial class PriceListModal : IDisposable private async Task SetSortCol(string orderBy) { - _items = new List(); + Items = new List(); _paging.OrderBy = orderBy; await GetSalesItems(); } diff --git a/Wonky.Client/Shared/ProductHistoryModal.razor.cs b/Wonky.Client/Shared/ProductHistoryModal.razor.cs index 8574a82a..1daa2872 100644 --- a/Wonky.Client/Shared/ProductHistoryModal.razor.cs +++ b/Wonky.Client/Shared/ProductHistoryModal.razor.cs @@ -29,7 +29,7 @@ public partial class ProductHistoryModal // [Parameter] public EventCallback OnSelected { get; set; } [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string ItemSku { get; set; } = ""; - [Inject] public ICustomerHistoryRepository CustomerHistoryCrmRepo { get; set; } + [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } private List? History { get; set; } private string ProductName { get; set; } = ""; private string _modalDisplay = ""; @@ -37,7 +37,7 @@ public partial class ProductHistoryModal protected override async Task OnParametersSetAsync() { - History = await CustomerHistoryCrmRepo.FetchHistory(CompanyId, ItemSku); + History = await HistoryRepo.FetchHistory(CompanyId, ItemSku); if (History.Any()) { ProductName = History[0].Description; diff --git a/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs b/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs index de314f02..d8afefe0 100644 --- a/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs +++ b/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs @@ -29,7 +29,7 @@ public partial class ProductPriceHistoryModal [Parameter] public EventCallback OnSelected { get; set; } [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string Sku { get; set; } = ""; - [Inject] public ICustomerHistoryRepository CustomerHistoryCrmRepo { get; set; } + [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } private List? History { get; set; } private string ProductName { get; set; } = ""; private string _modalDisplay = ""; @@ -40,7 +40,7 @@ public partial class ProductPriceHistoryModal if (string.IsNullOrWhiteSpace(Sku)) return; - History = await CustomerHistoryCrmRepo.FetchHistory(CompanyId, Sku); + History = await HistoryRepo.FetchHistory(CompanyId, Sku); if (History.Any()) { ProductName = History[0].Description; diff --git a/Wonky.Client/wwwroot/css/app.css b/Wonky.Client/wwwroot/css/app.css index 2cb2a5d5..11012adf 100644 --- a/Wonky.Client/wwwroot/css/app.css +++ b/Wonky.Client/wwwroot/css/app.css @@ -6,8 +6,12 @@ body { .draft-expires-msg { font-size: 0.8em; } -.spinner { - height: 48px; +.busy-signal { + float: right; + z-index: 100; + position: relative; + top: 1px; + right: 10px; } .workDate { font-variant: small-caps; diff --git a/Wonky.Entity/Requests/CatalogPaging.cs b/Wonky.Entity/Requests/CatalogPaging.cs index 8ab6ea2a..fd7ecb96 100644 --- a/Wonky.Entity/Requests/CatalogPaging.cs +++ b/Wonky.Entity/Requests/CatalogPaging.cs @@ -60,9 +60,4 @@ public class CatalogPaging /// Set product group filter ///
public string SelectGroup { get; set; } = ""; - - /// - /// Country code - /// - public string CountryCode { get; set; } = "dk"; } \ No newline at end of file diff --git a/Wonky.Entity/Requests/CustomerPaging.cs b/Wonky.Entity/Requests/CustomerPaging.cs index cdb7391b..7ca546dc 100644 --- a/Wonky.Entity/Requests/CustomerPaging.cs +++ b/Wonky.Entity/Requests/CustomerPaging.cs @@ -71,6 +71,4 @@ public class CustomerPaging ///
public int HasFolded { get; set; } - public string CountryCode { get; set; } = "dk"; - } \ No newline at end of file From a5c5ed688325263ce35b8db8bd3ebcc95a8cfdf7 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Mon, 2 Jan 2023 07:14:37 +0100 Subject: [PATCH 06/49] task delay while data not yet available --- .../AdvisorCustomerInvoiceListPage.razor | 4 +- .../AdvisorCustomerInvoiceListPage.razor.cs | 46 +++++++++++-------- Wonky.Client/wwwroot/appsettings.json | 2 +- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor index 0b574d42..879724c7 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor @@ -32,8 +32,8 @@ Besøg - - + + } @if (Working) diff --git a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs index fe7da5ad..b7ade2a0 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs @@ -23,36 +23,41 @@ public partial class AdvisorCustomerInvoiceListPage : IDisposable [Inject] public ILogger Logger { get; set; } private InvoiceListView CompanyInvoices { get; set; } = new(); private CompanyDto Company { get; set; } = new(); - private bool Working { get; set; } = true; + private bool Working { get; set; } private InvoiceViewModal InvoiceView { get; set; } = new(); private string InvoiceId { get; set; } = ""; + private bool AllSet { get; set; } + private string _companyId = ""; + + protected override void OnInitialized() + { + _companyId = CompanyId; + Working = true; + } protected override async Task OnInitializedAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - Company = await CompanyRepo.GetCompanyById(CompanyId); - while (string.IsNullOrWhiteSpace(Company.HistorySync)) - { - await Task.Delay(1000); - } + Company = await CompanyRepo.GetCompanyById(_companyId); - var iDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-iDate"); + while (string.IsNullOrWhiteSpace(Company.HistorySync)) + await Task.Delay(500); + + var iDate = await Storage.GetItemAsStringAsync($"{_companyId}-iDate"); if (string.IsNullOrWhiteSpace(iDate) || (iDate == Company.HistorySync && iDate != $"{DateTime.Now:yyyy-MM-dd}")) { // send rpc to sync invoices from ERP to CRM - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + var ts = await HistoryRepo.ErpInvoiceToCrmRpc(_companyId, Company.HistorySync); // wait until we have the result while (string.IsNullOrWhiteSpace(ts)) - { - await Task.Delay(1000); - } - await Storage.SetItemAsync($"{Company.CompanyId}-iDate", ts); + await Task.Delay(500); + + await Storage.SetItemAsync($"{_companyId}-iDate", ts); } - CompanyInvoices = await FetchCompanyInvoices(); - Working = false; + AllSet = true; } private void CallInvoiceModal(string invoiceId) @@ -63,20 +68,23 @@ public partial class AdvisorCustomerInvoiceListPage : IDisposable private async Task FetchCompanyInvoices() { - var storage = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-invoices"); - var iDate = await Storage.GetItemAsStringAsync($"{Company.CompanyId}-iDate"); + // fetch from storage + var storage = await Storage.GetItemAsStringAsync($"{_companyId}-invoices"); + var iDate = await Storage.GetItemAsStringAsync($"{_companyId}-iDate"); + // if we have a list and iDate was today return the list - if (!string.IsNullOrWhiteSpace(storage) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now) + if (!string.IsNullOrWhiteSpace(storage) && (!string.IsNullOrWhiteSpace(iDate) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now)) { Logger.LogDebug("return invoices from storage"); return JsonSerializer.Deserialize(storage); } Logger.LogDebug("pulling invoices from backend"); // pull invoices - var invoices = await HistoryRepo.FetchInvoiceList(CompanyId); + var invoices = await HistoryRepo.FetchInvoiceList(_companyId); // send invoices to storage - await Storage.SetItemAsync($"{Company.CompanyId}-invoices", invoices); + await Storage.SetItemAsync($"{_companyId}-invoices", invoices); Logger.LogDebug("return invoices from backend"); + Working = false; return invoices; } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 0e7639c5..4a71c921 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.91.1", + "version": "0.92.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" From e520a03666dee3993e1c8f8bfdc91f648a8993cd Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Mon, 2 Jan 2023 16:43:58 +0100 Subject: [PATCH 07/49] admin/warehouse landing page --- .../Components/LandingComponentAdmin.razor | 90 ++++++++++----- .../AdvisorCatalogRepository.cs | 4 +- .../Pages/AdvisorCreateActivityPage.razor | 8 +- .../Pages/AdvisorCreateActivityPage.razor.cs | 104 +++++++++--------- .../AdvisorCustomerActivityListPage.razor | 2 +- Wonky.Client/Pages/CountryLandingPage.razor | 93 ++++++++++------ Wonky.Client/Shared/NavMenu.razor | 14 +-- 7 files changed, 182 insertions(+), 133 deletions(-) diff --git a/Wonky.Client/Components/LandingComponentAdmin.razor b/Wonky.Client/Components/LandingComponentAdmin.razor index 2c52239d..c7d9ef7e 100644 --- a/Wonky.Client/Components/LandingComponentAdmin.razor +++ b/Wonky.Client/Components/LandingComponentAdmin.razor @@ -18,38 +18,68 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components -
-
-

- Danmark -

-

- Kunder, Prisliste -

- Danmark .... +
+
+
+
Danmark
+ +
-
-
-
-

- Norge -

-

- Kunder, Prisliste -

- Norge .... +
+
-
-
-
-

- Sverige -

-

- Kunder, Prisliste -

- Sverige .... +
+
+
Sverige
+ +
-
+ +
\ No newline at end of file diff --git a/Wonky.Client/HttpRepository/AdvisorCatalogRepository.cs b/Wonky.Client/HttpRepository/AdvisorCatalogRepository.cs index 1dbdb3a0..63d270cb 100644 --- a/Wonky.Client/HttpRepository/AdvisorCatalogRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorCatalogRepository.cs @@ -109,7 +109,7 @@ public class AdvisorCatalogRepository : IAdvisorCatalogRepository ["selectGroup"] = pagingParameters.SelectGroup == "0" ? "" : pagingParameters.SelectGroup, }; var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/{countryCode}/page", queryString)); + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/page", queryString)); if (!response.IsSuccessStatusCode) { @@ -150,7 +150,7 @@ public class AdvisorCatalogRepository : IAdvisorCatalogRepository /// public async Task GetSalesItemSku(string countryCode, string sku) { - var salesItem = await _client.GetFromJsonAsync($"{_apiConfig.Catalog}/{countryCode}/sku/{sku}"); + var salesItem = await _client.GetFromJsonAsync($"{_apiConfig.Catalog}/sku/{countryCode}/{sku}"); return salesItem ?? new SalesItemView(); } diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor index b55921e8..5836a8a3 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor @@ -26,10 +26,10 @@
-@if (!string.IsNullOrWhiteSpace(Company.Blocked)) +@if (!string.IsNullOrWhiteSpace(_company.Blocked)) {
-

Ring til kontoret. Denne konto er spærret med kode '@Company.Blocked'

+

Ring til kontoret. Denne konto er spærret med kode '@_company.Blocked'

}
@@ -67,7 +67,7 @@ else
- @if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && Company.HasFolded == 0) + @if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && _company.HasFolded == 0) { @if (DraftProvider.Draft.DraftType == "order") { @@ -314,7 +314,7 @@ else
diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs index eae826e2..55a4eca3 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs @@ -49,12 +49,12 @@ public partial class AdvisorCreateActivityPage : IDisposable [Inject] public IAdvisorReportRepository AdvisorReportRepo { get; set; } [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } // variables - private readonly JsonSerializerOptions? _options = new() {PropertyNameCaseInsensitive = true}; + private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true}; private SalesItemView SelectedItem { get; set; } = new(); private UserPref UserPrefs { get; set; } = new(); private ActivityDto Activity { get; set; } = new(); - private CompanyDto Company = new(); - private EditContext ActivityContext { get; set; } + private CompanyDto _company = new(); + private EditContext? ActivityContext { get; set; } private bool PoFormInvalid { get; set; } = true; private bool ShowItem { get; set; } private string Quantity { get; set; } = "1"; @@ -62,20 +62,18 @@ public partial class AdvisorCreateActivityPage : IDisposable private string Discount { get; set; } = "0"; private bool Sas { get; set; } private bool InvalidActivityType { get; set; } = true; - private bool InvalidStatusType { get; set; } = true; private bool InvalidActivity { get; set; } = true; - private bool InvalidCanvas { get; set; } = true; - private bool NoHistory { get; set; } = true; private bool ReportClosed { get; set; } private bool Working { get; set; } = true; private UserInfoView ThisUserInfo { get; set; } = new(); private DateTime SelectedDate { get; set; } private string OldPhone { get; set; } = ""; - private string PromptDateConfirm { get; set; } + + private string PromptDateConfirm { get; set; } = ""; // MODAL DIALOGS - private PriceListModal PriceListModal { get; set; } - private ProductHistoryModal HistoryModal { get; set; } - private ProductPriceHistoryModal PriceHistoryModal { get; set; } + private PriceListModal PriceListModal { get; set; } = new(); + private ProductHistoryModal HistoryModal { get; set; } = new(); + private ProductPriceHistoryModal PriceHistoryModal { get; set; } = new(); private ConfirmWorkDateModal ConfirmWorkDateModal { get; set; } = new(); private ConfirmProductCheckModal ConfirmProductCheckModal { get; set; } = new(); private List CheckList { get; set; } = new(); @@ -97,42 +95,42 @@ public partial class AdvisorCreateActivityPage : IDisposable // User Info ThisUserInfo = await Storage.GetItemAsync("_xu"); // Fetch Customer from http - Company = await CompanyRepo.GetCompanyById(CompanyId); - if (Company.HasFolded == 1) + _company = await CompanyRepo.GetCompanyById(CompanyId); + if (_company.HasFolded == 1) // Company has shutdown activities Activity.OrderMessage = "BEMÆRK: CVR nummer er ophørt."; // variable to validate if customer needs phone number update - OldPhone = Company.Phone; - if (string.IsNullOrWhiteSpace(Company.Phone) - && !string.IsNullOrWhiteSpace(Company.Account) - && Company.Account != "NY" && Company.Account.Length > 7) + OldPhone = _company.Phone; + if (string.IsNullOrWhiteSpace(_company.Phone) + && !string.IsNullOrWhiteSpace(_company.Account) + && _company.Account != "NY" && _company.Account.Length > 7) { - Company.Phone = Company.Account[..8]; + _company.Phone = _company.Account[..8]; } // Populate base activity information - Activity.BcId = Company.BcId; + Activity.BcId = _company.BcId; Activity.ActivityStatusEnum = "noSale"; - Activity.VisitTypeEnum = Company.Account is "" or "NY" ? "new" : "recall"; - Activity.CompanyId = Company.CompanyId; + Activity.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall"; + Activity.CompanyId = _company.CompanyId; Activity.SalesRepId = ThisUserInfo.Id; Activity.SalesRep = ThisUserInfo.Advisor; Activity.CountryCode = ThisUserInfo.CountryCode; - Activity.Account = Company.Account; - Activity.VatNumber = Company.VatNumber; - Activity.Email = Company.Email; - Activity.Phone = Company.Phone; - Activity.Mobile = Company.Mobile; - Activity.Name = Company.Name; - Activity.Address1 = Company.Address1; - Activity.Address2 = Company.Address2; - Activity.ZipCode = Company.ZipCode; - Activity.City = Company.City; - Activity.DlvName = Company.Name; - Activity.DlvAddress1 = Company.Address1; - Activity.DlvAddress2 = Company.Address2; - Activity.DlvZipCode = Company.ZipCode; - Activity.DlvCity = Company.City; + Activity.Account = _company.Account; + Activity.VatNumber = _company.VatNumber; + Activity.Email = _company.Email; + Activity.Phone = _company.Phone; + Activity.Mobile = _company.Mobile; + Activity.Name = _company.Name; + Activity.Address1 = _company.Address1; + Activity.Address2 = _company.Address2; + Activity.ZipCode = _company.ZipCode; + Activity.City = _company.City; + Activity.DlvName = _company.Name; + Activity.DlvAddress1 = _company.Address1; + Activity.DlvAddress2 = _company.Address2; + Activity.DlvZipCode = _company.ZipCode; + Activity.DlvCity = _company.City; // Initialize date variable SelectedDate = string.IsNullOrWhiteSpace(UserPrefs.WorkDate) ? DateTime.Now : DateTime.Parse(UserPrefs.WorkDate); // raise flag if report is closed @@ -159,8 +157,8 @@ public partial class AdvisorCreateActivityPage : IDisposable private async Task CallConfirmProductCheckModel() { // check if new account - if (string.IsNullOrWhiteSpace(Company.Account) - || Company.Account.ToLower() == "ny" + if (string.IsNullOrWhiteSpace(_company.Account) + || _company.Account.ToLower() == "ny" || Activity.ActivityStatusEnum.ToLower() == "quote") { // proceed to create activity - as there is no product check to be done @@ -170,37 +168,39 @@ public partial class AdvisorCreateActivityPage : IDisposable // check if product has been checked // fetch products from storage - var storage = await Storage.GetItemAsStringAsync($"{CompanyId}-products"); + var pStorage = await Storage.GetItemAsStringAsync($"{CompanyId}-products"); + Logger.LogDebug("pStorage => {}", pStorage); // fetch pDate from storage - var pDate = await Storage.GetItemAsStringAsync($"{CompanyId}-pDate"); + var pDate = await Storage.GetItemAsync($"{CompanyId}-pDate"); + Logger.LogDebug("pDate => {}", pDate); // check if product data is valid and updated today - if (string.IsNullOrWhiteSpace(storage) || DateTime.Parse(pDate.Replace("\"", "")) < DateTime.Now) + if (string.IsNullOrWhiteSpace(pStorage) || pDate.Replace("\"", "") != $"{DateTime.Now:yyyy-MM-dd}") { Working = true; - // pop a message Toast.ShowError("Produkt gennemgang mangler. Vent mens produkt oversigt indlæses. Gå ikke væk fra siden!", "Produkt check ..."); // product inventory has not been updated // send rpc call to sync ERP to CRM Toast.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ..."); - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, _company.HistorySync); while (string.IsNullOrWhiteSpace(ts)) - { - await Task.Delay(1000); - } + await Task.Delay(500); // save pDate await Storage.SetItemAsync($"{CompanyId}-pDate", ts); // request products from backend Toast.ShowInfo("Vent mens produkt oversigt hentes", "CRM produkt liste"); + CheckList = await HistoryRepo.FetchInventory(CompanyId); - CheckList = CheckList.OrderBy(x => x.Description).ToList(); + if(CheckList.Any()) + CheckList = CheckList.OrderBy(x => x.Description).ToList(); + await Storage.SetItemAsync($"{CompanyId}-products", CheckList); Working = false; } else { // deserialize storage data - CheckList = JsonSerializer.Deserialize>(storage); + CheckList = JsonSerializer.Deserialize>(pStorage); if(CheckList.Any()) CheckList = CheckList.OrderBy(x => x.Description).ToList(); } @@ -210,14 +210,14 @@ public partial class AdvisorCreateActivityPage : IDisposable } private async Task ConfirmProductCheckCallback() { + ConfirmProductCheckModal.Hide(); await CreateActivity(); foreach (var item in CheckList) { item.Check = false; } - await Storage.SetItemAsync($"{CompanyId}-products", CheckList); - ConfirmProductCheckModal.Hide(); + } /// @@ -308,7 +308,7 @@ public partial class AdvisorCreateActivityPage : IDisposable Toast.ShowError("Ved bestilling skal der være en eller flere linjer i kladden."); return; // phone number is required if first time customer - case "order" when Company.Account is "NY" or "" && string.IsNullOrWhiteSpace(Activity.Phone): + case "order" when _company.Account is "NY" or "" && string.IsNullOrWhiteSpace(Activity.Phone): Toast.ShowError("Ved bestilling til ny kunde skal telefon nummer angives."); return; // verify email address is a valid address @@ -324,8 +324,8 @@ public partial class AdvisorCreateActivityPage : IDisposable // check if phone number need to be updated if (OldPhone != Activity.Phone) { - Company.Phone = Activity.Phone; - await CompanyRepo.UpdateErpData(Company.CompanyId, Company); + _company.Phone = Activity.Phone; + await CompanyRepo.UpdateErpData(_company.CompanyId, _company); } // begin assembling activity Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}"; diff --git a/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor index ed762f6b..1d54ce4b 100644 --- a/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor @@ -74,7 +74,7 @@ @activity.OfficeNote
- ikke fuldt implementeret + @activity.CrmNote
diff --git a/Wonky.Client/Pages/CountryLandingPage.razor b/Wonky.Client/Pages/CountryLandingPage.razor index 1e06bd51..6efa458d 100644 --- a/Wonky.Client/Pages/CountryLandingPage.razor +++ b/Wonky.Client/Pages/CountryLandingPage.razor @@ -17,41 +17,70 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Admin,Warehouse")] -@page "/office/country/{CountryCode}" +@page "/office/country" - - -
-
-

- @CountryCode.ToUpper() Sælgere -

-

- Sælger kundeliste, Rapporter, Stamdata -

- Sælgere +
+
+
- -
-
-

- @CountryCode.ToUpper() Kunder -

-

- Filtrer og søg kunder -

- Kundeliste + +
+
-
-
-
-

- @CountryCode.ToUpper() Priskatalog -

-

- Produkter og priser -

- Priskatalog + +
+
+
Sverige
+ +
+
\ No newline at end of file diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index d25a5066..15c604e1 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -46,18 +46,8 @@ - -
protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); ReportContext = new EditContext(Report); ReportContext.OnFieldChanged += HandleFieldChanged; diff --git a/Wonky.Client/Pages/AdvisorReportListPage.razor.cs b/Wonky.Client/Pages/AdvisorReportListPage.razor.cs index 40e882c6..fd828760 100644 --- a/Wonky.Client/Pages/AdvisorReportListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportListPage.razor.cs @@ -30,15 +30,17 @@ public partial class AdvisorReportListPage : IDisposable [Inject] public ILogger Logger { get; set; } private List ReportList { get; set; } = new(); - private bool Working { get; set; } = true; + private bool Working { get; set; } protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterAfterSendEvent(); + + Working = true; - ReportList = await AdvisorReportRepo.GetReports(); - if (ReportList.Any()) + var reports = await AdvisorReportRepo.GetReports(); + if (reports.Any()) ReportList = ReportList.OrderByDescending(x => x.ReportDate).ToList(); Working = false; diff --git a/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs b/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs index b1e91957..8defa3a2 100644 --- a/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs @@ -42,8 +42,8 @@ public partial class AdvisorReportViewPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); UserInfo = await Storage.GetItemAsync("_xu"); diff --git a/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs index be336254..30f3cdc7 100644 --- a/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs @@ -45,8 +45,8 @@ public partial class AdvisorTaskItemListCrmPage : IDisposable if(!string.IsNullOrWhiteSpace(Prefs.WorkDate)) WorkDate = Prefs.WorkDate; - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); await GetTaskItems(WorkDate); Working = false; } diff --git a/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs index e418bb54..b24aef87 100644 --- a/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs @@ -36,8 +36,8 @@ public partial class AdvisorTaskItemViewCrmPage : IDisposable protected override async Task OnParametersSetAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); + _interceptor.RegisterAfterSendEvent(); + _interceptor.RegisterBeforeSendAsyncEvent(); _taskItem = await AdvisorTaskRepo.GetTaskItem(TaskItemId); Console.WriteLine(JsonSerializer.Serialize(_taskItem)); diff --git a/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs b/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs index 7005d5b8..eb3f85dd 100644 --- a/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs @@ -42,8 +42,8 @@ public partial class AdvisorTodayActivityListPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); UserPref = await UserProfileService.GetPreferences(); SelectedDate = string.IsNullOrWhiteSpace(UserPref.WorkDate) ? DateTime.Now : DateTime.Parse(UserPref.WorkDate); ReportExist = await AdvisorReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); diff --git a/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs index 369db7df..5a86cf92 100644 --- a/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs @@ -47,8 +47,8 @@ public partial class AdvisorViewActivityPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); NoteContext = new EditContext(Note); NoteContext.OnFieldChanged += HandleFieldChanged; ReportItem = await AdvisorActivityRepo.GetReportItem(OrderId); diff --git a/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs index 0c8e3bd7..afed17ab 100644 --- a/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs @@ -36,8 +36,8 @@ public partial class AdvisorWorkplaceListPage : IDisposable protected override async Task OnParametersSetAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); + _interceptor.RegisterAfterSendEvent(); + _interceptor.RegisterBeforeSendAsyncEvent(); _company = await _companyRepo.GetCompanyById(CompanyId); Working = false; } diff --git a/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs index 7f1bac00..b5b45206 100644 --- a/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs @@ -39,8 +39,8 @@ public partial class AdvisorWorkplaceViewPage : IDisposable protected override async Task OnParametersSetAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); + _interceptor.RegisterAfterSendEvent(); + _interceptor.RegisterBeforeSendAsyncEvent(); _workplace = await WorkplaceCrmRepo.GetWorkplace(CompanyId, WorkplaceId); Working = false; diff --git a/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs b/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs index bd2c117d..27a9bd1d 100644 --- a/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs +++ b/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs @@ -53,8 +53,8 @@ public partial class BackendAdminSalesRepViewPage : IDisposable _editContext = new EditContext(_updateInfo); _passwdContext = new EditContext(_passwords); - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); + _interceptor.RegisterAfterSendEvent(); + _interceptor.RegisterBeforeSendAsyncEvent(); UserInfo = await SystemUserRepo.GetAdvisorInfo(UserId); diff --git a/Wonky.Client/Pages/CountryCatalogPage.razor.cs b/Wonky.Client/Pages/CountryCatalogPage.razor.cs index 2be19ada..ae889c4c 100644 --- a/Wonky.Client/Pages/CountryCatalogPage.razor.cs +++ b/Wonky.Client/Pages/CountryCatalogPage.razor.cs @@ -48,8 +48,8 @@ public partial class CountryCatalogPage : IDisposable Paging.SearchColumn = Prefs.ItemSearch; Paging.PageSize = Convert.ToInt32(Prefs.PageSize); - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); await FetchSalesItems(); } diff --git a/Wonky.Client/Pages/CountryCustomerListPage.razor.cs b/Wonky.Client/Pages/CountryCustomerListPage.razor.cs index 43562e4d..3a949d55 100644 --- a/Wonky.Client/Pages/CountryCustomerListPage.razor.cs +++ b/Wonky.Client/Pages/CountryCustomerListPage.razor.cs @@ -47,8 +47,8 @@ namespace Wonky.Client.Pages protected override async Task OnParametersSetAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); // set preferences Prefs = await ProfileService.GetPreferences(); diff --git a/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs b/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs index 82216fa7..6ff439b4 100644 --- a/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs @@ -41,8 +41,8 @@ public partial class CountryPrintCatalogPage : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); UserInfo = await Storage.GetItemAsync("_xu"); Items = await Catalog.GetPriceList(CountryCode); diff --git a/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs b/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs index 6b37dbb3..8abeb031 100644 --- a/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs +++ b/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs @@ -40,7 +40,7 @@ public partial class CountrySalesRepCustomerListPage : IDisposable protected override async Task OnParametersSetAsync() { Interceptor.DisposeEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); // set preferences UserPref = await UserProfileService.GetPreferences(); diff --git a/Wonky.Client/Pages/PrintCatalogPage.razor.cs b/Wonky.Client/Pages/PrintCatalogPage.razor.cs index 7b054de0..548c9563 100644 --- a/Wonky.Client/Pages/PrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/PrintCatalogPage.razor.cs @@ -40,8 +40,8 @@ public partial class PrintCatalogPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); UserInfo = await Storage.GetItemAsync("_xu"); Items = await ItemRepo.GetPriceList(); diff --git a/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs b/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs index 5e40b2f6..2e2f6010 100644 --- a/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs +++ b/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs @@ -20,8 +20,8 @@ public partial class WarehouseOrderListPage : IDisposable private bool ReadyToShip { get; set; } protected override async Task OnParametersSetAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); OrderList = await FetchOrders(Status); } diff --git a/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs b/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs index 8242936b..1e420003 100644 --- a/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs +++ b/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs @@ -39,8 +39,8 @@ public partial class WarehouseOrderViewPage : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); if (!string.IsNullOrWhiteSpace(OrderId)) Order = await WarehouseRepo.GetWarehouseOrder(OrderId); diff --git a/Wonky.Client/Shared/InvoiceViewModal.razor.cs b/Wonky.Client/Shared/InvoiceViewModal.razor.cs index 198abaf4..8569caa5 100644 --- a/Wonky.Client/Shared/InvoiceViewModal.razor.cs +++ b/Wonky.Client/Shared/InvoiceViewModal.razor.cs @@ -37,8 +37,8 @@ public partial class InvoiceViewModal : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); if (!string.IsNullOrWhiteSpace(InvoiceId)) { diff --git a/Wonky.Client/Shared/PriceListModal.razor.cs b/Wonky.Client/Shared/PriceListModal.razor.cs index 9513817d..aa16eefd 100644 --- a/Wonky.Client/Shared/PriceListModal.razor.cs +++ b/Wonky.Client/Shared/PriceListModal.razor.cs @@ -45,8 +45,8 @@ public partial class PriceListModal : IDisposable _paging.OrderBy = _userPref.ItemSort; _paging.SearchColumn = _userPref.ItemSearch; _paging.PageSize = Convert.ToInt32(_userPref.PageSize); - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendAsyncEvent(); await GetSalesItems(); } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 4a71c921..5c31ddfd 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.92.1", + "version": "0.94.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://dev.innotec.dk", + "baseUrl": "https://zeta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From 972fceb948b6c8551d3c8341ceeb1763e4dab08f Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 4 Jan 2023 14:32:11 +0100 Subject: [PATCH 09/49] v0.94.2 fix missing reference --- .../HttpInterceptors/HttpInterceptorService.cs | 16 ++++++++-------- .../HttpRepository/AdvisorReportRepository.cs | 5 +---- Wonky.Client/Pages/AdminReportListPage.razor.cs | 4 ++-- Wonky.Client/Pages/AdminReportViewPage.razor.cs | 4 ++-- .../Pages/AdminSalesRepListPage.razor.cs | 4 ++-- Wonky.Client/Pages/AdvisorCatalogPage.razor.cs | 4 ++-- .../Pages/AdvisorCreateActivityPage.razor.cs | 4 ++-- .../Pages/AdvisorCreateCustomerPage.razor.cs | 4 ++-- .../AdvisorCustomerActivityListPage.razor.cs | 4 ++-- .../AdvisorCustomerInventoryListPage.razor.cs | 4 ++-- .../AdvisorCustomerInvoiceListPage.razor.cs | 4 ++-- .../Pages/AdvisorCustomerListPage.razor.cs | 4 ++-- .../Pages/AdvisorCustomerOrderViewPage.razor.cs | 4 ++-- .../Pages/AdvisorCustomerViewPage.razor.cs | 4 ++-- Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs | 4 ++-- .../Pages/AdvisorReportCreatePage.razor.cs | 4 ++-- .../Pages/AdvisorReportListPage.razor.cs | 8 ++++---- .../Pages/AdvisorReportViewPage.razor.cs | 4 ++-- .../Pages/AdvisorTaskItemListCrmPage.razor.cs | 4 ++-- .../Pages/AdvisorTaskItemViewCrmPage.razor.cs | 4 ++-- .../Pages/AdvisorTodayActivityListPage.razor.cs | 4 ++-- .../Pages/AdvisorViewActivityPage.razor.cs | 4 ++-- .../Pages/AdvisorWorkplaceListPage.razor.cs | 4 ++-- .../Pages/AdvisorWorkplaceViewPage.razor.cs | 4 ++-- .../Pages/BackendAdminSalesRepViewPage.razor.cs | 4 ++-- Wonky.Client/Pages/CountryCatalogPage.razor.cs | 4 ++-- .../Pages/CountryCustomerListPage.razor.cs | 4 ++-- .../Pages/CountryPrintCatalogPage.razor.cs | 4 ++-- .../CountrySalesRepCustomerListPage.razor.cs | 2 +- Wonky.Client/Pages/PrintCatalogPage.razor.cs | 4 ++-- .../Pages/WarehouseOrderListPage.razor.cs | 4 ++-- .../Pages/WarehouseOrderViewPage.razor.cs | 4 ++-- Wonky.Client/Shared/InvoiceViewModal.razor.cs | 4 ++-- Wonky.Client/Shared/PriceListModal.razor.cs | 4 ++-- Wonky.Client/wwwroot/appsettings.json | 2 +- 35 files changed, 75 insertions(+), 78 deletions(-) diff --git a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs index 1e50dc43..de952483 100644 --- a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs +++ b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs @@ -49,23 +49,23 @@ namespace Wonky.Client.HttpInterceptors _authenticationService = authenticationService; } - public void RegisterAfterSendEvent() + public void RegisterEvent() { - _interceptor.AfterSend += InterceptorAfterSend; + _interceptor.AfterSend += AfterSend; } - public void RegisterBeforeSendAsyncEvent() + public void RegisterBeforeSendEvent() { - _interceptor.BeforeSendAsync += InterceptBeforeSendAsync; + _interceptor.BeforeSendAsync += InterceptBeforeSend; } public void DisposeEvent() { - _interceptor.AfterSend -= InterceptorAfterSend; - _interceptor.BeforeSendAsync -= InterceptBeforeSendAsync; + _interceptor.AfterSend -= AfterSend; + _interceptor.BeforeSendAsync -= InterceptBeforeSend; } - private async Task InterceptBeforeSendAsync(object sender, HttpClientInterceptorEventArgs e) + private async Task InterceptBeforeSend(object sender, HttpClientInterceptorEventArgs e) { var absolutePath = e.Request.RequestUri.AbsolutePath; if (!absolutePath.Contains("token")) @@ -81,7 +81,7 @@ namespace Wonky.Client.HttpInterceptors } - private void InterceptorAfterSend (object sender, HttpClientInterceptorEventArgs e) + private void AfterSend (object sender, HttpClientInterceptorEventArgs e) { if (e.Response == null || e.Response.IsSuccessStatusCode) return; diff --git a/Wonky.Client/HttpRepository/AdvisorReportRepository.cs b/Wonky.Client/HttpRepository/AdvisorReportRepository.cs index 515575d4..c242ef1b 100644 --- a/Wonky.Client/HttpRepository/AdvisorReportRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorReportRepository.cs @@ -68,10 +68,7 @@ public class AdvisorReportRepository : IAdvisorReportRepository var result = await _client.GetAsync($"{_apiConfig.CrmReports}"); if (!result.IsSuccessStatusCode) return new List(); - var content = await result.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + return await result.Content.ReadFromJsonAsync>(); } /// diff --git a/Wonky.Client/Pages/AdminReportListPage.razor.cs b/Wonky.Client/Pages/AdminReportListPage.razor.cs index 682bf8a3..fe7abf87 100644 --- a/Wonky.Client/Pages/AdminReportListPage.razor.cs +++ b/Wonky.Client/Pages/AdminReportListPage.razor.cs @@ -40,8 +40,8 @@ public partial class AdminReportListPage : IDisposable /// protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); UserInfo = await SystemUserRepo.GetAdvisorInfo(UserId); while (string.IsNullOrWhiteSpace(UserInfo.UserId)) diff --git a/Wonky.Client/Pages/AdminReportViewPage.razor.cs b/Wonky.Client/Pages/AdminReportViewPage.razor.cs index d7dbb1a6..4c429c78 100644 --- a/Wonky.Client/Pages/AdminReportViewPage.razor.cs +++ b/Wonky.Client/Pages/AdminReportViewPage.razor.cs @@ -88,8 +88,8 @@ public partial class AdminReportViewPage : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); ProfileService.OnChange += ProfileServiceOnOnChange; await ProfileService.SetWorkDate(DateTime.Parse(ReportDate)); diff --git a/Wonky.Client/Pages/AdminSalesRepListPage.razor.cs b/Wonky.Client/Pages/AdminSalesRepListPage.razor.cs index 84cde004..7a56e6ec 100644 --- a/Wonky.Client/Pages/AdminSalesRepListPage.razor.cs +++ b/Wonky.Client/Pages/AdminSalesRepListPage.razor.cs @@ -15,8 +15,8 @@ public partial class AdminSalesRepListPage protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); var AdvisorList = await SystemUserRepo.GetAdvisors(); SalesReps = AdvisorList .Where(x => x.CountryCode.ToLower() == CountryCode && Convert.ToInt32(x.SalesRep) < 100) diff --git a/Wonky.Client/Pages/AdvisorCatalogPage.razor.cs b/Wonky.Client/Pages/AdvisorCatalogPage.razor.cs index 906390b2..ef9426af 100644 --- a/Wonky.Client/Pages/AdvisorCatalogPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCatalogPage.razor.cs @@ -51,8 +51,8 @@ public partial class AdvisorCatalogPage : IDisposable _page.SearchColumn = Prefs.ItemSearch; _page.PageSize = Convert.ToInt32(Prefs.PageSize); - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); await FetchSalesItems(); } diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs index 2178004e..55a4eca3 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs @@ -88,8 +88,8 @@ public partial class AdvisorCreateActivityPage : IDisposable ActivityContext.OnFieldChanged += HandleFieldChanged; ActivityContext.OnValidationStateChanged += ValidationChanged; - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); // User Preferences UserPrefs = await Profiles.GetPreferences(); // User Info diff --git a/Wonky.Client/Pages/AdvisorCreateCustomerPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateCustomerPage.razor.cs index 06c501f1..9f116c88 100644 --- a/Wonky.Client/Pages/AdvisorCreateCustomerPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateCustomerPage.razor.cs @@ -79,8 +79,8 @@ namespace Wonky.Client.Pages Company.LastVisit = $"{LastVisit:yyyy-MM-dd}"; Company.NextVisit = $"{NextVisit:yyyy-MM-dd}"; - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); } diff --git a/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs index dc7f2329..b0571288 100644 --- a/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerActivityListPage.razor.cs @@ -37,8 +37,8 @@ public partial class AdvisorCustomerActivityListPage : IDisposable protected override async Task OnInitializedAsync() { - _interceptor.RegisterAfterSendEvent(); - _interceptor.RegisterBeforeSendAsyncEvent(); + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); Company = await CompanyRepo.GetCompanyById(CompanyId); await GetActivities(); diff --git a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs index 67632935..a688858b 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs @@ -50,8 +50,8 @@ public partial class AdvisorCustomerInventoryListPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); Company = await CompanyRepo.GetCompanyById(CompanyId); diff --git a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs index ffa5542e..bf299599 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs @@ -37,8 +37,8 @@ public partial class AdvisorCustomerInvoiceListPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); Company = await CompanyRepo.GetCompanyById(_companyId); diff --git a/Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs index f830a51e..96d68f32 100644 --- a/Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerListPage.razor.cs @@ -46,8 +46,8 @@ namespace Wonky.Client.Pages protected override void OnParametersSet() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); } diff --git a/Wonky.Client/Pages/AdvisorCustomerOrderViewPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerOrderViewPage.razor.cs index 66c04c44..f8ee5031 100644 --- a/Wonky.Client/Pages/AdvisorCustomerOrderViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerOrderViewPage.razor.cs @@ -52,8 +52,8 @@ public partial class AdvisorCustomerOrderViewPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); // fetch order from backend _reportItem = await AdvisorActivityRepo.GetReportItem(OrderId); Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(_reportItem, _options)); diff --git a/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs index 28e7b035..98068853 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs @@ -69,8 +69,8 @@ public partial class AdvisorCustomerViewPage : IDisposable protected override async Task OnInitializedAsync() { // setup interceptor - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); // initialize default contact DefaultContact = new ContactDto { CompanyId = CompanyId, ContactId = "", FirstName = ""}; diff --git a/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs b/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs index 55dffa4d..882d02b4 100644 --- a/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorQuoteListPage.razor.cs @@ -28,8 +28,8 @@ public partial class AdvisorQuoteListPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); Working = true; Quotes = await AdvisorActivityRepo.GetQuotes(); await Storage.SetItemAsync("quotes", Quotes.OrderBy(x => x.Company.Name)); diff --git a/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs index b1eecd2c..f0849828 100644 --- a/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs @@ -57,8 +57,8 @@ public partial class AdvisorReportCreatePage : IDisposable /// protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); ReportContext = new EditContext(Report); ReportContext.OnFieldChanged += HandleFieldChanged; diff --git a/Wonky.Client/Pages/AdvisorReportListPage.razor.cs b/Wonky.Client/Pages/AdvisorReportListPage.razor.cs index fd828760..9288e255 100644 --- a/Wonky.Client/Pages/AdvisorReportListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportListPage.razor.cs @@ -34,15 +34,15 @@ public partial class AdvisorReportListPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterBeforeSendAsyncEvent(); - Interceptor.RegisterAfterSendEvent(); + Interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterEvent(); Working = true; var reports = await AdvisorReportRepo.GetReports(); if (reports.Any()) - ReportList = ReportList.OrderByDescending(x => x.ReportDate).ToList(); - + ReportList = reports.OrderByDescending(x => x.ReportDate).ToList(); + Working = false; } diff --git a/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs b/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs index 8defa3a2..b1e91957 100644 --- a/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportViewPage.razor.cs @@ -42,8 +42,8 @@ public partial class AdvisorReportViewPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); UserInfo = await Storage.GetItemAsync("_xu"); diff --git a/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs index 30f3cdc7..be336254 100644 --- a/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTaskItemListCrmPage.razor.cs @@ -45,8 +45,8 @@ public partial class AdvisorTaskItemListCrmPage : IDisposable if(!string.IsNullOrWhiteSpace(Prefs.WorkDate)) WorkDate = Prefs.WorkDate; - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); await GetTaskItems(WorkDate); Working = false; } diff --git a/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs index b24aef87..e418bb54 100644 --- a/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTaskItemViewCrmPage.razor.cs @@ -36,8 +36,8 @@ public partial class AdvisorTaskItemViewCrmPage : IDisposable protected override async Task OnParametersSetAsync() { - _interceptor.RegisterAfterSendEvent(); - _interceptor.RegisterBeforeSendAsyncEvent(); + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); _taskItem = await AdvisorTaskRepo.GetTaskItem(TaskItemId); Console.WriteLine(JsonSerializer.Serialize(_taskItem)); diff --git a/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs b/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs index eb3f85dd..7005d5b8 100644 --- a/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorTodayActivityListPage.razor.cs @@ -42,8 +42,8 @@ public partial class AdvisorTodayActivityListPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); UserPref = await UserProfileService.GetPreferences(); SelectedDate = string.IsNullOrWhiteSpace(UserPref.WorkDate) ? DateTime.Now : DateTime.Parse(UserPref.WorkDate); ReportExist = await AdvisorReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); diff --git a/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs index 5a86cf92..369db7df 100644 --- a/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorViewActivityPage.razor.cs @@ -47,8 +47,8 @@ public partial class AdvisorViewActivityPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); NoteContext = new EditContext(Note); NoteContext.OnFieldChanged += HandleFieldChanged; ReportItem = await AdvisorActivityRepo.GetReportItem(OrderId); diff --git a/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs index afed17ab..0c8e3bd7 100644 --- a/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceListPage.razor.cs @@ -36,8 +36,8 @@ public partial class AdvisorWorkplaceListPage : IDisposable protected override async Task OnParametersSetAsync() { - _interceptor.RegisterAfterSendEvent(); - _interceptor.RegisterBeforeSendAsyncEvent(); + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); _company = await _companyRepo.GetCompanyById(CompanyId); Working = false; } diff --git a/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs index b5b45206..7f1bac00 100644 --- a/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorWorkplaceViewPage.razor.cs @@ -39,8 +39,8 @@ public partial class AdvisorWorkplaceViewPage : IDisposable protected override async Task OnParametersSetAsync() { - _interceptor.RegisterAfterSendEvent(); - _interceptor.RegisterBeforeSendAsyncEvent(); + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); _workplace = await WorkplaceCrmRepo.GetWorkplace(CompanyId, WorkplaceId); Working = false; diff --git a/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs b/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs index 27a9bd1d..bd2c117d 100644 --- a/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs +++ b/Wonky.Client/Pages/BackendAdminSalesRepViewPage.razor.cs @@ -53,8 +53,8 @@ public partial class BackendAdminSalesRepViewPage : IDisposable _editContext = new EditContext(_updateInfo); _passwdContext = new EditContext(_passwords); - _interceptor.RegisterAfterSendEvent(); - _interceptor.RegisterBeforeSendAsyncEvent(); + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); UserInfo = await SystemUserRepo.GetAdvisorInfo(UserId); diff --git a/Wonky.Client/Pages/CountryCatalogPage.razor.cs b/Wonky.Client/Pages/CountryCatalogPage.razor.cs index ae889c4c..2be19ada 100644 --- a/Wonky.Client/Pages/CountryCatalogPage.razor.cs +++ b/Wonky.Client/Pages/CountryCatalogPage.razor.cs @@ -48,8 +48,8 @@ public partial class CountryCatalogPage : IDisposable Paging.SearchColumn = Prefs.ItemSearch; Paging.PageSize = Convert.ToInt32(Prefs.PageSize); - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); await FetchSalesItems(); } diff --git a/Wonky.Client/Pages/CountryCustomerListPage.razor.cs b/Wonky.Client/Pages/CountryCustomerListPage.razor.cs index 3a949d55..43562e4d 100644 --- a/Wonky.Client/Pages/CountryCustomerListPage.razor.cs +++ b/Wonky.Client/Pages/CountryCustomerListPage.razor.cs @@ -47,8 +47,8 @@ namespace Wonky.Client.Pages protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); // set preferences Prefs = await ProfileService.GetPreferences(); diff --git a/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs b/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs index 6ff439b4..82216fa7 100644 --- a/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/CountryPrintCatalogPage.razor.cs @@ -41,8 +41,8 @@ public partial class CountryPrintCatalogPage : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); UserInfo = await Storage.GetItemAsync("_xu"); Items = await Catalog.GetPriceList(CountryCode); diff --git a/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs b/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs index 8abeb031..6b37dbb3 100644 --- a/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs +++ b/Wonky.Client/Pages/CountrySalesRepCustomerListPage.razor.cs @@ -40,7 +40,7 @@ public partial class CountrySalesRepCustomerListPage : IDisposable protected override async Task OnParametersSetAsync() { Interceptor.DisposeEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterBeforeSendEvent(); // set preferences UserPref = await UserProfileService.GetPreferences(); diff --git a/Wonky.Client/Pages/PrintCatalogPage.razor.cs b/Wonky.Client/Pages/PrintCatalogPage.razor.cs index 548c9563..7b054de0 100644 --- a/Wonky.Client/Pages/PrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/PrintCatalogPage.razor.cs @@ -40,8 +40,8 @@ public partial class PrintCatalogPage : IDisposable protected override async Task OnInitializedAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); UserInfo = await Storage.GetItemAsync("_xu"); Items = await ItemRepo.GetPriceList(); diff --git a/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs b/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs index 2e2f6010..5e40b2f6 100644 --- a/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs +++ b/Wonky.Client/Pages/WarehouseOrderListPage.razor.cs @@ -20,8 +20,8 @@ public partial class WarehouseOrderListPage : IDisposable private bool ReadyToShip { get; set; } protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); OrderList = await FetchOrders(Status); } diff --git a/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs b/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs index 1e420003..8242936b 100644 --- a/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs +++ b/Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs @@ -39,8 +39,8 @@ public partial class WarehouseOrderViewPage : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); if (!string.IsNullOrWhiteSpace(OrderId)) Order = await WarehouseRepo.GetWarehouseOrder(OrderId); diff --git a/Wonky.Client/Shared/InvoiceViewModal.razor.cs b/Wonky.Client/Shared/InvoiceViewModal.razor.cs index 8569caa5..198abaf4 100644 --- a/Wonky.Client/Shared/InvoiceViewModal.razor.cs +++ b/Wonky.Client/Shared/InvoiceViewModal.razor.cs @@ -37,8 +37,8 @@ public partial class InvoiceViewModal : IDisposable protected override async Task OnParametersSetAsync() { - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); if (!string.IsNullOrWhiteSpace(InvoiceId)) { diff --git a/Wonky.Client/Shared/PriceListModal.razor.cs b/Wonky.Client/Shared/PriceListModal.razor.cs index aa16eefd..9513817d 100644 --- a/Wonky.Client/Shared/PriceListModal.razor.cs +++ b/Wonky.Client/Shared/PriceListModal.razor.cs @@ -45,8 +45,8 @@ public partial class PriceListModal : IDisposable _paging.OrderBy = _userPref.ItemSort; _paging.SearchColumn = _userPref.ItemSearch; _paging.PageSize = Convert.ToInt32(_userPref.PageSize); - Interceptor.RegisterAfterSendEvent(); - Interceptor.RegisterBeforeSendAsyncEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); await GetSalesItems(); } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 5c31ddfd..8dc66bd4 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.94.1", + "version": "0.94.2", "rc": true, "sandBox": false, "image": "grumpy-coder.png" From 8a5b5ecc3af1c72be41044b5e2bcb4eb59bc6192 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 4 Jan 2023 14:40:27 +0100 Subject: [PATCH 10/49] dev --- Wonky.Client/wwwroot/appsettings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 8dc66bd4..293bb2de 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.94.2", + "version": "0.95.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://zeta.innotec.dk", + "baseUrl": "https://dev.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From 2f900393e9bbb65b57fbc4a715dc6c08ac9ad3c0 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 5 Jan 2023 10:16:44 +0100 Subject: [PATCH 11/49] wip - preparations --- ...s => IAdvisorCustomerHistoryRepository.cs} | 2 +- .../ICountryCustomerHistoryRepository.cs | 70 +++++++++ ...cs => AdvisorCustomerHistoryRepository.cs} | 8 +- .../CountryCustomerHistoryRepository.cs | 145 ++++++++++++++++++ .../Pages/AdvisorCreateActivityPage.razor.cs | 2 +- .../AdvisorCustomerInventoryListPage.razor.cs | 2 +- .../AdvisorCustomerInvoiceListPage.razor.cs | 2 +- .../Pages/AdvisorCustomerViewPage.razor.cs | 2 +- Wonky.Client/Program.cs | 2 +- .../Shared/InventoryReorderModal.razor.cs | 2 +- Wonky.Client/Shared/InvoiceViewModal.razor.cs | 2 +- .../Shared/ProductHistoryModal.razor.cs | 2 +- .../Shared/ProductPriceHistoryModal.razor.cs | 2 +- 13 files changed, 229 insertions(+), 14 deletions(-) rename Wonky.Client/HttpInterfaces/{ICustomerHistoryRepository.cs => IAdvisorCustomerHistoryRepository.cs} (97%) create mode 100644 Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs rename Wonky.Client/HttpRepository/{CustomerHistoryRepository.cs => AdvisorCustomerHistoryRepository.cs} (95%) create mode 100644 Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs diff --git a/Wonky.Client/HttpInterfaces/ICustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs similarity index 97% rename from Wonky.Client/HttpInterfaces/ICustomerHistoryRepository.cs rename to Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs index ffd59fd5..b02c3ae5 100644 --- a/Wonky.Client/HttpInterfaces/ICustomerHistoryRepository.cs +++ b/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs @@ -21,7 +21,7 @@ namespace Wonky.Client.HttpInterfaces; /// /// Interface Customer History CRM Http repository /// -public interface ICustomerHistoryRepository +public interface IAdvisorCustomerHistoryRepository { /// /// Fetch Invoice LIst diff --git a/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs new file mode 100644 index 00000000..f6cc466d --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs @@ -0,0 +1,70 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface Customer History CRM Http repository +/// +public interface ICountryCustomerHistoryRepository +{ + /// + /// Fetch Invoice LIst + /// + /// + /// + Task FetchInvoiceList(string countryCode, string companyId); + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + Task FetchInvoice(string countryCode, string companyId, string invoiceId); + + /// + /// Fetch inventory from given customer + /// + /// + /// + Task> FetchInventory(string countryCode, string companyId); + + /// + /// Fetch History for given customer + /// + /// + /// + Task> FetchHistory(string countryCode, string companyId); + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + Task> FetchHistory(string countryCode, string companyId, string sku); + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + Task ErpInvoiceToCrmRpc(string countryCode, string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs similarity index 95% rename from Wonky.Client/HttpRepository/CustomerHistoryRepository.cs rename to Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs index 57887031..3024b837 100644 --- a/Wonky.Client/HttpRepository/CustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs @@ -25,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CustomerHistoryRepository : ICustomerHistoryRepository +public class AdvisorCustomerHistoryRepository : IAdvisorCustomerHistoryRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -33,12 +33,12 @@ public class CustomerHistoryRepository : ICustomerHistoryRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CustomerHistoryRepository( - HttpClient client, ILogger logger, + public AdvisorCustomerHistoryRepository( + HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; diff --git a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs new file mode 100644 index 00000000..93e9aa77 --- /dev/null +++ b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs @@ -0,0 +1,145 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Pages; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepository +{ + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _api; + + public CountryCustomerHistoryRepository( + HttpClient client, ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _api = configuration.Value; + } + + /// + /// Fetch Invoice LIst + /// + /// + /// + /// + public async Task FetchInvoiceList(string countryCode, string companyId) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices"); + + if (!response.IsSuccessStatusCode) return new InvoiceListView(); + + var content = await response.Content.ReadAsStringAsync(); + return response.IsSuccessStatusCode + ? JsonSerializer.Deserialize(content, _options) + : new InvoiceListView(); + } + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + /// + public async Task FetchInvoice(string countryCode, string companyId, string invoiceId) + { + return await _client + .GetFromJsonAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices/{invoiceId}", _options); + } + + /// + /// Fetch inventory from given customer + /// + /// + /// + public async Task> FetchInventory(string countryCode, string companyId) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmInventoryExt}"); + if (!response.IsSuccessStatusCode) + return new List(); + var content = await response.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } + + /// + /// Fetch History for given customer + /// + /// + /// + public async Task> FetchHistory(string countryCode, string companyId) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmProductExt}"); + + if (!response.IsSuccessStatusCode) return new List(); + + var content = await response.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + public async Task> FetchHistory(string countryCode, string companyId, string sku) + { + var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmProductExt}/{sku}"); + if (!response.IsSuccessStatusCode) + return new List(); + var content = await response.Content.ReadAsStringAsync(); + return string.IsNullOrWhiteSpace(content) + ? new List() + : JsonSerializer.Deserialize>(content, _options); + } + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + public async Task ErpInvoiceToCrmRpc(string countryCode, string companyId, string syncDate) + { + var x = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmRpcSyncExt}/{syncDate}"); + if (!x.IsSuccessStatusCode) + return string.Empty; + var content = await x.Content.ReadAsStringAsync(); + return content.Replace("\"", ""); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs index 55a4eca3..37af6fa1 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs @@ -47,7 +47,7 @@ public partial class AdvisorCreateActivityPage : IDisposable [Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; } [Inject] public IAdvisorActivityRepository AdvisorActivityRepo { get; set; } [Inject] public IAdvisorReportRepository AdvisorReportRepo { get; set; } - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } // variables private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true}; private SalesItemView SelectedItem { get; set; } = new(); diff --git a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs index a688858b..a79447c9 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs @@ -28,7 +28,7 @@ namespace Wonky.Client.Pages; public partial class AdvisorCustomerInventoryListPage : IDisposable { - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } [Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IToastService Toaster { get; set; } diff --git a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs index bf299599..12d81396 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerInvoiceListPage.razor.cs @@ -17,7 +17,7 @@ public partial class AdvisorCustomerInvoiceListPage : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs index 98068853..87ee73fc 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs @@ -38,7 +38,7 @@ public partial class AdvisorCustomerViewPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; } - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } [Inject] public IAdvisorContactRepository AdvisorContactRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public VatInfoLookupService VatService { get; set; } diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 16946f72..1b2bad91 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -57,7 +57,7 @@ builder.Services.Configure(builder.Configuration.GetSection("AppInfo")) builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/Wonky.Client/Shared/InventoryReorderModal.razor.cs b/Wonky.Client/Shared/InventoryReorderModal.razor.cs index 6980fea6..a4700b87 100644 --- a/Wonky.Client/Shared/InventoryReorderModal.razor.cs +++ b/Wonky.Client/Shared/InventoryReorderModal.razor.cs @@ -29,7 +29,7 @@ public partial class InventoryReorderModal { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public SalesItemView SalesItem { get; set; } = new(); - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } [Parameter] public EventCallback OnSelected { get; set; } private List? History { get; set; } = new(); private DraftItem SelectedItem { get; set; } = new(); diff --git a/Wonky.Client/Shared/InvoiceViewModal.razor.cs b/Wonky.Client/Shared/InvoiceViewModal.razor.cs index 198abaf4..2f014a10 100644 --- a/Wonky.Client/Shared/InvoiceViewModal.razor.cs +++ b/Wonky.Client/Shared/InvoiceViewModal.razor.cs @@ -30,7 +30,7 @@ public partial class InvoiceViewModal : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string InvoiceId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } private string _modalDisplay = ""; private bool _showBackdrop; private InvoiceView Invoice { get; set; } = new(); diff --git a/Wonky.Client/Shared/ProductHistoryModal.razor.cs b/Wonky.Client/Shared/ProductHistoryModal.razor.cs index 1daa2872..9089b133 100644 --- a/Wonky.Client/Shared/ProductHistoryModal.razor.cs +++ b/Wonky.Client/Shared/ProductHistoryModal.razor.cs @@ -29,7 +29,7 @@ public partial class ProductHistoryModal // [Parameter] public EventCallback OnSelected { get; set; } [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string ItemSku { get; set; } = ""; - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } private List? History { get; set; } private string ProductName { get; set; } = ""; private string _modalDisplay = ""; diff --git a/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs b/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs index d8afefe0..0dc5f6c2 100644 --- a/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs +++ b/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs @@ -29,7 +29,7 @@ public partial class ProductPriceHistoryModal [Parameter] public EventCallback OnSelected { get; set; } [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string Sku { get; set; } = ""; - [Inject] public ICustomerHistoryRepository HistoryRepo { get; set; } + [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } private List? History { get; set; } private string ProductName { get; set; } = ""; private string _modalDisplay = ""; From e1b9004629cf9877c0d3cad3d4cb2945219029da Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 5 Jan 2023 17:56:42 +0100 Subject: [PATCH 12/49] wip - creating phone order page --- .../ICountryReportRepository.cs | 8 + .../HttpRepository/CountryReportRepository.cs | 11 + .../Pages/AdvisorCreateActivityPage.razor.cs | 1 - .../Pages/CountryCreateNewOrderPage.razor | 238 ++++++++++++++++++ .../Pages/CountryCreateNewOrderPage.razor.cs | 204 +++++++++++++++ .../Pages/CountryCustomerViewPage.razor | 28 --- .../Pages/CountryCustomerViewPage.razor.cs | 38 --- Wonky.Client/Program.cs | 5 +- 8 files changed, 464 insertions(+), 69 deletions(-) create mode 100644 Wonky.Client/Pages/CountryCreateNewOrderPage.razor create mode 100644 Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs delete mode 100644 Wonky.Client/Pages/CountryCustomerViewPage.razor delete mode 100644 Wonky.Client/Pages/CountryCustomerViewPage.razor.cs diff --git a/Wonky.Client/HttpInterfaces/ICountryReportRepository.cs b/Wonky.Client/HttpInterfaces/ICountryReportRepository.cs index 00d4b74e..914cd7de 100644 --- a/Wonky.Client/HttpInterfaces/ICountryReportRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICountryReportRepository.cs @@ -24,6 +24,14 @@ namespace Wonky.Client.HttpInterfaces; /// Possibly duplicated in IReportHttpRepository public interface ICountryReportRepository { + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + /// + Task ReportExist(string salesRepId, string workDate); + /// /// Get Reports for given userId (Office) /// diff --git a/Wonky.Client/HttpRepository/CountryReportRepository.cs b/Wonky.Client/HttpRepository/CountryReportRepository.cs index 84abc430..38b67849 100644 --- a/Wonky.Client/HttpRepository/CountryReportRepository.cs +++ b/Wonky.Client/HttpRepository/CountryReportRepository.cs @@ -47,6 +47,17 @@ public class CountryReportRepository : ICountryReportRepository _apiConfig = configuration.Value; } + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + public async Task ReportExist(string salesRepId, string workDate) + { + var result = await _client.GetFromJsonAsync( + $"{_apiConfig.OfficeReports}/exist/{workDate}"); + return result.ReportClosed; + } /// /// Get Reports for given userId (Office) /// diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs index 37af6fa1..ba28a001 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs @@ -18,7 +18,6 @@ using System.Text.Json; using Blazored.LocalStorage; using Blazored.Toast.Services; using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpRepository; using Wonky.Client.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; diff --git a/Wonky.Client/Pages/CountryCreateNewOrderPage.razor b/Wonky.Client/Pages/CountryCreateNewOrderPage.razor new file mode 100644 index 00000000..1827437f --- /dev/null +++ b/Wonky.Client/Pages/CountryCreateNewOrderPage.razor @@ -0,0 +1,238 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Admin,Warehouse")] +@page "/office/customers/{CountryCode}/{CompanyId}/view" + +
+
+ +
+
+ +
+
+

@Activity.Name - @Activity.Account

+
+
+ +@if (ReportClosed) +{ +
+
+

Der kan ikke oprettes bestilling når der findes rapport for @SelectedDate.ToShortDateString()

+
+
+ +} +else +{ + + + +
+
+ + +
+
+ +
+ +
+ + +
+ + +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ @* Order lines -----------------------------------------------------*@ +
+
+ + + + + + + + + + + + + + + + + + @if (DraftProvider.Draft.Items.Count > 0) + { + @foreach (var cartItem in DraftProvider.Draft.Items) + { + + + + + + + + + + } + } + + + + + + + +
+ Ordrekladde Global kladde (udløber efter @(DraftProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) + + +
NavnVarenrAntalEnhedspris%Linjesum
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@($"{cartItem.Price:N2}")@($"{cartItem.Discount:N2}")@($"{cartItem.LineTotal:N2}") + +
Total@($"{DraftProvider.Draft.Total:N2}") + +
+
+
+ @* draft line ----------------------------------------------------- *@ +
+
+ @if (!string.IsNullOrWhiteSpace(SelectedItem.Name) && ShowItem) + { + + + + + + + + + + + + + + + + + + + + + + +
Kladdelinje
AntalPrisRabatVarenr.
+ + +
+ + +
+
+ + @SelectedItem.Sku + +
+ } +
+
+ @* end draft line ------------------------------------------------- *@ +
+
+ @* Delivery address *@ +
+

+ +

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ +
+
+} diff --git a/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs b/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs new file mode 100644 index 00000000..028a50e6 --- /dev/null +++ b/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs @@ -0,0 +1,204 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Text.Json; +using Wonky.Client.HttpInterceptors; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Client.Services; +using Wonky.Client.Shared; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class CountryCreateNewOrderPage : IDisposable +{ + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string CountryCode { get; set; } = ""; + + [CascadingParameter] public DraftStateProvider DraftProvider { get; set; } + + [Inject] public ILogger Logger { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public ICountryCustomerRepository CustomerRepo { get; set; } + [Inject] public ICountryCustomerHistoryRepository InventoryRepo { get; set; } + [Inject] public ICountryReportRepository ReportRepo { get; set; } + [Inject] public ISystemUserRepository UserRepo { get; set; } + + private DateTime SelectedDate { get; set; } + private CompanyDto _company { get; set; } = new(); + private List CustomerInventory { get; set; } = new(); + private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true}; + private SalesItemView SelectedItem { get; set; } = new(); + private UserPref UserPrefs { get; set; } = new(); + private ActivityDto Activity { get; set; } = new(); + private EditContext ActivityContext { get; set; } + private bool ShowItem { get; set; } + private string Quantity { get; set; } = "1"; + private string Price { get; set; } = "0"; + private string Discount { get; set; } = "0"; + private bool ReportClosed { get; set; } + private bool PoFormInvalid { get; set; } = true; + private bool Working { get; set; } + private WebUserInfoView ThisUserInfo { get; set; } = new(); + + + protected override async Task OnInitializedAsync() + { + ActivityContext = new EditContext(Activity); + ActivityContext.OnFieldChanged += HandleFieldChanged; + ActivityContext.OnValidationStateChanged += ValidationChanged; + + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + _company = await CustomerRepo.GetByCustomerId(CountryCode, CompanyId); + var today = $"{DateTime.Now:yyyy-MM-dd}"; + var ts = _company.HistorySync; + if (ts != today) + ts = await InventoryRepo.ErpInvoiceToCrmRpc(CountryCode, CompanyId, ts); + while (ts != today) + await Task.Delay(500); + // raise flag if report is closed + ReportClosed = await ReportRepo.ReportExist(_company.SalesRepId, ts); + // customer inventory + CustomerInventory = await InventoryRepo.FetchInventory(CountryCode, CompanyId); + // get sales rep info + ThisUserInfo = await UserRepo.GetAdvisorInfo(_company.SalesRepId); + // setting up base data + Activity.BcId = _company.BcId; + Activity.ActivityStatusEnum = "noSale"; + Activity.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall"; + Activity.ActivityTypeEnum = "phone"; + Activity.ActivityStatusEnum = "order"; + Activity.CompanyId = _company.CompanyId; + Activity.SalesRepId = _company.SalesRepId; + Activity.SalesRep = ThisUserInfo.Advisor; + Activity.CountryCode = ThisUserInfo.CountryCode; + Activity.Account = _company.Account; + Activity.VatNumber = _company.VatNumber; + Activity.Email = _company.Email; + Activity.Phone = _company.Phone; + Activity.Mobile = _company.Mobile; + Activity.Name = _company.Name; + Activity.Address1 = _company.Address1; + Activity.Address2 = _company.Address2; + Activity.ZipCode = _company.ZipCode; + Activity.City = _company.City; + Activity.DlvName = _company.Name; + Activity.DlvAddress1 = _company.Address1; + Activity.DlvAddress2 = _company.Address2; + Activity.DlvZipCode = _company.ZipCode; + Activity.DlvCity = _company.City; + // Initialize date variable + SelectedDate = DateTime.Now; + } + + private void CallPriceListModal() + { + + } + private void CallPriceHistoryModal() + { + + } + private void DeleteDraft() + { + + } + + private void AddItem(SalesItemView item) + { + + } + private void RemoveItem(DraftItem item) + { + + } + + private void CreateActivity() + { + + } + + /// + /// Work Date component callback + /// + /// + private async Task WorkDateComponentCallback(string workDate) + { + ReportClosed = await ReportRepo.ReportExist(_company.SalesRepId, workDate); + SelectedDate = DateTime.Parse(workDate); + Activity.ActivityDate = workDate; + } + + /// + /// Edit Context handle field change + /// + /// + /// + private void HandleFieldChanged(object sender, FieldChangedEventArgs e) + { + Logger.LogDebug("ActivityNewPage => HandleFieldChanged => ActivityStatusEnum <= '{}'", Activity.ActivityStatusEnum); + DraftProvider.Draft.DraftType = Activity.ActivityStatusEnum; + if (Activity.ActivityStatusEnum == "noSale") + { + Logger.LogDebug("ActivityNewPage => ActivityStatusEnum == 'noSale' <= remove items"); + DraftProvider.Draft.Items = new List(); + + } + + // InvalidCanvas = InvalidActivityType; + if (Activity.YourRef.Length > 35 || Activity.ReferenceNumber.Length > 20 || DraftProvider.Draft.Items.Count == 0) + { + PoFormInvalid = true; + return; + } + PoFormInvalid = !ActivityContext.Validate(); + StateHasChanged(); + } + + /// + /// Edit Context handle validation change + /// + /// + /// + private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) + { + if (string.IsNullOrEmpty(Activity.ActivityTypeEnum) && !ReportClosed) + { + PoFormInvalid = true; + return; + } + PoFormInvalid = false; + ActivityContext.OnFieldChanged -= HandleFieldChanged; + ActivityContext.OnValidationStateChanged -= ValidationChanged; + ActivityContext = new EditContext(Activity); + ActivityContext.OnFieldChanged += HandleFieldChanged; + ActivityContext.OnValidationStateChanged += ValidationChanged; + } + + /// + /// Implement Dispose from IDisposable + /// + public void Dispose() + { + Interceptor.DisposeEvent(); + ActivityContext.OnFieldChanged -= HandleFieldChanged; + ActivityContext.OnValidationStateChanged -= ValidationChanged; + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CountryCustomerViewPage.razor b/Wonky.Client/Pages/CountryCustomerViewPage.razor deleted file mode 100644 index e1372503..00000000 --- a/Wonky.Client/Pages/CountryCustomerViewPage.razor +++ /dev/null @@ -1,28 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components -@using Wonky.Client.Components -@attribute [Authorize(Roles = "Admin,Warehouse")] -@page "/office/customers/{CountryCode}/{CompanyId}/view" - -
-
-

Data for @CountryCode.ToUpper() Id '@CompanyId' er ikke klar

-
-
diff --git a/Wonky.Client/Pages/CountryCustomerViewPage.razor.cs b/Wonky.Client/Pages/CountryCustomerViewPage.razor.cs deleted file mode 100644 index 13341fb2..00000000 --- a/Wonky.Client/Pages/CountryCustomerViewPage.razor.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System.Text.Json; -using System.Text.RegularExpressions; -using Blazored.LocalStorage; -using Blazored.Toast.Services; -using Wonky.Client.HttpInterceptors; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using Wonky.Client.Helpers; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.Models; -using Wonky.Client.Services; -using Wonky.Client.Shared; -using Wonky.Entity.DTO; -using Wonky.Entity.Models; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class CountryCustomerViewPage -{ - [Parameter] public string CompanyId { get; set; } = ""; - [Parameter] public string CountryCode { get; set; } = ""; -} \ No newline at end of file diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 1b2bad91..a51e9c15 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -59,14 +59,15 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); // administrative repositories -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); // warehouse repository builder.Services.AddScoped(); // mail service From 4f8f24132c4ab455196c0319357d9a2dcb7dab42 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 10 Jan 2023 13:51:14 +0100 Subject: [PATCH 13/49] WIP --- Wonky.Client/HttpRepository/CountryCustomerRepository.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Wonky.Client/HttpRepository/CountryCustomerRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerRepository.cs index 5f99aac7..5669600f 100644 --- a/Wonky.Client/HttpRepository/CountryCustomerRepository.cs +++ b/Wonky.Client/HttpRepository/CountryCustomerRepository.cs @@ -108,7 +108,7 @@ public class CountryCustomerRepository : ICountryCustomerRepository ["hasFolded"] = paging.HasFolded.ToString(), }; - var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString)); + var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/{countryCode}/salesRep/{salesRepId}/", queryString)); var content = await response.Content.ReadAsStringAsync(); var pagingResponse = new PagingResponse { @@ -127,7 +127,7 @@ public class CountryCustomerRepository : ICountryCustomerRepository /// public async Task GetByCustomerId(string countryCode, string companyId) { - var company = await _client.GetFromJsonAsync($"{_api.OfficeCustomers}/id/{companyId}"); + var company = await _client.GetFromJsonAsync($"{_api.OfficeCustomers}/{countryCode}/id/{companyId}"); return company ?? new CompanyDto(); } @@ -140,7 +140,7 @@ public class CountryCustomerRepository : ICountryCustomerRepository /// public async Task UpdateCompany(string countryCode, string companyId, CompanyDto model) { - var response = await _client.PutAsJsonAsync($"{_api.OfficeCustomers}/{companyId}", model); + var response = await _client.PutAsJsonAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}", model); var content = await response.Content.ReadAsStringAsync(); Console.WriteLine(content); return response.IsSuccessStatusCode; From 94afd3e8c378cdc3e6981b31f69d44f859d36f0d Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 10 Jan 2023 14:58:14 +0100 Subject: [PATCH 14/49] added info page on quote pictograms --- Wonky.Client.sln.DotSettings | 4 +++ ...t.razor => InfoColorCodingComponent.razor} | 0 ...css => InfoColorCodingComponent.razor.css} | 0 .../InfoQuoteToolbarComponent.razor | 33 +++++++++++++++++++ .../Components/QuoteListComponent.razor | 10 +++--- .../HttpRepository/AdvisorReportRepository.cs | 17 ++++++++++ .../Pages/AdvisorCreateActivityPage.razor | 2 +- .../Pages/AdvisorCreateActivityPage.razor.cs | 13 ++++++-- Wonky.Client/Pages/AdvisorQuoteListPage.razor | 22 ++++++------- .../Pages/AdvisorReportCreatePage.razor.cs | 6 ++-- Wonky.Client/Pages/InfoPage.razor | 9 +++-- 11 files changed, 90 insertions(+), 26 deletions(-) rename Wonky.Client/Components/{ColorCodingComponent.razor => InfoColorCodingComponent.razor} (100%) rename Wonky.Client/Components/{ColorCodingComponent.razor.css => InfoColorCodingComponent.razor.css} (100%) create mode 100644 Wonky.Client/Components/InfoQuoteToolbarComponent.razor diff --git a/Wonky.Client.sln.DotSettings b/Wonky.Client.sln.DotSettings index 9438812a..22a99637 100644 --- a/Wonky.Client.sln.DotSettings +++ b/Wonky.Client.sln.DotSettings @@ -1,6 +1,10 @@  True True + True + True True + True + True True True \ No newline at end of file diff --git a/Wonky.Client/Components/ColorCodingComponent.razor b/Wonky.Client/Components/InfoColorCodingComponent.razor similarity index 100% rename from Wonky.Client/Components/ColorCodingComponent.razor rename to Wonky.Client/Components/InfoColorCodingComponent.razor diff --git a/Wonky.Client/Components/ColorCodingComponent.razor.css b/Wonky.Client/Components/InfoColorCodingComponent.razor.css similarity index 100% rename from Wonky.Client/Components/ColorCodingComponent.razor.css rename to Wonky.Client/Components/InfoColorCodingComponent.razor.css diff --git a/Wonky.Client/Components/InfoQuoteToolbarComponent.razor b/Wonky.Client/Components/InfoQuoteToolbarComponent.razor new file mode 100644 index 00000000..2803fdf4 --- /dev/null +++ b/Wonky.Client/Components/InfoQuoteToolbarComponent.razor @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
Alle tilbud
Tabte tilbud
Ingen svar
Åbne tilbud
Aktive aftaler
Åbne tilbud / Aktive aftaler
diff --git a/Wonky.Client/Components/QuoteListComponent.razor b/Wonky.Client/Components/QuoteListComponent.razor index ef741305..c07e912e 100644 --- a/Wonky.Client/Components/QuoteListComponent.razor +++ b/Wonky.Client/Components/QuoteListComponent.razor @@ -46,19 +46,19 @@ @switch (quote.QuoteStatusEnum) { case "None": - + break; case "Lose": - + break; case "Note": - + break; case "Archive": - + break; default: - + break; } diff --git a/Wonky.Client/HttpRepository/AdvisorReportRepository.cs b/Wonky.Client/HttpRepository/AdvisorReportRepository.cs index c242ef1b..4f09c0b2 100644 --- a/Wonky.Client/HttpRepository/AdvisorReportRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorReportRepository.cs @@ -104,8 +104,25 @@ public class AdvisorReportRepository : IAdvisorReportRepository { var response = await _client .PostAsJsonAsync($"{_apiConfig.CrmReports}/{workDate}", reportDto, _options); + if (!response.IsSuccessStatusCode) + return new ApiResponseView + { + Code = (int) response.StatusCode, + Id = "", + Message = "Der er opstået en fejl.", + IsSuccess = false + }; var jsonDate = await response.Content.ReadAsStringAsync(); + if(string.IsNullOrWhiteSpace(jsonDate)) + return new ApiResponseView + { + Code = (int) response.StatusCode, + Id = "", + Message = "Response er tom", + IsSuccess = response.IsSuccessStatusCode + }; + var result = JsonSerializer.Deserialize(jsonDate); return new ApiResponseView { diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor index 5836a8a3..1aa03ab5 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor @@ -317,7 +317,7 @@ else Kundekort
- +
} diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs index 55a4eca3..cbeb463e 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs @@ -77,6 +77,7 @@ public partial class AdvisorCreateActivityPage : IDisposable private ConfirmWorkDateModal ConfirmWorkDateModal { get; set; } = new(); private ConfirmProductCheckModal ConfirmProductCheckModal { get; set; } = new(); private List CheckList { get; set; } = new(); + private string ButtonText { get; set; } = "Gem besøg"; /// @@ -444,10 +445,16 @@ public partial class AdvisorCreateActivityPage : IDisposable { Logger.LogDebug("ActivityNewPage => ActivityStatusEnum == 'noSale' <= remove items"); DraftProvider.Draft.Items = new List(); - } - - + + ButtonText = Activity.ActivityStatusEnum switch + { + "noSale" => "Gem Besøg", + "order" => "Gem Bestilling", + "quote" => "Gem Tilbud", + _ => ButtonText + }; + // InvalidCanvas = InvalidActivityType; InvalidActivity = InvalidActivityType || PoFormInvalid diff --git a/Wonky.Client/Pages/AdvisorQuoteListPage.razor b/Wonky.Client/Pages/AdvisorQuoteListPage.razor index 3a053261..b1d69a00 100644 --- a/Wonky.Client/Pages/AdvisorQuoteListPage.razor +++ b/Wonky.Client/Pages/AdvisorQuoteListPage.razor @@ -27,23 +27,23 @@
+ + + - + - - - - - - - - + + - + + + + - +
@* diff --git a/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs index f0849828..db488281 100644 --- a/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorReportCreatePage.razor.cs @@ -69,8 +69,8 @@ public partial class AdvisorReportCreatePage : IDisposable if (!string.IsNullOrWhiteSpace(Prefs.WorkDate)) _workDate = DateTime.Parse(Prefs.WorkDate); - // if(await CrmReportRepo.ReportExist(Prefs.WorkDate)) - // Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); + if(await AdvisorReportRepo.ReportExist(Prefs.WorkDate)) + Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); BeginLeave = _workDate; EndLeave = _workDate; @@ -131,7 +131,7 @@ public partial class AdvisorReportCreatePage : IDisposable Working = true; var result = await AdvisorReportRepo.CreateReport($"{_workDate:yyyy-MM-dd}", Report); - Toaster.ShowInfo($"{result.Message}", $"HTTP Status"); + Logger.LogDebug("CreateReport.result => {}", JsonSerializer.Serialize(result)); // reset km and date confirmation await ProfileService.SetKmMorning(0); diff --git a/Wonky.Client/Pages/InfoPage.razor b/Wonky.Client/Pages/InfoPage.razor index 5d78d83b..ba460ea3 100644 --- a/Wonky.Client/Pages/InfoPage.razor +++ b/Wonky.Client/Pages/InfoPage.razor @@ -31,9 +31,12 @@
-
-

Piktogrammer

- +

Piktogrammer

+
+ +
+
+
From 920ed03e67ae9575ee830f14d782d92bebe98777 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 10 Jan 2023 14:58:56 +0100 Subject: [PATCH 15/49] bump version --- Wonky.Client/wwwroot/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 293bb2de..9747c1d8 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.95.1", + "version": "0.95.2", "rc": true, "sandBox": false, "image": "grumpy-coder.png" From ef521fcff27c67c3472367ee278d810a8ace4f2a Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 11 Jan 2023 09:43:01 +0100 Subject: [PATCH 16/49] bump version --- Wonky.Client/wwwroot/appsettings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 9747c1d8..13b3316b 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.95.2", + "version": "0.96.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://dev.innotec.dk", + "baseUrl": "https://eta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From 090e44b47372df9d550219f1cea6dde259af9da0 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 11 Jan 2023 13:06:52 +0100 Subject: [PATCH 17/49] bump version --- Wonky.Client/wwwroot/appsettings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 9747c1d8..3c6b75c3 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.95.2", + "version": "0.96.2", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://dev.innotec.dk", + "baseUrl": "https://eta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From 03ae5bbfefc49dd3a4bcd2f063b4d18b53602445 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 11 Jan 2023 13:10:54 +0100 Subject: [PATCH 18/49] dev settings --- Wonky.Client/wwwroot/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 3c6b75c3..88cb0a6c 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -7,7 +7,7 @@ "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://eta.innotec.dk", + "baseUrl": "https://dev.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From 40ad1d42d642c11402e9fa46c7b9536896e12f72 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 11 Jan 2023 13:56:58 +0100 Subject: [PATCH 19/49] cosmetic update --- .../AdvisorCompanyTableComponent.razor | 2 +- .../Components/InfoBrowserComponent.razor | 9 +++ ...razor => InfoColorCustomerComponent.razor} | 41 ++++--------- ...s => InfoColorCustomerComponent.razor.css} | 0 .../InfoColorPackageComponent.razor | 61 +++++++++++++++++++ .../InfoColorPackageComponent.razor.css | 4 ++ .../Components/InfoOpenSourceComponent.razor | 12 ++++ .../InfoProcessStateComponent.razor | 34 +++++++++++ .../InfoQuoteToolbarComponent.razor | 14 ++--- Wonky.Client/Pages/InfoPage.razor | 43 ++++--------- Wonky.Client/wwwroot/appsettings.json | 4 +- 11 files changed, 154 insertions(+), 70 deletions(-) create mode 100644 Wonky.Client/Components/InfoBrowserComponent.razor rename Wonky.Client/Components/{InfoColorCodingComponent.razor => InfoColorCustomerComponent.razor} (71%) rename Wonky.Client/Components/{InfoColorCodingComponent.razor.css => InfoColorCustomerComponent.razor.css} (100%) create mode 100644 Wonky.Client/Components/InfoColorPackageComponent.razor create mode 100644 Wonky.Client/Components/InfoColorPackageComponent.razor.css create mode 100644 Wonky.Client/Components/InfoOpenSourceComponent.razor create mode 100644 Wonky.Client/Components/InfoProcessStateComponent.razor diff --git a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor b/Wonky.Client/Components/AdvisorCompanyTableComponent.razor index bfa7ad6a..2f46f5da 100644 --- a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor +++ b/Wonky.Client/Components/AdvisorCompanyTableComponent.razor @@ -42,7 +42,7 @@ @if (!string.IsNullOrWhiteSpace(company.Note)) { - + } diff --git a/Wonky.Client/Components/InfoBrowserComponent.razor b/Wonky.Client/Components/InfoBrowserComponent.razor new file mode 100644 index 00000000..c89a7e63 --- /dev/null +++ b/Wonky.Client/Components/InfoBrowserComponent.razor @@ -0,0 +1,9 @@ +

Testede browsere

+
    +
  • Safari (macOS, iOS)
  • +
  • Chrome (Linux, Windows, Android)
  • +
  • Edge (Linux, Windows, Android)
  • +
  • Firefox (Linux, Windows, Android)
  • +
  • Chromium (Linux)
  • +
  • Vivaldi (Linux)
  • +
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorCodingComponent.razor b/Wonky.Client/Components/InfoColorCustomerComponent.razor similarity index 71% rename from Wonky.Client/Components/InfoColorCodingComponent.razor rename to Wonky.Client/Components/InfoColorCustomerComponent.razor index c05bd7c7..e4071b09 100644 --- a/Wonky.Client/Components/InfoColorCodingComponent.razor +++ b/Wonky.Client/Components/InfoColorCustomerComponent.razor @@ -16,14 +16,23 @@ *@ @using Wonky.Client.Components +

Kunde Info

- - + + + + + + - - - - - - - - - - - -
Kunde / Besøg StatusPakning / ForsendelseSymbolBetydning
+ + + Vigtig info registreret +
@@ -31,12 +40,6 @@
Er nylig besøgt -
- -
-
Ubehandlet
@@ -45,12 +48,6 @@ Planlæg -
- -
-
Varer er plukket
@@ -59,12 +56,6 @@ Interval Overskredet -
- -
-
Varer er pakket
@@ -73,12 +64,6 @@ Ajourfør besøgsdato/interval -
- -
-
Varer er afsendt
@@ -87,8 +72,6 @@ Virksomhed ophørt
@@ -97,8 +80,6 @@ CVR/ORG nummer ugyldig
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorCodingComponent.razor.css b/Wonky.Client/Components/InfoColorCustomerComponent.razor.css similarity index 100% rename from Wonky.Client/Components/InfoColorCodingComponent.razor.css rename to Wonky.Client/Components/InfoColorCustomerComponent.razor.css diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor b/Wonky.Client/Components/InfoColorPackageComponent.razor new file mode 100644 index 00000000..7b70594e --- /dev/null +++ b/Wonky.Client/Components/InfoColorPackageComponent.razor @@ -0,0 +1,61 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ +@using Wonky.Client.Components + +

Pakning / Forsendelse

+ + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
+
+ +
+
Ubehandlet
+
+ +
+
Varer er plukket
+
+ +
+
Varer er pakket
+
+ +
+
Varer er afsendt
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor.css b/Wonky.Client/Components/InfoColorPackageComponent.razor.css new file mode 100644 index 00000000..002017f5 --- /dev/null +++ b/Wonky.Client/Components/InfoColorPackageComponent.razor.css @@ -0,0 +1,4 @@ + +.color-code { + max-width: 40px; +} \ No newline at end of file diff --git a/Wonky.Client/Components/InfoOpenSourceComponent.razor b/Wonky.Client/Components/InfoOpenSourceComponent.razor new file mode 100644 index 00000000..ca542448 --- /dev/null +++ b/Wonky.Client/Components/InfoOpenSourceComponent.razor @@ -0,0 +1,12 @@ +

Open Source

+ \ No newline at end of file diff --git a/Wonky.Client/Components/InfoProcessStateComponent.razor b/Wonky.Client/Components/InfoProcessStateComponent.razor new file mode 100644 index 00000000..5edd239d --- /dev/null +++ b/Wonky.Client/Components/InfoProcessStateComponent.razor @@ -0,0 +1,34 @@ + +

Aktivitet Oversigt

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolBetydning
Ekspress
Telefon
Ubehandlet
Plukket
Pakket
Afhentet
diff --git a/Wonky.Client/Components/InfoQuoteToolbarComponent.razor b/Wonky.Client/Components/InfoQuoteToolbarComponent.razor index 2803fdf4..5f76cc6e 100644 --- a/Wonky.Client/Components/InfoQuoteToolbarComponent.razor +++ b/Wonky.Client/Components/InfoQuoteToolbarComponent.razor @@ -1,4 +1,4 @@ - +

Aftaler / Tilbud

@@ -6,27 +6,27 @@ - + - + - + - + - + - + diff --git a/Wonky.Client/Pages/InfoPage.razor b/Wonky.Client/Pages/InfoPage.razor index ba460ea3..fbb87db4 100644 --- a/Wonky.Client/Pages/InfoPage.razor +++ b/Wonky.Client/Pages/InfoPage.razor @@ -32,40 +32,23 @@

Piktogrammer

-
- +
+
-
+
+ +
+
-
-
-
-

Testede browsere

-
    -
  • Safari (macOS, iOS)
  • -
  • Chrome (Linux, Windows, Android)
  • -
  • Edge (Linux, Windows, Android)
  • -
  • Firefox (Linux, Windows, Android)
  • -
  • Chromium (Linux)
  • -
  • Vivaldi (Linux)
  • -
+
+
-
-
- diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 88cb0a6c..45039bdf 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.96.2", + "version": "0.96.3", "rc": true, "sandBox": false, "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://dev.innotec.dk", + "baseUrl": "https://zeta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", From bd3d62f029744fb586ebac0fe4c1cf425f776529 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Wed, 11 Jan 2023 13:59:17 +0100 Subject: [PATCH 20/49] more cosmetic --- Wonky.Client/Components/AdvisorCompanyTableComponent.razor | 2 +- Wonky.Client/wwwroot/appsettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor b/Wonky.Client/Components/AdvisorCompanyTableComponent.razor index 2f46f5da..378ac3ce 100644 --- a/Wonky.Client/Components/AdvisorCompanyTableComponent.razor +++ b/Wonky.Client/Components/AdvisorCompanyTableComponent.razor @@ -42,7 +42,7 @@
Betydning
Alle tilbud
Tabte tilbud
Ingen svar
Åbne tilbud
Aktive aftaler
Åbne tilbud / Aktive aftaler
@if (!string.IsNullOrWhiteSpace(company.Note)) { - + } diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 45039bdf..fba26895 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.96.3", + "version": "0.96.4", "rc": true, "sandBox": false, "image": "grumpy-coder.png" From be52137c15f1f048bc9bc8d925f38354e3da9035 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 12 Jan 2023 18:09:18 +0100 Subject: [PATCH 21/49] WIP - admin office front end --- .../InfoColorCustomerComponent.razor.css | 6 ++- .../InfoColorPackageComponent.razor.css | 6 ++- .../IAdvisorCustomerHistoryRepository.cs | 2 +- .../ICountryCustomerHistoryRepository.cs | 2 +- .../AdvisorCustomerHistoryRepository.cs | 4 +- .../CountryCustomerHistoryRepository.cs | 4 +- .../Pages/AdvisorCreateActivityPage.razor.cs | 2 +- .../Pages/AdvisorCustomerViewPage.razor.cs | 2 +- .../Pages/CountryCreateNewOrderPage.razor.cs | 2 +- Wonky.Client/wwwroot/appsettings.json | 6 ++- Wonky.Entity/Configuration/ApiConfig.cs | 50 +++++++++++-------- 11 files changed, 51 insertions(+), 35 deletions(-) diff --git a/Wonky.Client/Components/InfoColorCustomerComponent.razor.css b/Wonky.Client/Components/InfoColorCustomerComponent.razor.css index 002017f5..d28e2116 100644 --- a/Wonky.Client/Components/InfoColorCustomerComponent.razor.css +++ b/Wonky.Client/Components/InfoColorCustomerComponent.razor.css @@ -1,4 +1,6 @@ - +.pictogram { + max-width: 30px; +} .color-code { - max-width: 40px; + max-width: 30px; } \ No newline at end of file diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor.css b/Wonky.Client/Components/InfoColorPackageComponent.razor.css index 002017f5..d28e2116 100644 --- a/Wonky.Client/Components/InfoColorPackageComponent.razor.css +++ b/Wonky.Client/Components/InfoColorPackageComponent.razor.css @@ -1,4 +1,6 @@ - +.pictogram { + max-width: 30px; +} .color-code { - max-width: 40px; + max-width: 30px; } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs index b02c3ae5..8233c00d 100644 --- a/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpInterfaces/IAdvisorCustomerHistoryRepository.cs @@ -66,5 +66,5 @@ public interface IAdvisorCustomerHistoryRepository /// /// /// - Task ErpInvoiceToCrmRpc(string companyId, string syncDate); + Task InvoiceErpToCrmRpc(string companyId, string syncDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs index f6cc466d..1fa695b4 100644 --- a/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICountryCustomerHistoryRepository.cs @@ -66,5 +66,5 @@ public interface ICountryCustomerHistoryRepository /// /// /// - Task ErpInvoiceToCrmRpc(string countryCode, string companyId, string syncDate); + Task InvoiceErpToCrmRpc(string countryCode, string companyId, string syncDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs index 3024b837..fc292b80 100644 --- a/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorCustomerHistoryRepository.cs @@ -128,9 +128,9 @@ public class AdvisorCustomerHistoryRepository : IAdvisorCustomerHistoryRepositor /// /// /// - public async Task ErpInvoiceToCrmRpc(string companyId, string syncDate) + public async Task InvoiceErpToCrmRpc(string companyId, string syncDate) { - var x = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmRpcSyncExt}/{syncDate}"); + var x = await _client.GetAsync($"{_api.SyncRpc}/companies/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); if (!x.IsSuccessStatusCode) return string.Empty; var content = await x.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs index 93e9aa77..5b3a9e54 100644 --- a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs @@ -134,9 +134,9 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor /// /// /// - public async Task ErpInvoiceToCrmRpc(string countryCode, string companyId, string syncDate) + public async Task InvoiceErpToCrmRpc(string countryCode, string companyId, string syncDate) { - var x = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.CrmRpcSyncExt}/{syncDate}"); + var x = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); if (!x.IsSuccessStatusCode) return string.Empty; var content = await x.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs index e8a016c8..8ffd4d04 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor.cs @@ -182,7 +182,7 @@ public partial class AdvisorCreateActivityPage : IDisposable // product inventory has not been updated // send rpc call to sync ERP to CRM Toast.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ..."); - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, _company.HistorySync); + var ts = await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, _company.HistorySync); while (string.IsNullOrWhiteSpace(ts)) await Task.Delay(500); // save pDate diff --git a/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs index 87ee73fc..00cab0be 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerViewPage.razor.cs @@ -139,7 +139,7 @@ public partial class AdvisorCustomerViewPage : IDisposable await FetchContacts(CompanyId); - var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync); + var ts = await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync); // remove loading image Working = false; diff --git a/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs b/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs index 028a50e6..ba4edabd 100644 --- a/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs +++ b/Wonky.Client/Pages/CountryCreateNewOrderPage.razor.cs @@ -70,7 +70,7 @@ public partial class CountryCreateNewOrderPage : IDisposable var today = $"{DateTime.Now:yyyy-MM-dd}"; var ts = _company.HistorySync; if (ts != today) - ts = await InventoryRepo.ErpInvoiceToCrmRpc(CountryCode, CompanyId, ts); + ts = await InventoryRepo.InvoiceErpToCrmRpc(CountryCode, CompanyId, ts); while (ts != today) await Task.Delay(500); // raise flag if report is closed diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index fba26895..4a8f02b8 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -7,16 +7,16 @@ "image": "grumpy-coder.png" }, "apiConfig": { - "baseUrl": "https://zeta.innotec.dk", + "baseUrl": "https://eta.innotec.dk", "catalog": "api/v2/catalog", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory", "crmProductExt": "history/products", "crmReports": "api/v2/crm/advisors/reports", "crmActivities": "api/v2/crm/advisors/activities", - "crmRpcSyncExt": "invoices/rpc", "crmTasks": "api/v2/crm/advisors/tasks", "crmWorkplaceExt": "workplaces", + "officeBase": "api/v2/office", "officeAdvisors": "api/v2/office/users/advisors", "officeCustomers": "api/v2/office/customers", "officeReports": "api/v2/office/reports", @@ -29,6 +29,8 @@ "serviceVatEu": "api/v2/services/vies", "servicesVatNo": "api/v2/services/brReg", "servicesAuth": "token", + "syncRpc": "api/v2/rpc", + "syncRpcInvoiceExt": "invoices/rpc", "userInfo": "api/auth/userinfo", "warehouse": "api/v2/warehouse/packages" }, diff --git a/Wonky.Entity/Configuration/ApiConfig.cs b/Wonky.Entity/Configuration/ApiConfig.cs index ad07c6f0..a6c20ae9 100644 --- a/Wonky.Entity/Configuration/ApiConfig.cs +++ b/Wonky.Entity/Configuration/ApiConfig.cs @@ -12,6 +12,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // + namespace Wonky.Entity.Configuration; public class ApiConfig @@ -20,7 +21,7 @@ public class ApiConfig /// Application base url /// public string BaseUrl { get; set; } = ""; - + /// /// Application uri for product catalog request /// @@ -45,37 +46,37 @@ public class ApiConfig /// Application uri for customer information request /// public string CrmCustomers { get; set; } = ""; - + /// /// Application uri for customer product inventory request /// public string CrmInventoryExt { get; set; } = ""; - + /// /// Application uri for customer product sale request /// public string CrmProductExt { get; set; } = ""; - - /// - /// Application uri for updating customer product sale request - /// - public string CrmRpcSyncExt { get; set; } = ""; /// /// Application uri for getting workplace(s) /// public string CrmWorkplaceExt { get; set; } = ""; - + + /// + /// Office base url + /// + public string OfficeBase { get; set; } = ""; + /// /// Application uri for administration of sales representatives /// public string OfficeAdvisors { get; set; } = ""; - + /// /// Application uri for administration of administrative users /// public string OfficeUsers { get; set; } = ""; - + /// /// Application uri for administrative reset of user credentials /// @@ -95,45 +96,54 @@ public class ApiConfig /// Application uri for token request /// public string ServicesAuth { get; set; } = ""; - + /// /// GLS tracking url /// public string ServicesGlsTrackUrl { get; set; } = ""; - + /// /// GLS customer entity /// public string ServicesGlsId { get; set; } = ""; - + /// /// url for sending mail message /// public string ServicesMail { get; set; } = ""; - + /// /// VAT registrar url Denmark /// public string ServicesVatDk { get; set; } = ""; - + /// /// VAT registrar url Norway /// public string ServicesVatNo { get; set; } = ""; - + /// /// VAT registrar url EU /// public string ServicesVatEu { get; set; } = ""; - + + /// + /// Base sync url + /// + public string SyncRpc { get; set; } = ""; + + /// + /// Application uri for updating customer product sale request + /// + public string SyncRpcInvoiceExt { get; set; } = ""; + /// /// Application uri for user information request /// public string UserInfo { get; set; } = ""; - + /// /// Uri for warehouse requests /// public string Warehouse { get; set; } = ""; - } \ No newline at end of file From b82bc43ded488eb98c5b46a23f1e90518b743529 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Sun, 15 Jan 2023 13:42:04 +0100 Subject: [PATCH 22/49] cosmetic when in portrait mode on tablet --- .../AdvisorActivityListComponent.razor | 92 +++++++++++ ...AdvisorReportActivityLedgerComponent.razor | 93 +++++++++++ .../Components/CatalogSearchComponent.razor | 6 +- .../Components/CatalogSortComponent.razor | 4 +- .../CompanySearchColumnComponent.razor | 10 +- .../Components/CompanySortComponent.razor | 4 +- .../ReportActivityLedgerComponent.razor | 7 +- .../ReportActivityLedgerComponent.razor.cs | 24 --- .../ReportActivityTableOfficeComponent.razor | 8 +- .../Pages/AdvisorCreateActivityPage.razor | 18 +-- .../Pages/AdvisorReportCreatePage.razor | 147 +----------------- .../Shared/ConfirmProductCheckModal.razor | 2 +- .../Shared/InventoryReorderModal.razor | 2 +- Wonky.Client/Shared/InvoiceViewModal.razor | 2 +- Wonky.Client/Shared/PriceListModal.razor | 2 +- Wonky.Client/Shared/ProductHistoryModal.razor | 2 +- .../Shared/ProductPriceHistoryModal.razor | 2 +- Wonky.Client/Shared/VatLookupDkModal.razor | 2 +- Wonky.Client/wwwroot/appsettings.json | 2 +- 19 files changed, 232 insertions(+), 197 deletions(-) create mode 100644 Wonky.Client/Components/AdvisorActivityListComponent.razor create mode 100644 Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor delete mode 100644 Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs diff --git a/Wonky.Client/Components/AdvisorActivityListComponent.razor b/Wonky.Client/Components/AdvisorActivityListComponent.razor new file mode 100644 index 00000000..13ed7bfa --- /dev/null +++ b/Wonky.Client/Components/AdvisorActivityListComponent.razor @@ -0,0 +1,92 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ +@using Wonky.Entity.Views + +@* Report activities *@ + + + + + + + + + + + + + + + + + + @foreach (var activity in Activities) + { + + + + + + + + + + + + + + } + + + + + + + +
KundeBynavnDemoSalgNotesasBeløb + + + + + + + +
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum.Contains("Quote") ? $"{0:N2}" : $"{activity.OrderAmount:N2}") + @if (activity.OurRef.Contains("T:")) + { + + } + + @if (activity.Express) + { + + } + + @if (activity.StatusTypeEnum == "Quote") + { + + } + + +
Total@Activities.Where(x => x.StatusTypeEnum != "Quote").Sum(x => x.OrderAmount)
+ +@code { + + [Parameter] + public List Activities { get; set; } = new(); + +} \ No newline at end of file diff --git a/Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor b/Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor new file mode 100644 index 00000000..bb2f8831 --- /dev/null +++ b/Wonky.Client/Components/AdvisorReportActivityLedgerComponent.razor @@ -0,0 +1,93 @@ +@using Wonky.Entity.Views +@using Wonky.Entity.DTO +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Dagens Demo @(ReportData.NewDemoCount + ReportData.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@ReportData.NewVisitCount@ReportData.NewDemoCount@ReportData.NewSaleCount@ReportData.NewTurnover@ReportData.NewVisitCountMonth@ReportData.NewDemoCountMonth@ReportData.NewSaleCountMonth@ReportData.NewTurnoverMonth
R@ReportData.RecallVisitCount@ReportData.RecallDemoCount@ReportData.RecallSaleCount@ReportData.RecallTurnover@ReportData.RecallVisitCountMonth@ReportData.RecallDemoCountMonth@ReportData.RecallSaleCountMonth@ReportData.RecallTurnoverMonth
SAS@ReportData.SasCount@ReportData.SasTurnover@ReportData.SasCountMonth@ReportData.SasTurnoverMonth
TOTAL@ReportData.TotalVisitCount@ReportData.TotalDemoCount@ReportData.TotalSaleCount@ReportData.TotalTurnover@ReportData.TotalVisitCountMonth@ReportData.TotalDemoCountMonth@ReportData.TotalSaleCountMonth@ReportData.TotalTurnoverMonth
+ +@code{ + + [Parameter] + public ReportFiguresDto ReportData { get; set; } = new(); + +} \ No newline at end of file diff --git a/Wonky.Client/Components/CatalogSearchComponent.razor b/Wonky.Client/Components/CatalogSearchComponent.razor index 64fb9429..e5e76efc 100644 --- a/Wonky.Client/Components/CatalogSearchComponent.razor +++ b/Wonky.Client/Components/CatalogSearchComponent.razor @@ -17,7 +17,7 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/CatalogSortComponent.razor b/Wonky.Client/Components/CatalogSortComponent.razor index 09dedc9b..6d92ab1e 100644 --- a/Wonky.Client/Components/CatalogSortComponent.razor +++ b/Wonky.Client/Components/CatalogSortComponent.razor @@ -17,6 +17,6 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/CompanySearchColumnComponent.razor b/Wonky.Client/Components/CompanySearchColumnComponent.razor index 3d6d41b6..bd08fc0a 100644 --- a/Wonky.Client/Components/CompanySearchColumnComponent.razor +++ b/Wonky.Client/Components/CompanySearchColumnComponent.razor @@ -17,9 +17,9 @@ diff --git a/Wonky.Client/Components/CompanySortComponent.razor b/Wonky.Client/Components/CompanySortComponent.razor index 4540f25c..0fe514a0 100644 --- a/Wonky.Client/Components/CompanySortComponent.razor +++ b/Wonky.Client/Components/CompanySortComponent.razor @@ -17,6 +17,6 @@ \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityLedgerComponent.razor b/Wonky.Client/Components/ReportActivityLedgerComponent.razor index 153d2759..6e804234 100644 --- a/Wonky.Client/Components/ReportActivityLedgerComponent.razor +++ b/Wonky.Client/Components/ReportActivityLedgerComponent.razor @@ -1,3 +1,4 @@ +@using Wonky.Entity.Views @* // Copyright (C) 2022 FCS Frede's Computer Services. // This program is free software: you can redistribute it and/or modify @@ -84,4 +85,8 @@
-
\ No newline at end of file +
+ +@code{ + [Parameter] public ReportData ReportData { get; set; } = new(); +} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs b/Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs deleted file mode 100644 index 870de4ef..00000000 --- a/Wonky.Client/Components/ReportActivityLedgerComponent.razor.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Entity.Views; -using Microsoft.AspNetCore.Components; - -namespace Wonky.Client.Components; - -public partial class ReportActivityLedgerComponent -{ - [Parameter] public ReportData ReportData { get; set; } = new(); -} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor b/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor index a9cf370e..e27dfb30 100644 --- a/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor +++ b/Wonky.Client/Components/ReportActivityTableOfficeComponent.razor @@ -27,10 +27,10 @@ Note sas Beløb - - - - + + + + diff --git a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor index 1aa03ab5..2ac2a359 100644 --- a/Wonky.Client/Pages/AdvisorCreateActivityPage.razor +++ b/Wonky.Client/Pages/AdvisorCreateActivityPage.razor @@ -156,7 +156,7 @@ else
- @* Order lines -----------------------------------------------------*@ + @* Draft lines in draft -----------------------------------------------------*@
@@ -216,7 +216,7 @@ else
- @* draft line ----------------------------------------------------- *@ + @* Create Draft line ----------------------------------------------------- *@
@if (!string.IsNullOrWhiteSpace(SelectedItem.Name) && ShowItem) @@ -227,9 +227,9 @@ else Kladdelinje - Antal - Pris - Rabat + Antal + Pris + Rabat SAS Varenr. @@ -237,10 +237,10 @@ else - + - +
- + @@ -256,7 +256,7 @@ else @SelectedItem.Sku - + diff --git a/Wonky.Client/Pages/AdvisorReportCreatePage.razor b/Wonky.Client/Pages/AdvisorReportCreatePage.razor index 28706842..22fbe885 100644 --- a/Wonky.Client/Pages/AdvisorReportCreatePage.razor +++ b/Wonky.Client/Pages/AdvisorReportCreatePage.razor @@ -17,6 +17,7 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components +@using Wonky.Entity.Views @attribute [Authorize(Roles = "Advisor")] @page "/sales-reports/new" @@ -36,7 +37,7 @@
- + @@ -105,9 +106,9 @@ @* details input *@
Dag / Periode Begyndt Afsluttet
- - - + + + @@ -129,7 +130,7 @@ @* distance ledger input *@
TekstSupervisor
BeskrivelseMin medkørende supervisor
- + @@ -156,145 +157,13 @@ @if (Activities.Any()) {
- @* Report activities *@ -
Km aften Km morgen Km privat
- - - - - - - - - - - - - - - - - @foreach (var activity in Activities) - { - - - - - - - - - - - - - - } - - - - - - - -
KundeBynavnDemoSalgNotesasBeløb - - - - - - - -
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum.Contains("Quote") ? $"{0:N2}" : $"{activity.OrderAmount:N2}") - @if (activity.OurRef.Contains("T:")) - { - - } - - @if (activity.Express) - { - - } - - @if (activity.StatusTypeEnum == "Quote") - { - - } - - -
Total@Activities.Where(x => x.StatusTypeEnum != "Quote").Sum(x => x.OrderAmount)
+
} }
@* ledger summaries calculated *@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dagens Demo @(Report.Figures.NewDemoCount + Report.Figures.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@Report.Figures.NewVisitCount@Report.Figures.NewDemoCount@Report.Figures.NewSaleCount@Report.Figures.NewTurnover@Report.Figures.NewVisitCountMonth@Report.Figures.NewDemoCountMonth@Report.Figures.NewSaleCountMonth@Report.Figures.NewTurnoverMonth
R@Report.Figures.RecallVisitCount@Report.Figures.RecallDemoCount@Report.Figures.RecallSaleCount@Report.Figures.RecallTurnover@Report.Figures.RecallVisitCountMonth@Report.Figures.RecallDemoCountMonth@Report.Figures.RecallSaleCountMonth@Report.Figures.RecallTurnoverMonth
SAS@Report.Figures.SasCount@Report.Figures.SasTurnover@Report.Figures.SasCountMonth@Report.Figures.SasTurnoverMonth
TOTAL@Report.Figures.TotalVisitCount@Report.Figures.TotalDemoCount@Report.Figures.TotalSaleCount@Report.Figures.TotalTurnover@Report.Figures.TotalVisitCountMonth@Report.Figures.TotalDemoCountMonth@Report.Figures.TotalSaleCountMonth@Report.Figures.TotalTurnoverMonth
+
diff --git a/Wonky.Client/Shared/ConfirmProductCheckModal.razor b/Wonky.Client/Shared/ConfirmProductCheckModal.razor index 6aa75cee..e1e852b3 100644 --- a/Wonky.Client/Shared/ConfirmProductCheckModal.razor +++ b/Wonky.Client/Shared/ConfirmProductCheckModal.razor @@ -16,7 +16,7 @@ *@ @using Wonky.Client.Components