Lagt till nytt fält stockisin
This commit is contained in:
@ -15,7 +15,7 @@ namespace StockWebHistory.Data
|
||||
{
|
||||
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 })
|
||||
@ -24,7 +24,7 @@ namespace StockWebHistory.Data
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
||||
116
StockWebHistory/Migrations/20260927091703_newfield_ISIN.Designer.cs
generated
Normal file
116
StockWebHistory/Migrations/20260927091703_newfield_ISIN.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using StockWebHistory.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StockWebHistory.Migrations
|
||||
{
|
||||
[DbContext(typeof(StockWebDbContext))]
|
||||
[Migration("20260927091703_newfield_ISIN")]
|
||||
partial class newfield_ISIN
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
|
||||
|
||||
modelBuilder.Entity("StockWebHistory.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("StockWebHistory.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
StockWebHistory/Migrations/20260927091703_newfield_ISIN.cs
Normal file
77
StockWebHistory/Migrations/20260927091703_newfield_ISIN.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StockWebHistory.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class newfield_ISIN : 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" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,13 +45,17 @@ namespace StockWebHistory.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");
|
||||
});
|
||||
@ -78,6 +82,9 @@ namespace StockWebHistory.Migrations
|
||||
b.Property<string>("StockCode")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StockISIN")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("StockPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@ -95,7 +102,7 @@ namespace StockWebHistory.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; }
|
||||
|
||||
@ -12,6 +12,7 @@ namespace StockWebHistory.Models
|
||||
Map(m => m.Id).Ignore();
|
||||
// Matcha CSV-kolumner mot C#-egenskaper
|
||||
Map(m => m.StockCode).Name(@"Värdepapper/beskrivning", @"Värdepapper"); // Exemplet kollar flera alternativa namn
|
||||
Map(m => m.StockISIN).Name(@"ISIN"); // Exemplet kollar flera alternativa namn
|
||||
Map(m => m.TransactionDate).Name("Datum", "Date", "Affärsdag");
|
||||
Map(m => m.TransactionType).Name("Typ av transaktion", "Transaktion");
|
||||
Map(m => m.StockQuantity).Name("Antal", "Innehavsförändring");
|
||||
|
||||
@ -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,
|
||||
@ -151,14 +152,8 @@ public class StockEquityServices : IStockEquityServices
|
||||
{
|
||||
equityWarningList.Add(new StockEquity
|
||||
{
|
||||
//StockCode = note.StockCode,
|
||||
//Bought = DateTime.MinValue,
|
||||
//BoughtPrice = 0,
|
||||
//Quantity = 0,
|
||||
//Sold = note.TransactionDate,
|
||||
//SoldPrice = note.StockPrice,
|
||||
//SoldQuant = note.StockQuantity
|
||||
StockCode = note.StockCode,
|
||||
StockISIN = note.StockISIN,
|
||||
Bought = note.TransactionDate,
|
||||
BoughtPrice = note.StockPrice * -1,
|
||||
Quantity = note.StockQuantity,
|
||||
@ -201,6 +196,7 @@ public class StockEquityServices : IStockEquityServices
|
||||
var splitEquity = new StockEquity
|
||||
{
|
||||
StockCode = eq.StockCode,
|
||||
StockISIN = eq.StockISIN,
|
||||
Bought = eq.Bought,
|
||||
BoughtPrice = eq.BoughtPrice,
|
||||
Quantity = soldQuant,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -19,6 +19,7 @@
|
||||
<th>Id</th>
|
||||
<th>TransactionDate</th>
|
||||
<th>TransactionType</th>
|
||||
<th>StockCodeISIN</th>
|
||||
<th>StockCode</th>
|
||||
<th>StockPrice</th>
|
||||
<th>ExchangeRate</th>
|
||||
@ -37,6 +38,7 @@
|
||||
<td>@note.Id</td>
|
||||
<td>@note.TransactionDate.ToString("yyyy-MM-dd")</td>
|
||||
<td>@note.TransactionType</td>
|
||||
<td>@note.StockISIN</td>
|
||||
<td>@note.StockCode</td>
|
||||
<td>@note.StockPrice.ToString("F2")</td>
|
||||
<td>@(note.ExchangeRate == null ? "" : ((decimal)note.ExchangeRate).ToString("F2", System.Globalization.CultureInfo.InvariantCulture))</td>
|
||||
@ -47,11 +49,13 @@
|
||||
<td>@(note.AmountToPay == null ? "" : ((decimal)note.AmountToPay).ToString("F2", System.Globalization.CultureInfo.InvariantCulture))</td>
|
||||
<td>
|
||||
<a asp-action="CreateEditNote" asp-route-id="@note.Id">Edit</a>
|
||||
<a asp-action="DeleteNote" asp-route-id="@note.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
<td>
|
||||
<a asp-action="DeleteNote" asp-route-id="@note.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user