Lagt till stockisin
This commit is contained in:
@ -19,7 +19,7 @@ public class AppDbContext : DbContext
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
modelBuilder.Entity<TransactionNote>()
|
||||
.HasIndex(t => new { t.StockCode, t.TransactionDate })
|
||||
.HasIndex(t => new { t.StockISIN, t.StockCode, t.TransactionDate })
|
||||
.IsUnique(true);
|
||||
modelBuilder.Entity<StockEquity>()
|
||||
.HasIndex(s => new { s.Bought })
|
||||
@ -28,7 +28,7 @@ public class AppDbContext : DbContext
|
||||
.HasIndex(s => new { s.Sold })
|
||||
.IsUnique(false);
|
||||
modelBuilder.Entity<StockEquity>()
|
||||
.HasIndex(s => new { s.Bought, s.StockCode, s.Quantity })
|
||||
.HasIndex(s => new { s.Bought, s.StockISIN, s.Quantity })
|
||||
.IsUnique(false);
|
||||
modelBuilder.Entity<SglStockEquity>()
|
||||
.HasIndex(s => new { s.Bought })
|
||||
|
||||
@ -27,6 +27,7 @@ public class HandleCsvNotes : IHandleCsvNotes
|
||||
TransactionDate = DateTime.Parse(values[NamePos(Header_table, "Datum")]),
|
||||
TransactionType = values[NamePos(Header_table, "Typ av transaktion")] == "Köp" ? "KÖP" : "SÄLJ",
|
||||
StockCode = values[NamePos(Header_table, @"Värdepapper/beskrivning")],
|
||||
StockISIN = values[NamePos(Header_table, "ISIN")],
|
||||
StockPrice = decimal.Parse((values[NamePos(Header_table, "Kurs")] == "") ? "0" : values[NamePos(Header_table, "Kurs")]),
|
||||
Currency = values[NamePos(Header_table, @"Instrumentvaluta")],
|
||||
StockQuantity = Math.Abs(ParseCsvNumber(values[NamePos(Header_table, "Antal")])),
|
||||
@ -64,6 +65,7 @@ public class HandleCsvNotes : IHandleCsvNotes
|
||||
TransactionDate = DateTime.Parse(values[NamePos(Header_table, "Affärsdag")]),
|
||||
TransactionType = values[NamePos(Header_table, "Transaktion")] == "Köp" ? "KÖP" : "SÄLJ",
|
||||
StockCode = values[NamePos(Header_table, @"Värdepapper")],
|
||||
StockISIN = values[NamePos(Header_table, "ISIN")],
|
||||
StockPrice = decimal.Parse((values[NamePos(Header_table, "Kurs")] == "") ? "0" : values[NamePos(Header_table, "Kurs")]),
|
||||
Currency = values[NamePos(Header_table, @"Noteringsvaluta")],
|
||||
StockQuantity = Math.Abs(ParseCsvNumber(values[NamePos(Header_table, "Innehavsförändring")])),
|
||||
|
||||
155
StockHistory/Migrations/20260928083725_newfield_StockISIN.Designer.cs
generated
Normal file
155
StockHistory/Migrations/20260928083725_newfield_StockISIN.Designer.cs
generated
Normal file
@ -0,0 +1,155 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using StockHistory.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StockHistory.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20260928083725_newfield_StockISIN")]
|
||||
partial class newfield_StockISIN
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.6");
|
||||
|
||||
modelBuilder.Entity("StockHistory.Models.SglStockEquity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Bought")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("BoughtPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Sold")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("SoldPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SoldQuant")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("StockCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Bought");
|
||||
|
||||
b.HasIndex("Sold");
|
||||
|
||||
b.HasIndex("Bought", "StockCode", "Quantity");
|
||||
|
||||
b.ToTable("SglStocks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StockHistory.Models.StockEquity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Bought")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("BoughtPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Sold")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("SoldPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SoldQuant")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("StockCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StockISIN")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Bought");
|
||||
|
||||
b.HasIndex("Sold");
|
||||
|
||||
b.HasIndex("Bought", "StockISIN", "Quantity");
|
||||
|
||||
b.ToTable("Stocks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StockHistory.Models.TransactionNote", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("AmountToPay")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Commission")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Currency")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("ExchangeRate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StockCode")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StockISIN")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StockPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("StockQuantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("TotalAmount")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("TransactionDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("TransactionType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StockISIN", "StockCode", "TransactionDate")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("TransactionNotes");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
77
StockHistory/Migrations/20260928083725_newfield_StockISIN.cs
Normal file
77
StockHistory/Migrations/20260928083725_newfield_StockISIN.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StockHistory.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class newfield_StockISIN : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_TransactionNotes_StockCode_TransactionDate",
|
||||
table: "TransactionNotes");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Stocks_Bought_StockCode_Quantity",
|
||||
table: "Stocks");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "StockISIN",
|
||||
table: "TransactionNotes",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "StockISIN",
|
||||
table: "Stocks",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TransactionNotes_StockISIN_StockCode_TransactionDate",
|
||||
table: "TransactionNotes",
|
||||
columns: new[] { "StockISIN", "StockCode", "TransactionDate" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Stocks_Bought_StockISIN_Quantity",
|
||||
table: "Stocks",
|
||||
columns: new[] { "Bought", "StockISIN", "Quantity" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_TransactionNotes_StockISIN_StockCode_TransactionDate",
|
||||
table: "TransactionNotes");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Stocks_Bought_StockISIN_Quantity",
|
||||
table: "Stocks");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StockISIN",
|
||||
table: "TransactionNotes");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StockISIN",
|
||||
table: "Stocks");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TransactionNotes_StockCode_TransactionDate",
|
||||
table: "TransactionNotes",
|
||||
columns: new[] { "StockCode", "TransactionDate" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Stocks_Bought_StockCode_Quantity",
|
||||
table: "Stocks",
|
||||
columns: new[] { "Bought", "StockCode", "Quantity" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,13 +84,17 @@ namespace StockHistory.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StockISIN")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Bought");
|
||||
|
||||
b.HasIndex("Sold");
|
||||
|
||||
b.HasIndex("Bought", "StockCode", "Quantity");
|
||||
b.HasIndex("Bought", "StockISIN", "Quantity");
|
||||
|
||||
b.ToTable("Stocks");
|
||||
});
|
||||
@ -117,6 +121,9 @@ namespace StockHistory.Migrations
|
||||
b.Property<string>("StockCode")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StockISIN")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StockPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@ -134,7 +141,7 @@ namespace StockHistory.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StockCode", "TransactionDate")
|
||||
b.HasIndex("StockISIN", "StockCode", "TransactionDate")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("TransactionNotes");
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
public class EquityTemp
|
||||
{
|
||||
public string StockCode { get; set; } = string.Empty;
|
||||
public string StockISIN { get; set; } = string.Empty;
|
||||
public DateTime Bought { get; set; }
|
||||
public decimal BoughtPrice { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
|
||||
@ -4,6 +4,7 @@ public class StockEquity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string StockCode { get; set; } = string.Empty;
|
||||
public string StockISIN { get; set; } = string.Empty;
|
||||
public DateTime Bought { get; set; }
|
||||
public decimal BoughtPrice { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
|
||||
@ -6,6 +6,7 @@ public class TransactionNote
|
||||
public DateTime TransactionDate { get; set; }
|
||||
public string? TransactionType { get; set; }
|
||||
public string? StockCode { get; set; }
|
||||
public string? StockISIN { get; set; }
|
||||
public decimal StockPrice { get; set; }
|
||||
public decimal ExchangeRate { get; set; }
|
||||
public string Currency { get; set; }
|
||||
|
||||
@ -127,6 +127,7 @@ public class StockEquityServices : IStockEquityServices
|
||||
var equity = new StockEquity
|
||||
{
|
||||
StockCode = note.StockCode,
|
||||
StockISIN = note.StockISIN,
|
||||
Bought = note.TransactionDate,
|
||||
BoughtPrice = note.StockPrice,
|
||||
Quantity = note.StockQuantity,
|
||||
@ -159,6 +160,7 @@ public class StockEquityServices : IStockEquityServices
|
||||
//SoldPrice = note.StockPrice,
|
||||
//SoldQuant = note.StockQuantity
|
||||
StockCode = note.StockCode,
|
||||
StockISIN = note.StockISIN,
|
||||
Bought = note.TransactionDate,
|
||||
BoughtPrice = note.StockPrice * -1,
|
||||
Quantity = note.StockQuantity,
|
||||
@ -201,6 +203,7 @@ public class StockEquityServices : IStockEquityServices
|
||||
var splitEquity = new StockEquity
|
||||
{
|
||||
StockCode = eq.StockCode,
|
||||
StockISIN = eq.StockISIN,
|
||||
Bought = eq.Bought,
|
||||
BoughtPrice = eq.BoughtPrice,
|
||||
Quantity = soldQuant,
|
||||
|
||||
@ -35,4 +35,9 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Stockbrokerage.db">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Binary file not shown.
@ -246,6 +246,7 @@ public partial class frmStockHistoryInit : Form
|
||||
if (!string.IsNullOrWhiteSpace(line) && line.StartsWith("Affärsdag")
|
||||
|| !string.IsNullOrWhiteSpace(line) && line.StartsWith("Handelstidpunkt")
|
||||
|| !string.IsNullOrWhiteSpace(line) && line.StartsWith("Värdepapper")
|
||||
|| !string.IsNullOrWhiteSpace(line) && line.StartsWith("ISIN-kod")
|
||||
|| !string.IsNullOrWhiteSpace(line) && line.StartsWith("Kurs")
|
||||
|| !string.IsNullOrWhiteSpace(line) && line.StartsWith("Genomsnittlig")
|
||||
|| !string.IsNullOrWhiteSpace(line) && line.StartsWith("Antal")
|
||||
@ -283,6 +284,15 @@ public partial class frmStockHistoryInit : Form
|
||||
else
|
||||
trans.StockCode = templist[1];
|
||||
}
|
||||
if (line.StartsWith("ISIN-kod"))
|
||||
{
|
||||
var templist = line.Split(" ", StringSplitOptions.RemoveEmptyEntries);
|
||||
if (templist.Length > 2)
|
||||
trans.StockISIN = templist[1] + " " + templist[2];
|
||||
else
|
||||
trans.StockISIN = templist[1];
|
||||
}
|
||||
|
||||
if (line.StartsWith("Kurs"))
|
||||
{
|
||||
trans.Currency = line.Split(" ", StringSplitOptions.RemoveEmptyEntries)[1];
|
||||
@ -423,6 +433,7 @@ public partial class frmStockHistoryInit : Form
|
||||
item.SubItems.Add(t.TotalAmount.ToString());
|
||||
item.SubItems.Add(t.Commission.ToString());
|
||||
item.SubItems.Add(t.AmountToPay.ToString());
|
||||
item.SubItems.Add(t.StockISIN.ToString());
|
||||
lwTransactions.Items.Add(item);
|
||||
Debug.WriteLine(t.ToString());
|
||||
}
|
||||
|
||||
4
settings.VisualStudio.json
Normal file
4
settings.VisualStudio.json
Normal file
@ -0,0 +1,4 @@
|
||||
/* Visual Studio Settings File */
|
||||
{
|
||||
"environment.visualExperience.systemDarkTheme": "juicy-plum"
|
||||
}
|
||||
Reference in New Issue
Block a user