feat: implement VAT management service and integrate VAT calculations across components
This commit is contained in:
@@ -7,12 +7,16 @@ namespace FrontOffice.Main.Pages.Store;
|
||||
public partial class Cart : ComponentBase, IDisposable
|
||||
{
|
||||
[Inject] private CartService CartService { get; set; } = default!;
|
||||
[Inject] private VATService VAT { get; set; } = default!;
|
||||
// Navigation and Snackbar are available via _Imports.razor
|
||||
private CartService CartData => CartService;
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// لود سبد خرید (فقط اگر کاربر لاگین کرده باشد)
|
||||
await CartService.EnsureInitializedAsync();
|
||||
CartService.OnChange += StateHasChanged;
|
||||
await VAT.LoadAsync();
|
||||
}
|
||||
|
||||
private async Task IncrementQty(long productId)
|
||||
@@ -44,7 +48,13 @@ public partial class Cart : ComponentBase, IDisposable
|
||||
Navigation.NavigateTo(RouteConstants.Store.CheckoutSummary);
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} ", price);
|
||||
private string FormatPrice(long price) => $"{price:N0} ";
|
||||
|
||||
private string FormatPriceWithVAT(long price) => $"{VAT.AddVAT(price):N0} ";
|
||||
|
||||
private long TotalWithVAT => VAT.AddVAT(CartData.Total);
|
||||
|
||||
private long VATAmount => VAT.CalculateVAT(CartData.Total);
|
||||
|
||||
private static string GetProductImageUrl(string? imageUrl)
|
||||
=> string.IsNullOrWhiteSpace(imageUrl) ? "/images/product-placeholder.svg" : imageUrl;
|
||||
|
||||
Reference in New Issue
Block a user