#129 donation accounting models

This commit is contained in:
Hamid Reza Mohammadi 2021-06-04 19:45:57 +04:30
parent ebbe50705f
commit 1b7427fa89
6 changed files with 2865 additions and 1 deletions

View File

@ -24,7 +24,7 @@ namespace RMuseum.DbContext
{
public RMuseumDbContext(DbContextOptions<RMuseumDbContext> options) : base(options)
{
//Database.Migrate();
Database.Migrate();
}
/// <summary>
@ -111,6 +111,22 @@ namespace RMuseum.DbContext
//Index set suggested by SQL Server Tuning Wizard -- end
builder.Entity<GanjoorDonation>()
.Property(c => c.Amount)
.HasColumnType("decimal(18,2)");
builder.Entity<GanjoorDonation>()
.Property(c => c.Remaining)
.HasColumnType("decimal(18,2)");
builder.Entity<GanjoorExpense>()
.Property(c => c.Amount)
.HasColumnType("decimal(18,2)");
builder.Entity<DonationExpenditure>()
.Property(c => c.Amount)
.HasColumnType("decimal(18,2)");
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,98 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class DonationAccounting : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GanjoorDonations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DateString = table.Column<string>(type: "nvarchar(max)", nullable: true),
RecordDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Unit = table.Column<string>(type: "nvarchar(max)", nullable: true),
AmountString = table.Column<string>(type: "nvarchar(max)", nullable: true),
DonorName = table.Column<string>(type: "nvarchar(max)", nullable: true),
DonorLink = table.Column<string>(type: "nvarchar(max)", nullable: true),
Remaining = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
ExpenditureDesc = table.Column<string>(type: "nvarchar(max)", nullable: true),
ImportedRecord = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorDonations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "GanjoorExpenses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ExpenseDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
Unit = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorExpenses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DonationExpenditure",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
GanjoorDonationId = table.Column<int>(type: "int", nullable: false),
Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
GanjoorExpenseId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DonationExpenditure", x => x.Id);
table.ForeignKey(
name: "FK_DonationExpenditure_GanjoorDonations_GanjoorDonationId",
column: x => x.GanjoorDonationId,
principalTable: "GanjoorDonations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DonationExpenditure_GanjoorExpenses_GanjoorExpenseId",
column: x => x.GanjoorExpenseId,
principalTable: "GanjoorExpenses",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_DonationExpenditure_GanjoorDonationId",
table: "DonationExpenditure",
column: "GanjoorDonationId");
migrationBuilder.CreateIndex(
name: "IX_DonationExpenditure_GanjoorExpenseId",
table: "DonationExpenditure",
column: "GanjoorExpenseId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DonationExpenditure");
migrationBuilder.DropTable(
name: "GanjoorDonations");
migrationBuilder.DropTable(
name: "GanjoorExpenses");
}
}
}

View File

@ -120,6 +120,97 @@ namespace RMuseum.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("RMuseum.Models.Accounting.DonationExpenditure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<decimal>("Amount")
.HasColumnType("decimal(18,2)");
b.Property<int>("GanjoorDonationId")
.HasColumnType("int");
b.Property<int?>("GanjoorExpenseId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GanjoorDonationId");
b.HasIndex("GanjoorExpenseId");
b.ToTable("DonationExpenditure");
});
modelBuilder.Entity("RMuseum.Models.Accounting.GanjoorDonation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<decimal>("Amount")
.HasColumnType("decimal(18,2)");
b.Property<string>("AmountString")
.HasColumnType("nvarchar(max)");
b.Property<string>("DateString")
.HasColumnType("nvarchar(max)");
b.Property<string>("DonorLink")
.HasColumnType("nvarchar(max)");
b.Property<string>("DonorName")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExpenditureDesc")
.HasColumnType("nvarchar(max)");
b.Property<bool>("ImportedRecord")
.HasColumnType("bit");
b.Property<DateTime>("RecordDate")
.HasColumnType("datetime2");
b.Property<decimal>("Remaining")
.HasColumnType("decimal(18,2)");
b.Property<string>("Unit")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("GanjoorDonations");
});
modelBuilder.Entity("RMuseum.Models.Accounting.GanjoorExpense", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<decimal>("Amount")
.HasColumnType("decimal(18,2)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("ExpenseDate")
.HasColumnType("datetime2");
b.Property<string>("Unit")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("GanjoorExpenses");
});
modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactItemRecord", b =>
{
b.Property<Guid>("Id")
@ -1955,6 +2046,21 @@ namespace RMuseum.Migrations
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.Accounting.DonationExpenditure", b =>
{
b.HasOne("RMuseum.Models.Accounting.GanjoorDonation", "GanjoorDonation")
.WithMany()
.HasForeignKey("GanjoorDonationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("RMuseum.Models.Accounting.GanjoorExpense", null)
.WithMany("DonationExpenditures")
.HasForeignKey("GanjoorExpenseId");
b.Navigation("GanjoorDonation");
});
modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactItemRecord", b =>
{
b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", null)
@ -2468,6 +2574,11 @@ namespace RMuseum.Migrations
.HasForeignKey("RArtifactItemRecordId");
});
modelBuilder.Entity("RMuseum.Models.Accounting.GanjoorExpense", b =>
{
b.Navigation("DonationExpenditures");
});
modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactItemRecord", b =>
{
b.Navigation("Images");

View File

@ -5,6 +5,10 @@
/// </summary>
public class DonationExpenditure
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// GanjoorDonation Id
/// </summary>

View File

@ -1499,6 +1499,11 @@
donation expenditures
</summary>
</member>
<member name="P:RMuseum.Models.Accounting.DonationExpenditure.Id">
<summary>
Id
</summary>
</member>
<member name="P:RMuseum.Models.Accounting.DonationExpenditure.GanjoorDonationId">
<summary>
GanjoorDonation Id