Skip to content

Commit

Permalink
Add dividend table and improve export format of the tables
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpung committed Oct 14, 2023
1 parent 0c6d291 commit 2081dfe
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 13 deletions.
45 changes: 45 additions & 0 deletions BlazorApp-Investment Tax Calculator/Components/DividendTable.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@using Model
@using Model.Interfaces;
@using Syncfusion.Blazor.Grids;

@inject IDividendLists dividendList

<p>Imported Dividends and withholding taxes</p>

<SfGrid ID="ImportedDividendGrid" @ref="importedDividendGrid" DataSource="@dividendList.Dividends"
AllowPaging="true" AllowSorting="true" AllowPdfExport="true" AllowExcelExport="true" AllowResizing="true"
Toolbar="@(new List<string>() { "PdfExport", "ExcelExport", "Print" })" Height="1000px">
<GridPageSettings PageSizes="true"></GridPageSettings>
<GridEvents OnToolbarClick="ToolbarClickHandler" TValue="Dividend"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Dividend.Date) HeaderText="Date" Format="d"></GridColumn>
<GridColumn Field=@nameof(Dividend.DividendType) HeaderText="Dividend/Withholding tax"></GridColumn>
<GridColumn Field=@nameof(Dividend.AssetName) HeaderText="Asset Name"></GridColumn>
<GridColumn Field=@nameof(Dividend.CompanyLocation) HeaderText="Company location"></GridColumn>
<GridColumn Field=@(nameof(Dividend.Proceed) + "." + nameof(DescribedMoney.BaseCurrencyAmount)) HeaderText="Sterling Amount"></GridColumn>
<GridColumn Field=@(nameof(Dividend.Proceed) + "." + nameof(DescribedMoney.Amount)) HeaderText="Local Currency Amount"></GridColumn>
<GridColumn Field=@(nameof(Dividend.Proceed) + "." + nameof(DescribedMoney.Description)) HeaderText="Description"></GridColumn>
</GridColumns>
</SfGrid>

@code {
private SfGrid<Dividend> importedDividendGrid = new();

public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "ImportedDividendGrid_pdfexport") //Id is combination of Grid's ID and itemname
{
var pdfExportProperties = new PdfExportProperties()
{
PageOrientation = PageOrientation.Landscape,
PageSize = PdfPageSize.A4
};
await importedDividendGrid.ExportToPdfAsync(pdfExportProperties);
}
if (args.Item.Id == "ImportedDividendGrid_excelexport") //Id is combination of Grid's ID and itemname
{
await importedDividendGrid.ExportToExcelAsync();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<GridColumn Field=@nameof(ITradeTaxCalculation.TotalProceeds) HeaderText="Total Proceeeds"></GridColumn>
<GridColumn Field=@nameof(ITradeTaxCalculation.TotalAllowableCost) HeaderText="Allowable Cost"></GridColumn>
<GridColumn Field=@nameof(ITradeTaxCalculation.Gain) HeaderText="Gain (Loss)"></GridColumn>
<GridColumn Field=@nameof(ITradeTaxCalculation.CalculationCompleted) HeaderText="Completely Matched?"></GridColumn>
<GridColumn Field=@nameof(ITradeTaxCalculation.UnmatchedQty) HeaderText="Unmatched shares"></GridColumn>
</GridColumns>
<GridTemplates>
<DetailTemplate>
Expand Down Expand Up @@ -47,11 +47,16 @@

public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "ResultGrid_pdfexport") //Id is combination of Grid's ID and itemname
if (args.Item.Id == "DisposalCalculationGrid_pdfexport") //Id is combination of Grid's ID and itemname
{
await disposalCalculationGrid.ExportToPdfAsync();
var pdfExportProperties = new PdfExportProperties()
{
PageOrientation = PageOrientation.Landscape,
PageSize = PdfPageSize.A4
};
await disposalCalculationGrid.ExportToPdfAsync(pdfExportProperties);
}
if (args.Item.Id == "ResultGrid_excelexport") //Id is combination of Grid's ID and itemname
if (args.Item.Id == "DisposalCalculationGrid_excelexport") //Id is combination of Grid's ID and itemname
{
await disposalCalculationGrid.ExportToExcelAsync();
}
Expand Down
7 changes: 2 additions & 5 deletions BlazorApp-Investment Tax Calculator/Model/DescribedMoney.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ public string PrintToTextFile()

public string Display()
{
string outputString;
if (Description == string.Empty) outputString = Amount.ToString();
else outputString = $"{Description}: {Amount}";
if (FxRate == 1)
{
return outputString;
return BaseCurrencyAmount.ToString();
}
else return $"{BaseCurrencyAmount} ({outputString})";
else return $"{BaseCurrencyAmount} ({Amount})";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "/DividendDataPage"

@using BlazorApp_Investment_Tax_Calculator.Components

<DividendTable />
3 changes: 2 additions & 1 deletion BlazorApp-Investment Tax Calculator/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

<p>To sum up, this application assist you filling out the SA106, SA108 tax form.</p>

<p>Currently only the import/export tab is usable. To get started gather some sample XML files and try to import it by going to the import/export tab.</p>
<p>Currently you can import/export and view calulations and dividend data, the add missing trade tab is not functional.
To get started gather some sample XML files and try to import it by going to the import/export tab.</p>

<p>Your trade data is not uploaded anywhere. They never leave your browser thanks to Blazor WASM framework. The calculation is entirely done in your browser.</p>

Expand Down
2 changes: 1 addition & 1 deletion BlazorApp-Investment Tax Calculator/Pages/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
new listData {Id="1", Text = "Home", IconCss = "sb-icons icon-grid e-sb-icon control-icon", PageAddress = ""},
new listData {Id="2",Text = "Import/Export", IconCss = "sb-icons icon-chart e-sb-icon control-icon", PageAddress = "MainCalculatorPage"},
new listData {Id="3",Text = "Disposal Summary", IconCss = "sb-icons icon-datepicker e-sb-icon control-icon", PageAddress = "CalculationViewPage"},
new listData {Id="4", Text = "Dividend Data", IconCss = "sb-icons icon-dialog e-sb-icon control-icon", PageAddress = "MainCalculatorPage"},
new listData {Id="4", Text = "Dividend Data", IconCss = "sb-icons icon-dialog e-sb-icon control-icon", PageAddress = "DividendDataPage"},
new listData {Id="5", Text = "Add missing trade", IconCss = "sb-icons icon-dropdownlist e-sb-icon control-icon", PageAddress = "MainCalculatorPage"}
};
public class listData
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Anyone interested can implement a new parser implementing ITaxEventFileParser.
https://github.com/alexpung/UK-Investment-tax-calculator/tree/master/BlazorApp-Investment%20Tax%20Calculator/Parser/InteractiveBrokersXml

## Current functionality
#### Parsed trade type:
### Parsed trade type:
1. Trades:
1. Stock orders
2. Dividend income
Expand All @@ -31,11 +31,12 @@ https://github.com/alexpung/UK-Investment-tax-calculator/tree/master/BlazorApp-I
3. Dividend in Lieu.
3. Corporate actions
1. Forward split only
4. View trade calculations and dividend data in a table

#### Pending implementation
FX, Futures (not sure if I want to handle delivery calculation.....)
More corporate actions
Viewing your imported trade in a separate table.
Viewing imported trade and flattened trade matching details in tables.
Add missing trade and export it.
Tests and feedback are welcome, bugs are to be expected.

Expand Down

0 comments on commit 2081dfe

Please sign in to comment.