fde24b09c9
- Invoice Write-Off: WriteOff POST action in InvoicesController posts bad-debt JE (DR bad debt expense / CR AR), reduces customer balance, marks invoice WrittenOff; write-off modal added to Invoice Details view with expense account selector - Fixed Assets: FixedAsset + FixedAssetDepreciationEntry entities with straight-line depreciation; FixedAssetsController (Index/Create/Edit/Details/PostDepreciation/Delete); PostDepreciation auto-generates one JE per asset per period, skips already-posted, fully-depreciated, and disposed assets; full CRUD views + nav link - Period Locking: Company.BookLockedThrough field; AccountingPeriodValidator static helper; lock check added to JE Post and Bill Create (blocks backdating into closed periods); SetPeriodLock action + date picker UI in Company Settings Accounting section - 1099 Tracking: Is1099Vendor flag on Vendor entity + DTOs; checkbox in Create/Edit views; TaxReporting1099 report action + view lists payments by year, flags vendors >= $600; report card added to Reports Landing - Migration AddFixedAssetsLockAnd1099 applied Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
200 lines
9.3 KiB
C#
200 lines
9.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace PowderCoating.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddFixedAssetsLockAnd1099 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<bool>(
|
|
name: "Is1099Vendor",
|
|
table: "Vendors",
|
|
type: "bit",
|
|
nullable: false,
|
|
defaultValue: false);
|
|
|
|
migrationBuilder.AddColumn<DateTime>(
|
|
name: "BookLockedThrough",
|
|
table: "Companies",
|
|
type: "datetime2",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "FixedAssets",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
PurchaseDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
PurchaseCost = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
SalvageValue = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
UsefulLifeMonths = table.Column<int>(type: "int", nullable: false),
|
|
AccumulatedDepreciation = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
IsDisposed = table.Column<bool>(type: "bit", nullable: false),
|
|
DisposalDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
AssetAccountId = table.Column<int>(type: "int", nullable: true),
|
|
DepreciationExpenseAccountId = table.Column<int>(type: "int", nullable: true),
|
|
AccumDepreciationAccountId = table.Column<int>(type: "int", nullable: true),
|
|
CompanyId = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
|
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_FixedAssets", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_FixedAssets_Accounts_AccumDepreciationAccountId",
|
|
column: x => x.AccumDepreciationAccountId,
|
|
principalTable: "Accounts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_FixedAssets_Accounts_AssetAccountId",
|
|
column: x => x.AssetAccountId,
|
|
principalTable: "Accounts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_FixedAssets_Accounts_DepreciationExpenseAccountId",
|
|
column: x => x.DepreciationExpenseAccountId,
|
|
principalTable: "Accounts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "FixedAssetDepreciationEntries",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FixedAssetId = table.Column<int>(type: "int", nullable: false),
|
|
PeriodYear = table.Column<int>(type: "int", nullable: false),
|
|
PeriodMonth = table.Column<int>(type: "int", nullable: false),
|
|
Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
JournalEntryId = table.Column<int>(type: "int", nullable: true),
|
|
CompanyId = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
|
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_FixedAssetDepreciationEntries", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_FixedAssetDepreciationEntries_FixedAssets_FixedAssetId",
|
|
column: x => x.FixedAssetId,
|
|
principalTable: "FixedAssets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_FixedAssetDepreciationEntries_JournalEntries_JournalEntryId",
|
|
column: x => x.JournalEntryId,
|
|
principalTable: "JournalEntries",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 16, 0, 49, 626, DateTimeKind.Utc).AddTicks(4004));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 16, 0, 49, 626, DateTimeKind.Utc).AddTicks(4009));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 16, 0, 49, 626, DateTimeKind.Utc).AddTicks(4011));
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FixedAssetDepreciationEntries_FixedAssetId",
|
|
table: "FixedAssetDepreciationEntries",
|
|
column: "FixedAssetId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FixedAssetDepreciationEntries_JournalEntryId",
|
|
table: "FixedAssetDepreciationEntries",
|
|
column: "JournalEntryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FixedAssets_AccumDepreciationAccountId",
|
|
table: "FixedAssets",
|
|
column: "AccumDepreciationAccountId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FixedAssets_AssetAccountId",
|
|
table: "FixedAssets",
|
|
column: "AssetAccountId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FixedAssets_DepreciationExpenseAccountId",
|
|
table: "FixedAssets",
|
|
column: "DepreciationExpenseAccountId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "FixedAssetDepreciationEntries");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "FixedAssets");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Is1099Vendor",
|
|
table: "Vendors");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "BookLockedThrough",
|
|
table: "Companies");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(199));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(205));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 15, 25, 26, 831, DateTimeKind.Utc).AddTicks(206));
|
|
}
|
|
}
|
|
}
|