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 = "";