Invoice history - v.0.38.x
This commit is contained in:
parent
19621a8e51
commit
00ff0a66f7
13 changed files with 215 additions and 17 deletions
58
Wonky.Client/Components/InvoiceTableComponent.razor
Normal file
58
Wonky.Client/Components/InvoiceTableComponent.razor
Normal file
|
@ -0,0 +1,58 @@
|
|||
@using Wonky.Entity.Views
|
||||
@using System.Linq.Expressions
|
||||
|
||||
@if (InvoiceList.Any())
|
||||
{
|
||||
<div class="list-group">
|
||||
<div class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<h4>Dato</h4>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<h4>Faktura</h4>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<h4>Rekvisition</h4>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<h4>Reference</h4>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<h4>Beløb</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@foreach (var invoice in InvoiceList)
|
||||
{
|
||||
<div class="list-group-item list-group-item-action">
|
||||
<div class="row">
|
||||
<div class="col-md-2">@invoice.DocumentDate</div>
|
||||
<div class="col-md-2">@invoice.DocumentNumber</div>
|
||||
<div class="col-md-2">@invoice.ReferenceNumber</div>
|
||||
<div class="col-md-3">@invoice.YourRef</div>
|
||||
<div class="col-md-3">@invoice.InvoiceAmount</div>
|
||||
</div>
|
||||
@if (!string.IsNullOrWhiteSpace(invoice.OrderNote))
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-1"><i class="bi-pencil"></i></div>
|
||||
<div class="col-md-10 fw-bold">@invoice.OrderNote</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Ingen data</span>
|
||||
}
|
||||
|
||||
@code{
|
||||
|
||||
[Parameter]
|
||||
public List<InvoiceListItemView> InvoiceList { get; set; }
|
||||
|
||||
}
|
|
@ -20,6 +20,8 @@ namespace Wonky.Client.HttpInterfaces;
|
|||
|
||||
public interface ICrmHistoryHttpRepository
|
||||
{
|
||||
Task<InvoiceListView> FetchInvoiceList(string companyId);
|
||||
Task<InvoiceView> FetchInvoice(string companyId, string invoiceId);
|
||||
Task<List<ProductInventoryView>?> FetchInventory(string companyId);
|
||||
Task<List<ProductHistoryView>?> FetchHistory(string companyId);
|
||||
Task<List<ProductHistoryView>?> FetchHistory(string companyId, string sku);
|
||||
|
|
|
@ -46,6 +46,32 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository
|
|||
_navigation = navigation;
|
||||
_api = configuration.Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// fetch a list of invoices for CompanyId
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InvoiceListView> FetchInvoiceList(string companyId)
|
||||
{
|
||||
var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
return response.IsSuccessStatusCode
|
||||
? JsonSerializer.Deserialize<InvoiceListView>(content, _options)
|
||||
: new InvoiceListView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetch invoice from archiveHeadId
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="invoiceId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InvoiceView> FetchInvoice(string companyId, string invoiceId)
|
||||
{
|
||||
return await _client
|
||||
.GetFromJsonAsync<InvoiceView>($"{_api.CrmCustomers}/{companyId}/invoices/{invoiceId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fetch inventory - summarized list of products
|
||||
/// </summary>
|
||||
|
|
|
@ -34,7 +34,7 @@ public partial class CrmCompanyInventoryPage : IDisposable
|
|||
[Inject] public IToastService Toaster { get; set; }
|
||||
[Inject] public ILogger<CrmCompanyInventoryPage> Logger { get; set; }
|
||||
private CompanyDto Company { get; set; } = new();
|
||||
private List<ProductInventoryView>? Inventory { get; set; } = new();
|
||||
private List<ProductInventoryView>? Inventory { get; set; }
|
||||
private bool Loading { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
@ -49,13 +49,12 @@ public partial class CrmCompanyInventoryPage : IDisposable
|
|||
|
||||
private async Task RefreshHistory()
|
||||
{
|
||||
Toaster.ShowInfo("Varekøb opdateres ....", "Vent venligst");
|
||||
|
||||
await CrmHistoryRepo.RpcSyncErpToCrm(CompanyId, Company.HistorySync);
|
||||
|
||||
Toaster.ShowInfo("Arbejder på sagen ...", "Vent venligst");
|
||||
Inventory = await CrmHistoryRepo.FetchInventory(CompanyId);
|
||||
Inventory = Inventory.OrderBy(x => x.Description).ToList();
|
||||
Inventory = Inventory?.OrderBy(x => x.Description).ToList();
|
||||
Loading = false;
|
||||
Toaster.ClearAll();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
@page "/companies/{CompanyId}/invoices"
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2>Faktura oversigt</h2>
|
||||
@using Wonky.Client.Components
|
||||
<div class="row pt-2 pb-2 rounded-2 bg-dark text-white">
|
||||
<div class="col-6">
|
||||
<h3>@Company.Name</h3>
|
||||
</div>
|
||||
<div class="col-6 align-content-end">
|
||||
<a class="btn btn-primary" href="/companies/@Company.CompanyId">Kundekort</a>
|
||||
<a class="btn btn-primary" href="/companies/@Company.CompanyId/activities/new">Besøg</a>
|
||||
</div>
|
||||
</div>
|
||||
@if (Loading)
|
||||
{
|
||||
<LoaderThreeDots Loading="Loading"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<InvoiceTableComponent InvoiceList="@History.InvoiceList" />
|
||||
}
|
||||
|
|
|
@ -1,14 +1,45 @@
|
|||
using System.Net.NetworkInformation;
|
||||
using System.Text.Json;
|
||||
using Blazored.Toast.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpInterfaces;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Views;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class CrmCompanyInvoiceListPage
|
||||
public partial class CrmCompanyInvoiceListPage : IDisposable
|
||||
{
|
||||
[Parameter] public string CompanyId { get; set; } = "";
|
||||
[Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; }
|
||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||
[Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; }
|
||||
[Inject] public IToastService Toaster { get; set; }
|
||||
|
||||
private InvoiceListView History { get; set; } = new();
|
||||
private CompanyDto Company { get; set; }
|
||||
private bool Loading { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
|
||||
Company = await CompanyRepo.GetCompanyById(CompanyId);
|
||||
await RefreshHistory();
|
||||
}
|
||||
|
||||
private async Task RefreshHistory()
|
||||
{
|
||||
Toaster.ShowInfo("Arbejder på sagen ...", "Vent venligst");
|
||||
await HistoryRepo.RpcSyncErpToCrm(CompanyId, Company.HistorySync);
|
||||
History = await HistoryRepo.FetchInvoiceList(CompanyId);
|
||||
Loading = false;
|
||||
Toaster.ClearAll();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"appInfo": {
|
||||
"name": "Wonky Client",
|
||||
"version": "0.36.1",
|
||||
"version": "0.38.3",
|
||||
"rc": true,
|
||||
"sandBox": false,
|
||||
"image": "grumpy-coder.png"
|
||||
|
|
19
Wonky.Entity/Views/InvoiceCompanyView.cs
Normal file
19
Wonky.Entity/Views/InvoiceCompanyView.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class InvoiceCompanyView
|
||||
{
|
||||
public string CompanyId { get; set; } = "";
|
||||
public string VatNumber { get; set; } = "";
|
||||
public string Account { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Address1 { get; set; } = "";
|
||||
public string Address2 { get; set; } = "";
|
||||
public string ZipCode { get; set; } = "";
|
||||
public string City { get; set; } = "";
|
||||
public string Attention { get; set; } = "";
|
||||
public string Email { get; set; } = "";
|
||||
public string Mobile { get; set; } = "";
|
||||
public string Phone { get; set; } = "";
|
||||
public string Blocked { get; set; } = "";
|
||||
public string Note { get; set; } = "";
|
||||
}
|
10
Wonky.Entity/Views/InvoiceLineView.cs
Normal file
10
Wonky.Entity/Views/InvoiceLineView.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class InvoiceLineView
|
||||
{
|
||||
public string Sku { get; set; } = "";
|
||||
public string Text { get; set; } = "";
|
||||
public int Qty { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal Discount { get; set; }
|
||||
}
|
14
Wonky.Entity/Views/InvoiceListItemView.cs
Normal file
14
Wonky.Entity/Views/InvoiceListItemView.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class InvoiceListItemView
|
||||
{
|
||||
public string ArchiveHeadId { get; set; } = "";
|
||||
public string ESalesNumber { get; set; } = "";
|
||||
public string DocumentNumber { get; set; } = "";
|
||||
public string ReferenceNumber { get; set; } = "";
|
||||
public string YourRef { get; set; } = "";
|
||||
public string OrderNote { get; set; } = "";
|
||||
public string TrackingNumber { get; set; } = "";
|
||||
public string DocumentDate { get; set; } = "";
|
||||
public decimal InvoiceAmount { get; set; }
|
||||
}
|
7
Wonky.Entity/Views/InvoiceListView.cs
Normal file
7
Wonky.Entity/Views/InvoiceListView.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class InvoiceListView
|
||||
{
|
||||
public InvoiceCompanyView Company { get; set; } = new();
|
||||
public List<InvoiceListItemView> InvoiceList { get; set; } = new();
|
||||
}
|
19
Wonky.Entity/Views/InvoiceView.cs
Normal file
19
Wonky.Entity/Views/InvoiceView.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace Wonky.Entity.Views;
|
||||
|
||||
public class InvoiceView
|
||||
{
|
||||
public InvoiceCompanyView Company { get; set; } = new();
|
||||
public string Account { get; set; } = "";
|
||||
public string ArchiveHeadId { get; set; } = "";
|
||||
public string DocumentDate { get; set; } = "";
|
||||
public string DocumentNumber { get; set; } = "";
|
||||
public string ESalesNumber { get; set; } = "";
|
||||
public decimal InvoiceAmount { get; set; }
|
||||
public string OrderNote { get; set; } = "";
|
||||
public string OurRef { get; set; } = "";
|
||||
public string ReferenceNumber { get; set; } = "";
|
||||
public string YourRef { get; set; } = "";
|
||||
public string TrackingNumber { get; set; } = "";
|
||||
public string VatNumber { get; set; } = "";
|
||||
public List<InvoiceLineView> Lines { get; set; } = new();
|
||||
}
|
Loading…
Reference in a new issue