42eff3357e
- RecurringTemplate entity with Frequency/IntervalCount/NextFireDate/EndDate/MaxOccurrences/TemplateData JSON - RecurringFrequency + RecurringTemplateType enums - RecurringTransactionService BackgroundService: hourly check, creates Draft bills or immediate expenses, advances NextFireDate, auto-deactivates on limits - RecurringTemplatesController: Index/Create/Edit/ToggleActive/Delete/GenerateNow (on-demand fire) - Three views + external JS for type-toggle and dynamic bill line items - Finance sidebar nav: Recurring Transactions - Migration: AddRecurringTemplates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
172 lines
7.4 KiB
C#
172 lines
7.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace PowderCoating.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddRecurringTemplates : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_VendorCreditApplications_Bills_BillId",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "VendorCreditId1",
|
|
table: "VendorCreditApplications",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RecurringTemplates",
|
|
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),
|
|
TemplateType = table.Column<int>(type: "int", nullable: false),
|
|
Frequency = table.Column<int>(type: "int", nullable: false),
|
|
IntervalCount = table.Column<int>(type: "int", nullable: false),
|
|
NextFireDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
EndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
MaxOccurrences = table.Column<int>(type: "int", nullable: true),
|
|
OccurrenceCount = table.Column<int>(type: "int", nullable: false),
|
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
|
TemplateData = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
LastError = table.Column<string>(type: "nvarchar(max)", 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_RecurringTemplates", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6262));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6270));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 15, 1, 54, 769, DateTimeKind.Utc).AddTicks(6271));
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VendorCreditApplications_VendorCreditId1",
|
|
table: "VendorCreditApplications",
|
|
column: "VendorCreditId1");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_VendorCreditApplications_Bills_BillId",
|
|
table: "VendorCreditApplications",
|
|
column: "BillId",
|
|
principalTable: "Bills",
|
|
principalColumn: "Id");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId",
|
|
table: "VendorCreditApplications",
|
|
column: "VendorCreditId",
|
|
principalTable: "VendorCredits",
|
|
principalColumn: "Id");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId1",
|
|
table: "VendorCreditApplications",
|
|
column: "VendorCreditId1",
|
|
principalTable: "VendorCredits",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_VendorCreditApplications_Bills_BillId",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId1",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "RecurringTemplates");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_VendorCreditApplications_VendorCreditId1",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "VendorCreditId1",
|
|
table: "VendorCreditApplications");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 14, 48, 51, 545, DateTimeKind.Utc).AddTicks(3903));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 14, 48, 51, 545, DateTimeKind.Utc).AddTicks(3909));
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "PricingTiers",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "CreatedAt",
|
|
value: new DateTime(2026, 5, 10, 14, 48, 51, 545, DateTimeKind.Utc).AddTicks(3910));
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_VendorCreditApplications_Bills_BillId",
|
|
table: "VendorCreditApplications",
|
|
column: "BillId",
|
|
principalTable: "Bills",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_VendorCreditApplications_VendorCredits_VendorCreditId",
|
|
table: "VendorCreditApplications",
|
|
column: "VendorCreditId",
|
|
principalTable: "VendorCredits",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
}
|
|
}
|